Address: http://hi.baidu.com/snownight/blog/item/f472d9f9f450f157242df262.html
Main. mkAnalysis
Main. mkIt mainly includes the following parts:
1.
ShellSet
2.Compile environment Configuration
3.Compile environment check
4.Include necessary macros
5.AccordingMakeSet the variables during compilation.
6.ContainsAndroid. mk
7.Set the compilation systemTarget: Prerequisites controls the entire compilation process
The following are some explanations:
With the preceding sectionAndroidCompile the system architecture analysis, if you need to modifyAndroidCompile the system so that you do not blindly find the problem and modify it.Code. Analysis todayMain. mk, It can help usAndroidCompilation provides valuable information and how to customize ourAndroidCompile the system.
Main. mkThe first sentence is based onAndroid_build_shellUsed to package the compilation systemShellIf we do not want to useBashAnd want to useSh, You can write in front of itAndroid_build_shell
: =/Bin/sh, OrBuild/envsetup. Sh.
FinishedShellAfter thatMake_versionAnd then define the default compilation target.Droid!
If we enterMakeIf no parameter is added, the default target isDroid. Note thatInclude $ (build_system)/config. mkWritten in default targetDroidAfter the dependency, but its and subsequent statements must be executed. This isMakefile.
LaterInclude config. mk cleanbuild. mkConfigure the compilation system. Check the compiling environment, including case sensitivity, path check,JavaVersion check,JavacVersion check.AndroidIf the check for the compilation environment meets the conditions, it will not be checked again during the next compilation.
After checking the version, it will includeDefinations. mk, As described earlier,Definations. mkMany macros are defined in the compilation system. These macros need to be called frequently during compilation. Therefore, they are included in the early stages of compilation.
ThenMakeThe input compilation type (Eng user userdebug showcommands). These configurations will affect the modules included in the final compilation target. ForEng user userdebug SDK win_sdk testsYou can view the differences among other compilation targets.Main. mkCode to find out what is the difference.
Skip some unimportant content here and jump directly
Ifeq ($ (sdk_only), true)Location, probably368When the row is near the end of the statement blockSubdirsVariable settings,SubdirsVariables determine which subfolders are finally compiled.
InSubdir_makefilesVariable settings determine whichAndroid. mkCompiled. ThenInclude $ (subdir_makefiles)All of theseAndroid. mkFile dependency. This includesDroid.
ThenMakefileTo find out all the modules to be compiled (Module), And perform the necessary classification (Eng_modules/debug_modules/tests_modulesEtc,Modules_to_check/modules_to_install), To treat it differently.
Then, a series of implicit goals are defined:Prebuilt,All_copied_headers,Files,Checkbuild,Ramdisk,Systemtallball,Userdataimage,Userdatatarball,Bootimg,Droidcore. The most important thing is to discoverDroidDependent onDroidcore,WhileDroidcoreDependent on
Droidcore: files \
Systemimage \
$ (Installed_bootimage_target )\
$ (Installed_recoveryimage_target )\
$ (Installed_userdataimage_target )\
$ (Installed_files_file)
These dependencies control the entireAndroid.
The next blog post will introduceSystem. imgThe entire generation process