Android Internals 101 : Android Framework Build System
Hello Droids! Welcome back again in the exciting journey of AOSP internals with me. Today we will try to dig up in the AOSP build process and uncover some interesting facts and concepts related to it.
About this blog currently we are on 3rd chapter of our ongoing multipart series. You can visit previous editions by clicking previous and next button which are located at the bottom of this blog.
Now! Let’s get started …
AOSP build system is designed to build the entire android operating system from source code. It involves multiple processes and workflow.
We will see each process and its working with flow one by one. For now let’s concentrate on the big picture.
- There are 2 types of build files that is .mk and .bp file.
- Before android 7. Android uses make build system.
- But there are some serious flaws with make build system / .mk build system i.e.
- Build was very slow.
- Build was error prone.
- Difficult to test and debug for developers. - Google decided to improve make build system hence introduced SOONG build system.
- Now SOONG replaces android .mk files into .bp files.
- Hence if we look on AOSP project we will find .mk files as well as .bp files with SOONG build system under the hood.
SOONG Build System
- As Google is on the verge of replacing *.mk files into *.bp. they wanted better open hence they introduced SOONG.
- Now SOONG build system was written in GO language.
- SOONG and Kati converts *.bp and *.mk files into *.ninja files respectively as mentioned in above diagram.
- Then the ninja build system converts it into *.so, *.apk and *.jar
- Ninja build system is lower level system that hides underthehood and works with Make as well as SOONG build systems.
Source Tree Compilation Flow :
Compiling android source code involves following steps as mentioned in above diagram :
- Initialize repo and sync source code
repo init -u https://android.googlesource.com/platform/manifest
repo sync
- Setup the build environment
- source — It is shell command that read and execute the content of build/envsetup.sh line by line.
- envsetup.sh is a shell script
source build/envsetup.sh
- Select build target
lunch aosp_arm-eng
Once you selected the targeted build and hit enter this step triggers to start the process of android compilation which follows the same flow i.e. The same steps of SOONG build system.
- Build compilation and packaging usually takes longer time but once the process completes it output the system image file and other necessary files in
out/
directory.
Okay, we have reached the end of this blog. Hope we all are on same page about the AOSP build system and it’s internal working.
Here is the bonus article link of some frequently used AOSP commands.
In the next article we’ll see such interesting topics of android internal’s, stay tuned. If you like please share with your friends, Please write your feedback for further improvements. Happy learning.
Let me know your experience about reading of this blog on my email.