Android Build/core/makefile and Main.mk

Source: Internet
Author: User

The Android make system is divided into four tiers

  • Arch
  • Board
  • Device
  • Product

The definitions referenced in each character android.mk file are stored under./build/core/!
Like in Android.mk.
Include $ (clear_vars)
It corresponds to the clear_vars:=$ (Build_system) in the./build/core/config.mk/clear_vars.mk
Include $ (build_package)
It corresponds to the build_package:=$ (Build_system) in the./build/core/config.mk/package.mk

modules in the Main.mk
. Phony:checkbuilt
. Phony:prebuilt
. Phony:files
. Phony:ramdisk
. Phony:systemimage
. Phony:userdataimage
. Phony:bootimage
. Phony:recoveryimage
. Phony:droidcore
. Phony:apps_only
. Phony:sdk
. Phony:clean
. Phony:clobber
. Phony:modules
. Phony:showcommands


In a makefile file, you can make multiple targets at once! The structure of each individual target is broadly as follows

local_path:=$ (call My-dir)//Get current directory
#include $ (clear_vars) The//make system defines a number of private variables for the submodule, which is called to initialize all the private variables
...
There will be different local variables depending on the needs of the content.
...
#include $ (build_xxx)//Perform compilation tasks


Compiling apk
local_src_files:=$ (call All-subdir-java-files)
Local_package_name:=packagename
Include $ (build_package)

Compiling applications that rely on static Java libraries
local_static_java_libraries:=static-library
local_src_files:=$ (call All-subdir-java-files)
Local_package_name:=packagename
Include $ (build_package)

Compiling an application that needs to be signed with platform key
local_src_files:=$ (call All-subdir-java-files)
Local_package_name:=packagename
Local_certificate:=platform
Include $ (build_package)

Compiling an application that requires a specific key
Local_src_files: = $ (call all-subdir-java-files)
Local_package_name: = LocalPackage
local_certificate: = Vendor/example/certs/app
Include $ (build_package)

Add a precompiled application
Local_src_files: = $ (local_module). apk
Local_module: = Localmodulename
Local_module_class: = APPS
Local_module_suffix: = $ (common_android_package_suffix)

Include $ (build_prebuilt)

Local_src_files: = $ (call all-subdir-java-files)
local_java_libraries: = Android.test.runner
Local_module: = sample
Include $ (build_static_java_library)


commonly used MK classification
android.mkFor compiling modules or APK, the module corresponds to native code,package corresponding to Java
androidproducts.mkSet up product, the settings system contains those applications
target_<os>-<arch>.mk,host_<os>-<arch>.mk,<os>-<arch>.mkSet up for different system and CPU frame frames
boardconfig.mkTo set up a motherboard, such as a driver choice

./build/core/makefileDefines how the image is generated

Frameworks/base/core/java
When you extend the SDK, you can add your own classes to it

Make parameters
build/envsetup.shYou can set up the environment and support the MM command after running, so make support compiles only one module
buildspec.mk

Users can also use themmTo compile the specified module, or byMake clean-module_nameTo delete the specified module.

MakeOne_shot_makefile=<path to Androiod.mk>

with Create_module_info_file, the build system will list all module information in the $ (product_out)/module-info.txt

MakeCreate_module_info_file=true produces a single image file for early hardware testing
Host_build_typeAndTarget_build_typeUsed to set debug or Release,debug with debugging information, these two parameters can also be set in buildspec.mk to prevent being repeatedly specified elsewhere

Some of the other variables
Local_aapt_flags
Local_acp_unavailabl
Local_additional_java_dir
Local_aidl_includes
Local_allow_undefined_symbols
Local_arm_mode
Local_asflags
Local_asset_dir
Local_asset_files is valid when working with Build_package, indicating that the resource file
Local_built_module_stem
Local_c_includes used to specify the outer header file path
LOCAL_CC can specify the C compiler
Local_jar_manifest
Local_jarjar_rules
Local_jar_path
Local_shared_libraries can link dynamic library
Local_src_files Compiling source files
local_static_java_libraries
Local_static_libraries can link static library
Local_uninstallable_module
Local_whole_static_libraries prohibit deletion of useless code in a library at connection time
Local_force_static_executable if the compiled executable is to be statically linked (execution is not dependent on any dynamic library)
local_java_librariesWhen compiling Java applications and libraries, specify the Java class libraries that are included, there are two core and framework
In most cases it is defined as: local_java_libraries: = Core Framework
Note that local_java_libraries is not required and is not allowed to be defined when compiling the APK (the system will automatically add)




Envsetup.mk primarily reads some variables in the environment variable written by envsetup.sh to configure the output directory during compilation
CONFIG.MK defines the tools required for each module, and how to compile the modules
Clear_vars:= $ (Build_system)/clear_vars.mk
Build_host_static_library:= $ (Build_system)/host_static_library.mk
Build_host_shared_library:= $ (Build_system)/host_shared_library.mk
Build_static_library:= $ (Build_system)/static_library.mk
Build_raw_static_library: = $ (Build_system)/raw_static_library.mk
Build_shared_library:= $ (Build_system)/shared_library.mk
Build_executable:= $ (Build_system)/executable.mk
Build_raw_executable:= $ (Build_system)/raw_executable.mk
Build_host_executable:= $ (Build_system)/host_executable.mk
Build_package:= $ (Build_system)/package.mk
Build_host_prebuilt:= $ (Build_system)/host_prebuilt.mk
Build_prebuilt:= $ (Build_system)/prebuilt.mk
Build_multi_prebuilt:= $ (Build_system)/multi_prebuilt.mk
Build_java_library:= $ (Build_system)/java_library.mk
Build_static_java_library:= $ (Build_system)/static_java_library.mk
Build_host_java_library:= $ (Build_system)/host_java_library.mk
Build_droiddoc:= $ (Build_system)/droiddoc.mk
Build_copy_headers: = $ (Build_system)/copy_headers.mk
Build_key_char_map: = $ (Build_system)/key_char_map.mk
all of the above *.mk contain the base_rules.mk

Products Settings
./build/target/product/androidproducts.mk
Module Settings
Some of native code and JavaGeneral MethodsIt's all in the./build/core/definitions.mk
Build_share_xxx and other variables in the./build/core/config.mk
Board
./build/target/board/$ (Target_device)/boardconfig.mk
./vendor/*/$ (Target_device)/boardconfig.mk
rules related
Definitions related to Local_module_tags


Include $ (build_static_library) compiled into a static library
Include $ (build_shared_library) compiled into a dynamic library.
Include $ (build_executable) compiled into an executable program

Common functions
Call My-dir
Call All-subdir-java-files
Call All-java-files-under
Call all-makefiles-under,$ (Local_path)
Call All-clean-step
Call Import-module,android/native_app_glue
Call Inherit-product,xxx.mk
Call Inherit-product-if-exists
Call Device-test
Call Include-path-for,libpagemap
Call dist-for-goals,dist_files,$ (Local_built_module)
Call _add-charger-image,$ (_IMG)
Call libfilterfw-all-java-files-under,$ (1)
Call libfilterfw_to_document,$ (Local_path)
Call intermediates-dir-for,executables,$ (local_module,true)
Call all-named-subdir-makefiles,$ (Legacy_modules)
Call Rm;call MKDIR
Call Emugl-begin-host-shared-library,libegl_translator
Call Emugl-import,libopenglosutils
Call Emugl-end-module
Call EMUGL-EXPORT,LDLIBS,-LGL
Cal emugl-export,ldflags,$ (Gl_common_linker_flags)
Call EMUGL-SET-SHARED-LIBRARY-SUBPATH,HW
Call emugl-export,c_includes,$ (Intermediates)
Call all-makefiles-under,$ (Local_path) The difference between this and the following is unclear.
Call All-subdis-makefiles This is usually the tail of the entire makefile to implement recursive invocation of makefile in subdirectories, making the entire make system a tree-like structure

Transfer from shine80769769.blog.163.com/blog/static/1791482452012619105744163/

Android Build/core/makefile and Main.mk

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.