Android compilation system first involved

Source: Internet
Author: User

Rule format for makefile file Target:prefequistes COMMANDS
#include <stdio.h>#include <utility.h>int main(int argc,char *argv[]){    printf("%d",getNumber());    return0;}utility.hint getNumber();utility.cint getNumber(){    return2;}
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(另一种写法)OBEJCT=main.o utility.oSimpleMakefile:$(OBEJCT)gcc -o SimpleMakefile $(OBEJCT)
Compilation of Android system:
    1. 1.makefile->build/core/main.mk
    2. MAIN.MK's droid Process
      app:droid->app_only->$ (Unbunled_build_modules)
      System: Droid->droidcore
      ->dist_files

    3. MAIN.MK custom files (processing attribute parts)
      Vendorsetup.sh (appearing in envsetup.sh)
      Androidproducts.mk
      Boardconfig.mk
      Android.mk (appearing in main.mk)

    4. Droidcore compilation process
# The process of generating Droidcore main files with the last generated Installed-files.txt record pre-installed program module# All executable packages responsible for generating the system, such as System.img boot.img recovery.img, etc..Phony:DroidcoreDroidcore:Files Systemimage$(Installed_bootimage_target)$(Installed_recoveryimage_target)$(Installed_userdataimage_target)$(Installed_cacheimage_target)$(Installed_vendorimage_target)$(Installed_files_file)------------------------------Files-----------------------------------------# focus on the files generation process# prebuilt This mechanism for earlier versions.Phony:FilesFiles:prebuilt$(Modules_to_install)$(Installed_android_info_txt_target)# describes the modules that the system needs to install# product_files List of installation files for each modules# Tags_to_install Modules that are selectively compiled by flags# Get-tagged-modules Determines if the target has a "reject" tag, and if so, does not compileModules_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))----------------------------------------------------------------------------------------------------------Systemimag E-----------------------------------# This definition is in Build/core/makefile# Built_systemimage: = $ (systemimage_intermediates)/system.img final generated system.img file# [Email protected] represents a collection of target$(Installed_systemimage): $(Built_systemimage)$(Recovery_from_boot_patch) |$(ACP)@echo "Install system FS Image: [email protected]"    $(Copy-file-to-target)$(Hide$(Call Assert-max-image-size,[email protected] $(Recovery_from_boot_patch),$(board_systemimage_partition_size), yaffs)Systemimage: $(Installed_systemimage)----------------------------------------------------------------------------
    1. Dist_files compilation process
# 在outforlibraryintowith a full build..PHONY: dist_files
ANDROID.MK System Example
    • Take the android.mk of the $ (source) \SYSTEM\CORE\ADB project as an example
# Copyright 2005 the Android Open Source Project## android.mk for ADB#local_path:=$(Pagermy-dir)# ADB Host tool# =========================================================# Clear_vars Remove hundreds of Local_path outside the variableInclude$(Clear_vars)# Default to a virtual (sockets) USB Interface# define USB driveUsb_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 + = -dworkaround_bug6558362endififeQ ($ (host_os), Darwin) Usb_srcs: = usb_osx.c Extra_srcs: = get_my_path_darwin.c local_ldlibs + =-lpthread-framework CoreFoundation- Framework Iokit-framework CarbonendififeQ ($ (host_os), FreeBSD) Usb_srcs: = USB_LIBUSB.C Extra_srcs: = get_my_path_freebsd.c Local_ldlibs + =-lpthread-lusbendififeQ ($ (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 caseLocal_ldlibs + =-lpthread-lgdi32 Local_c_includes + =/usr/include/W32API/DDKendif IfneQ ($ (strip $ (use_mingw)),)# MinGW under Linux caseLocal_ldlibs + =-lws2_32-lgdi32 Use_sysdeps_win32: =1Local_c_includes + =/usr/i586-MINGW32MSVC/INCLUDE/DDK endif local_c_includes + = Development/host/windows/usb/api/endif# All the source files used to define this module include the driver variables used aboveLocal_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 file_sync_client.c$(EXTRA_SRCS)$(USB_SRCS) Usb_vendors.clocal_c_includes + = External/openssl/includeifneQ ($ (use_sysdeps_win32),) Local_src_files + = sysdeps_win32.cElseLocal_src_files + = fdevent.cendiflocal_cflags +-o2-g-dadb_host=1-wall-wno-unused-parameterlocal_cflags + =-d_xopen_source-d_gnu_source# The name of the module to be generatedLocal_module: = adblocal_module_tags: = Debug# Compile the libraries you need to useLocal_static_libraries: = Libzipfile Libunz libcrypto_static$(Extra_static_libs) IFEQ ($ (use_sysdeps_win32),) local_static_libraries + = Libcutilsendif# indicates a host executable file is generatedInclude$(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# =========================================================# Second Module compilation start FlagInclude$(Clear_vars) Local_src_files: = ADB.C backup_service.c fdevent.c transport.c transport_local.c Trans PORT_USB.C adb_auth_client.c sockets.c services.c file_sync_service.c jdwp_service.c framebuffer_s ervice.c remount_service.c usb_linux_client.c log_service.clocal_cflags: =-o2-g-dadb_host=0-wall-wno-unused-parameterlocal_cflags + =-d_xopen_source-d_gnu_sourceifneQ (,$(filter Userdebug Eng,$ (target_build_variant))) Local_cflags + =-dallow_adbd_root=1endif# The name of the module to be generatedLocal_module: = adbdlocal_force_static_executable: = Truelocal_module_path: =$(Target_root_out_sbin) Local_unstripped_path: =$(target_root_out_sbin_unstripped) Local_static_libraries: = Liblog libcutils libc libmincrypt# Generate ADBD executable fileInclude$(build_executable)
ANDROID.MK variable parsing

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android compilation system first involved

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.