511 people read comments (0) from
Figure 1 makefile structure of Android
Android compilation files mainly depend on MK files. The source code compilation name is Android. mk, which is not a common MAKEFILE file.
The MAKEFILE file in the android Directory includes the main. mk file in the build/Core directory.
Main. mk File
Main. mk:
Include build/CORE/config. mk: set some variables based on the standard variables and host information of the target board. Determine the output directory and product project.
Shell: =/bin/bash indicates the system Bash is used. If you want to use another SH, modify it accordingly.
Checks the host operating system and compiling environment.
Includes definitions. mk, which is a standard compilation system setting parameter. Mainly some macro definitions, such as all-subdir-makefiles and my-Dir macros that are common in Android. mk.
The main content is in the config. mk file.
1config. mk
First, we will check buildspec. mk in the main directory. Currently, this file does not exist. We can set some parameters here.
These parameters can be used in envsettup. mk. If the buildspec. mk file is not available, envsettup. mk defaults to some variables, such as target_arch: = arm and target_ OS: = Linux.
1.1 envsettup. mk
It should be said that envsettup. mk is an important part of config. mk and sets parameters related to some major compilation projects.
First, define deversion_defaults.mk and set the following variables:
Platform_version
Platform_sdk_version
Default_app_target_sdk
Build_id
Build_number
Set target_product, that is, if makeproduct-xxx-XXX is not used during the compilation, It is set here. Otherwise, the target and product parameters must be performed based on the content in the product_config.mk file.
Set some output file path variables, such as target_out_xxx.
Finally, some simple information is displayed on the terminal:
$ (Info ============================================ =======)
$ (Info platform_version_codename = $ (platform_version_codename ))
$ (Info platform_version = $ (platform_version ))
$ (Info target_product = $ (target_product ))
$ (Info target_build_variant = $ (target_build_variant ))
$ (Info target_simulator = $ (target_simulator ))
$ (Info target_build_type = $ (target_build_type ))
$ (Info target_arch = $ (target_arch ))
$ (Info host_arch = $ (host_arch ))
$ (Info host_ OS = $ (host_ OS ))
$ (Info host_build_type = $ (host_build_type ))
$ (Info build_id = $ (build_id ))
$ (Info ============================================ =======)
In envsetup. mk, the most important thing is product_config.mk.
Product_config.mk contains three files: node_fns.mk, product. mk, and device. mk. These three files are macro definitions or variable definitions. The purpose is to find the corresponding product and devcie information under the vendor directory and build/target directory based on the parameters passed in during make, find boardconfig. MK file to set the values of target_product and target_device.
1.2 pathmap. mk, some header file paths, and androidframework directories.
Compile some files in the system: host_static_library.mk, host_shared_library.mk, etc.
1.3 boardconfig. mk
By default, the compiled board is generic.
Find the content in the build/target/board/Generic Directory. There are two MK files, androidboard. mk and boardconfig. mk. Boardconfig. mk defines some hardware features.
2 makefile
Build/CORE/makefile files are system-integrated and complete IMG, app, frameworks, and module compilation (errors may occur)
3. For framework development, or adding an application during system transplantation, compilation is required every time the Code is written, and compilation takes a long time each time the make-related parameter command is used. The following methods can be considered for compiling.
Cdanddroid_top_path
./Build/envsetup. Sh
In this case, the Mmm, mm, and m commands are used for compilation:
M indicates compiling in the top-level directory
MM indicates that the module is compiled in the current directory.
Mmm path: Compile the module in the path directory.
Generally, you can use the mmm command when writing a module.
The following is a reprinted content, in the Framework to add or modify the code, the so-called system porting, the link address for the http://xxw8393.blog.163.com/blog/static/3725683420107532137920/
"
How to add a new class to the android framework
Google has two types of APIs and classes: open and not open. The so-called open mode is included in the value javadoc. It does not have public or private content in Java, but has something to do with Javadoc and code.
A variable is added to an open class without being hidden, which leads to errors caused by inconsistency with the original API Doc.
As prompted, there are two ways to solve the problem:
1. Add the "@ hide" annotation to the newly added variables or methods. Note that adding "@ hide" is not a simple/* @ hide, the standard javadoc should be like this/***/and the format variable should be added with {}, that is,/*** {@ hide }*/
2. To add the variable or method to the generated doc, enter:
Make Update-API
In this way, the system automatically adds the new API to current. xml.
Therefore, if you want to add a method, add it according to the above method.
If you want to add a new class, there are two types: one is to add classes under the original package. The simplest way to do this is to directly make Update-API. The other way is to add the classes under framework/base. At this time, you make Update-API will not current. Generate your class in XML. Read android. MK knows that you need to modify build/CORE/pathmap. mk in the root directory of the android source code to add your directory. Then we can.
"
In fact, for famework development, you can use the mmm command to generate a new jar package, and then manually upload it to the corresponding directory of the module, usually/system/framework, of course, you can also write a script by yourself and run the command in one step.
Figure 1 makefile structure of Android
Android compilation files mainly depend on MK files. The source code compilation name is Android. mk, which is not a common MAKEFILE file.
The MAKEFILE file in the android Directory includes the main. mk file in the build/Core directory.
Main. mk File
Main. mk:
Include build/CORE/config. mk: set some variables based on the standard variables and host information of the target board. Determine the output directory and product project.
Shell: =/bin/bash indicates the system Bash is used. If you want to use another SH, modify it accordingly.
Checks the host operating system and compiling environment.
Includes definitions. mk, which is a standard compilation system setting parameter. Mainly some macro definitions, such as all-subdir-makefiles and my-Dir macros that are common in Android. mk.
The main content is in the config. mk file.
1config. mk
First, we will check buildspec. mk in the main directory. Currently, this file does not exist. We can set some parameters here.
These parameters can be used in envsettup. mk. If the buildspec. mk file is not available, envsettup. mk defaults to some variables, such as target_arch: = arm and target_ OS: = Linux.
1.1 envsettup. mk
It should be said that envsettup. mk is an important part of config. mk and sets parameters related to some major compilation projects.
First, define deversion_defaults.mk and set the following variables:
Platform_version
Platform_sdk_version
Default_app_target_sdk
Build_id
Build_number
Set target_product, that is, if makeproduct-xxx-XXX is not used during the compilation, It is set here. Otherwise, the target and product parameters must be performed based on the content in the product_config.mk file.
Set some output file path variables, such as target_out_xxx.
Finally, some simple information is displayed on the terminal:
$ (Info ============================================ =======)
$ (Info platform_version_codename = $ (platform_version_codename ))
$ (Info platform_version = $ (platform_version ))
$ (Info target_product = $ (target_product ))
$ (Info target_build_variant = $ (target_build_variant ))
$ (Info target_simulator = $ (target_simulator ))
$ (Info target_build_type = $ (target_build_type ))
$ (Info target_arch = $ (target_arch ))
$ (Info host_arch = $ (host_arch ))
$ (Info host_ OS = $ (host_ OS ))
$ (Info host_build_type = $ (host_build_type ))
$ (Info build_id = $ (build_id ))
$ (Info ============================================ =======)
In envsetup. mk, the most important thing is product_config.mk.
Product_config.mk contains three files: node_fns.mk, product. mk, and device. mk. These three files are macro definitions or variable definitions. The purpose is to find the corresponding product and devcie information under the vendor directory and build/target directory based on the parameters passed in during make, find boardconfig. MK file to set the values of target_product and target_device.
1.2 pathmap. mk, some header file paths, and androidframework directories.
Compile some files in the system: host_static_library.mk, host_shared_library.mk, etc.
1.3 boardconfig. mk
By default, the compiled board is generic.
Find the content in the build/target/board/Generic Directory. There are two MK files, androidboard. mk and boardconfig. mk. Boardconfig. mk defines some hardware features.
2 makefile
Build/CORE/makefile files are system-integrated and complete IMG, app, frameworks, and module compilation (errors may occur)
3. For framework development, or adding an application during system transplantation, compilation is required every time the Code is written, and compilation takes a long time each time the make-related parameter command is used. The following methods can be considered for compiling.
Cdanddroid_top_path
./Build/envsetup. Sh
In this case, the Mmm, mm, and m commands are used for compilation:
M indicates compiling in the top-level directory
MM indicates that the module is compiled in the current directory.
Mmm path: Compile the module in the path directory.
Generally, you can use the mmm command when writing a module.
The following is a reprinted content, in the Framework to add or modify the code, the so-called system porting, the link address for the http://xxw8393.blog.163.com/blog/static/3725683420107532137920/
"
How to add a new class to the android framework
Google has two types of APIs and classes: open and not open. The so-called open mode is included in the value javadoc. It does not have public or private content in Java, but has something to do with Javadoc and code.
A variable is added to an open class without being hidden, which leads to errors caused by inconsistency with the original API Doc.
As prompted, there are two ways to solve the problem:
1. Add the "@ hide" annotation to the newly added variables or methods. Note that adding "@ hide" is not a simple/* @ hide, the standard javadoc should be like this/***/and the format variable should be added with {}, that is,/*** {@ hide }*/
2. To add the variable or method to the generated doc, enter:
Make Update-API
In this way, the system automatically adds the new API to current. xml.
Therefore, if you want to add a method, add it according to the above method.
If you want to add a new class, there are two types: one is to add classes under the original package. The simplest way to do this is to directly make Update-API. The other way is to add the classes under framework/base. At this time, you make Update-API will not current. Generate your class in XML. Read android. MK knows that you need to modify build/CORE/pathmap. mk in the root directory of the android source code to add your directory. Then we can.
"
In fact, for famework development, you can use the mmm command to generate a new jar package, and then manually upload it to the corresponding directory of the module, usually/system/framework, of course, you can also write a script by yourself and run the command in one step.