Facilitating the Rapid Reorganization of Android 9.0 System Source Code
Foreword
When you’ve successfully downloaded the Android Open Source Project (AOSP) and want to explore the source code, you often need to compile the system source code to meet certain requirements. These requirements include dynamic debugging, customizing the Android system, and installing the latest version of Android on your device. To achieve these goals, you need to compile the system source code.
1. Compile System Overview
To compile the Android system, you need to understand some basic concepts. The Android platform build system is based on Makefile, which is a project-independent Makefile written by the Android platform build system. This system defines the rules for compiling and integrates hundreds of Git repositories into a unified compiler. It also generates product categories and outputs them to a directory, packaged into a phone ROM, and used for SDK application development.
Makefile
The Makefile is the core of the Android platform build system. It defines the necessary parameters of a module, which are used to compile the source code and generate a corresponding object file. The Makefile is also responsible for defining the rules for compiling and integrating the source code.
Ninja
Ninja is a high-performance build system that is designed to replace the traditional Makefile-based build system. It is a high-level language compiler that is used to compile Ninja files. Soong is a build system that is used to parse Android.bp files and convert them into Ninja files.
Soong
Soong is a build system that is used to parse Android.bp files and convert them into Ninja files. It is responsible for defining the specific treatment of the corresponding command syntax and implementation.
Android.bp
Android.bp is a file that is used to replace Android.mk. It is a link between Soong and Blueprint, and it is responsible for parsing Android.bp file contents.
Blueprint
Blueprint is responsible for parsing Android.bp file contents. It is associated with syntax similar to a library file processing, and Soong is used to define the specific treatment of the corresponding command syntax and implementation.
2. Compile Source Way
There are several ways to compile the Android system source code, including:
- Source compiler system (Android official support): This method is supported by Android and can be used to compile the system source code directly on Linux.
- Source compiler system (Android official support): This method is also supported by Android and can be used to compile the system source code directly on Mac OS.
- Docker compilation: This method is supported by Docker and can be used to compile the system source code on Mac OS and Windows.
3. Prepare the Build Environment
To compile the Android system source code, you need to prepare the build environment. This includes:
- Installing JDK 8: You need to install JDK 8 on your system to compile the Android system source code.
- Installing dependencies: You need to install the following dependencies:
- Git-core
- Gnupg
- Flex
- Bison
- Gperf
- Build-essential
- Zip
- Curl
- Zlib1g-dev
- GCC-multilib
- G+±multilib
- Libc6-dev-i386
- Lib32ncurses5-dev
- X11proto-core-dev
- Libx11-dev
- Lib32z-dev
- Ccache
- Libgl1-mesa-dev
- Libxml2-utils
- Xsltproc
- Unzip
- Setting the number of processors: You need to set the number of processors to compile the Android system source code.
4. Source Reorganization
The source reorganization of the Android system source code involves three main steps:
- Initializing the environment: You need to enter the AOSP root directory and execute the following command:
source build/envsetup.sh. This script will initialize the environment and introduce other scripts for execution. - Selecting the target compiler: You need to enter the following command:
lunch. This command will allow you to select the compiler target. You will see a list of options, including:- aosp_arm-eng
- aosp_arm64-eng
- aosp_mips-eng
- aosp_mips64-eng
- aosp_x86-eng
- aosp_x86_64-eng
- aosp_car_arm-userdebug
- aosp_car_arm64-userdebug
- aosp_car_x86-userdebug
- aosp_car_x86_64-userdebug
- mini_emulator_arm64-userdebug
- m_e_arm-userdebug
- m_e_mips64-eng
- m_e_mips-userdebug
- mini_emulator_x86_64-userdebug
- mini_emulator_x86-userdebug
- uml-userdebug
- aosp_cf_x86_auto-userdebug
- aosp_cf_x86_phone-userdebug
- aosp_cf_x86_tablet-userdebug
- aosp_cf_x86_tablet_3g-userdebug
- aosp_cf_x86_tv-userdebug
- aosp_cf_x86_wear-userdebug
- aosp_cf_x86_64_auto-userdebug
- aosp_cf_x86_64_phone-userdebug
- aosp_cf_x86_64_tablet-userdebug
- aosp_cf_x86_64_tablet_3g-userdebug
- aosp_cf_x86_64_tv-userdebug
- cf_x86_auto-userdebug
- cf_x86_phone-userdebug
- cf_x86_tablet-userdebug
- cf_x86_tablet_3g-userdebug
- cf_x86_tv-userdebug
- cf_x86_wear-userdebug
- cf_x86_64_auto-userdebug
- cf_x86_64_phone-userdebug
- cf_x86_64_tablet-userdebug
- cf_x86_64_tablet_3g-userdebug
- cf_x86_64_tv-userdebug
- aosp_marlin-userdebug
- aosp_marlin_svelte-userdebug
- aosp_sailfish-userdebug
- aosp_walleye-userdebug
- aosp_walleye_test-userdebug
- aosp_taimen-userdebug
- hikey-userdebug
- hikey64_only-userdebug
- hikey960-userdebug
You need to select the target compiler by entering the corresponding number or the name of the target compiler.
- Starting the compilation: You need to enter the following command:
make -j6. This will start the compilation process with six parallel tasks.
The Single Source Encoding
To compile the system Settings application modules, you need to enter the following commands:
source build/envsetup.shlunch 5cd packages/apps/Settingsmm compile
This will compile the system Settings application modules and generate the Settings.odex file and the Settings.apk file in the out/target/product/generic_x86/system/priv-app/Settings directory.
Conclusion
In this article, we have discussed how to facilitate the rapid reorganization of the Android 9.0 system source code. We have covered the basic concepts of the Android platform build system, the Makefile, Ninja, Soong, Android.bp, and Blueprint. We have also discussed the different ways to compile the system source code, including the source compiler system, Docker compilation, and the build environment. Finally, we have covered the three main steps involved in the source reorganization of the Android system source code.