Android compilation system and android Compilation

Source: Internet
Author: User

Android compilation system and android Compilation
TARGET: PREFEQUISTES COMMANDS

main.c #include <stdio.h>#include <utility.h>int main(int argc,char *argv[]){    printf("%d",getNumber());    return 0;}utility.hint getNumber();utility.cint getNumber(){    return 2;}
Example
SimpleMakefile: main. o utility. o gcc-o SimpleMakefile main. o utility. omain. o: main. c gcc-c main. cutility. o: utility. c gcc-c utility. cMakefile (another method) OBEJCT = main. o utility. oSimpleMakefile: $ (OBEJCT) gcc-o SimpleMakefile $ (OBEJCT)
Android system Compilation:
# The main files and the last installed-files.txt generated during the droidcore generation process record the pre-installation program module # generate all executable packages of the system, such as system. img boot. img recovery. img and so on. PHONY: droidcoredroidcore: files \ systemimage \ $ (bytes) \ $ (INSTALLED_RECOVERYIMAGE_TARGET) \ $ (INSTALLED_USERDATAIMAGE_TARGET) \ $ (bytes) \ $ (INSTALLED_FILES_FILE) ------------------------------ files ------------------------------------------- # focus on the file generation process # prebuilt this mechanism is used in earlier versions. PHONY: filesfiles: prebuilt \ $ (modules_to_install) \ $ (INSTALLED_ANDROID_INFO_TXT_TARGET) # describe the modules to be installed in the system # list of the installation files for each product_FILES Module # tags_to_install indicates the module for selective compilation # get-tagged-modules to determine whether the target has a "reject" tag, if any, modules_to_install :=$ (sort \ $ (ALL_DEFAULT_INSTALLED_MODULES) \ $ (product_FILES) \ $ (foreach tag, $ (tags_to_install), $ (tag) _ MODULES) \ $ (call get-tagged-modules, shell _ $ (TARGET_SHELL) \ $ (CUSTOM_MODULES )\) define systemimage --------------------------------- # This definition is in build/core/Makefile # BUILT_SYSTEMIMAGE: = $ (systemimage_intermediates)/system. img finally generates system. imgfile # $ @ indicates the target set $ (INSTALLED_SYSTEMIMAGE): $ (BUILT_SYSTEMIMAGE) $ (RECOVERY_FROM_BOOT_PATCH) | $ (ACP) @ echo "Install system fs image: $ @ "$ (copy-file-to-target) $ (hide) $ (call assert-max-image-size, $ @ $ (RECOVERY_FROM_BOOT_PATCH), $ (BOARD_SYSTEMIMAGE_PARTITION_SIZE ), yaffs) systemimage: $ (INSTALLED_SYSTEMIMAGE )----------------------------------------------------------------------------
# Generate the dist folder in the out directory to store multiple distribution packages # dist_files only for putting your library into the dist directory with a full build .. PHONY: dist_files
Android. mk system example
  • Take android. mk of the $ (source code) \ system \ core \ adb project as an example.
# Copyright 2005 The Android Open Source Project # Android. mk for adb # LOCAL_PATH: = $ (call my-dir) # adb host tool #============================================= ==================================#clear_vars clears the variable include $ (CLEAR_VARS) other than the hundreds of LOCAL_PATH Variables) # Default to a virtual (sockets) usb interface # define usb drive USB_SRCS: = EXTRA_SRCS: = ifeq ($ (HOST_ OS), linux) USB_SRCS: = usb_linux.c EXTRA_SRCS: = get_my_path_linux.c LOCAL_LDLIBS + =-lrt-ldl-lpthread LOCAL_CFLAGS + =-Runtime ($ (HOST_ OS), darwin) USB_SRCS: = usb_osx.c EXTRA_SRCS: = get_my_path_darwin.c LOCAL_LDLIBS + =-lpthread-framework CoreFoundation-framework IOKit-framework carbonendi1_eq ($ (HOST_ OS), freebsd) USB_SRCS: = usb_libusb.c EXTRA_SRCS: = get_my_path_freebsd.c LOCAL_LDLIBS + =-lpthread-lusbendistmeq ($ (HOST_ OS), windows) USB_SRCS: = usb_windows.c EXTRA_SRCS: = get_my_path_windows.c .. /libcutils/list. c EXTRA_STATIC_LIBS: = AdbWinApi ifneq ($ (strip $ (USE_CYGWIN )),) # Pure cygwin case LOCAL_LDLIBS + =-lpthread-lgdi32 LOCAL_C_INCLUDES + =/usr/include/w32api/ddk endif ifneq ($ (strip $ (USE_MINGW )),) # MinGW under Linux case LOCAL_LDLIBS + =-lws2_32-lgdi32 USE_SYSDEPS_WIN32: = 1 LOCAL_C_INCLUDES + =/usr/i586-mingw32msvc/include/ddk endif LOCAL_C_INCLUDES + = development/host/windows/usb/api/endif # define all the source files used in this module including LOCAL_SRC_FILES: = \ adb. c \ console. c \ transport. c \ transport_local.c \ transport_usb.c \ commandline. c \ adb_client.c \ adb_auth_host.c \ sockets. c \ services. c \ Users \ $ (EXTRA_SRCS) \ $ (USB_SRCS) \ Users + = external/openssl/includeifneq ($ (USE_SYSDEPS_WIN32),) LOCAL_SRC_FILES + = export LOCAL_SRC_FILES + = fdevent. cendifLOCAL_CFLAGS + =-O2-g-DADB_HOST = 1-Wall-Wno-unused-parameterLOCAL_CFLAGS + =-D_XOPEN_SOURCE-D_GNU_SOURCE # Name of the module to be generated LOCAL_MODULE: = adbLOCAL_MODULE_TAGS: = debug # compile the library LOCAL_STATIC_LIBRARIES: = libzipfile libunz libcrypto_static $ (EXTRA_STATIC_LIBS) ifeq ($ (USE_SYSDEPS_WIN32 ),) LOCAL_STATIC_LIBRARIES + = libcutilsendif # generate a Host executable file include $ (BUILD_HOST_EXECUTABLE) $ (call dist-for-goals, dist_files sdk, $ (LOCAL_BUILT_MODULE )) ifeq ($ (HOST_ OS), windows) $ (LOCAL_INSTALLED_MODULE): \ $ (HOST_OUT_EXECUTABLES)/AdbWinApi. dll \ $ (HOST_OUT_EXECUTABLES)/AdbWinUsbApi. dllendif # adbd device daemon #================================== ==================================## the second module compilation start flag include $ (CLEAR_VARS) LOCAL_SRC_FILES: = \ adb. c \ backup_service.c \ fdevent. c \ transport. c \ transport_local.c \ transport_usb.c \ adb_auth_client.c \ sockets. c \ services. c \ file_sync_service.c \ jdwp_service.c \ framebuffer_service.c \ remount_service.c \ Users: =-O2-g-DADB_HOST = 0-Wall-Wno-unused-parameterLOCAL_CFLAGS + =-D_XOPEN_SOURCE-sources (, $ (filter userdebug eng, $ (TARGET_BUILD_VARIANT) LOCAL_CFLAGS + =-DALLOW_ADBD_ROOT = 1 endif # Name of the module to be generated LOCAL_MODULE: = modules: = trueLOCAL_MODULE_PATH: = $ (modules) LOCAL_UNSTRIPPED_PATH: = $ (TARGET_ROOT_OUT_SBIN_UNSTRIPPED) LOCAL_STATIC_LIBRARIES: = liblog libcutils libc libmincrypt # generate adbd executable file include $ (BUILD_EXECUTABLE)
Android. mk variable Parsing

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.