All the git projects for the AOSP are cloned by the repo tool, which reads this xml: https://android.googlesource.com/platform/manifest/+/refs/heads/master/default.xml.
AOSP guide says the in order to build, we should run source build/envsetup.sh
on the folder where repo cloned all repositories. So let's look at the platform/build
on the default.xml from the manifest repository. We get
<project path="build/make" name="platform/build" groups="pdk" >
<copyfile src="core/root.mk" dest="Makefile" />
<linkfile src="CleanSpec.mk" dest="build/CleanSpec.mk" />
<linkfile src="buildspec.mk.default" dest="build/buildspec.mk.default" />
<linkfile src="core" dest="build/core" />
<linkfile src="envsetup.sh" dest="build/envsetup.sh" />
<linkfile src="target" dest="build/target" />
<linkfile src="tools" dest="build/tools" />
</project>
We confirm where envsetup.sh is located., it is in platform/build
. It defines the function m
which according to the AOSP guide, builds the entire AOSP project:
function _trigger_build()
(
local -r bc="$1"; shift
if T="$(gettop)"; then
_wrap_build "$T/build/soong/soong_ui.bash" --build-mode --${bc} --dir="$(pwd)" "$@"
else
echo "Couldn't locate the top of the tree. Try setting TOP."
fi
)
function m()
(
_trigger_build "all-modules" "$@"
)
Ok, so looks like build/soong/soong_ui.bash
is the place called when we run the m
function, so this script should build everything.
Here's soong_ui.bash. It sources source ${TOP}/build/soong/scripts/microfactory.bash
and then calls soong_build_go soong_ui android/soong/cmd/soong_ui
Here's microfactory.bash, where we find function soong_build_go
soong_build_go
{
BUILDDIR=$(getoutdir) \
SRCDIR=${TOP} \
BLUEPRINTDIR=${TOP}/build/blueprint \
EXTRA_ARGS="-pkg-path android/soong=${TOP}/build/soong -pkg-path github.com/golang/protobuf=${TOP}/external/golang-protobuf" \
build_go $@
}
We find build_go
in microfactory.bash from build/blueprint:
Looks like all of this is for building the microfactory.go project. I think it has something to do with the soong build system.
I'm now lost. After building microfactory.go, what happens? Where does actual Android code gets built?
microfactory.sh says build_go does this: Bootstrap microfactory from source if necessary and use it to build the requested binary.
The requested binary is android/soong/cmd/soong_ui
I'm trying to find android/soong/cmd/soong_ui
but I don't know what/where it is, but I'd guess is the soong build system, not the AOSP project yet.
UPDATE:
on soong_ui.bash
, I noticed it end with
cd ${TOP}
exec "$(getoutdir)/soong_ui" "$@"
Remember that this is called form envsetup.sh
. Well, ${TOP}
, I guess, is the place where repo clones everything. Looks like it's trying to execute soong_ui
with the arguments from envsetup.sh
which are --build-mode --${bc} --dir="$(pwd)" "$@"
, where this $@
is "all-modules" "$@"
, I guess.
I assume song_ui
is the soong executable. It should look for Android.bp
on the ${TOP}
, but I don't think there is one on the place where repo cloned everything.
As of June 2021, Google is using 72-core machines with 64 GB of RAM internally, which take about 40 minutes for a full build (and just a few minutes for incremental builds, depending on exactly which files were modified). By contrast, a 6-core machine with a similar amount of RAM takes 3 hours.
The Android Open Source Project is a completely free and open operating system developed by Google. But as you might know, AOSP isn't actually Android — it's missing critical components like the Google Play Store, Google Play Services, and most Google applications.
The Android Open Source Project (AOSP) is an initiative created to guide development of the Android mobile platform. The Android platform consists of the operating system (OS), middleware and integral mobile applications.
The Android Open Source Project is often confused with “ stock Android ” but that’s an oversimplification. The AOSP contains everything developers need to build Android but it doesn’t include everything you need for a finished smartphone. First, Google and the AOSP can’t provide kernel device drivers for every hardware configuration out there.
What is AOSP? Everything you need to know Here's what you need to know about the Android Open Source Project (AOSP) powering your smartphone. For the better part of a decade, Robert has been writing about technology and trying not to ignore his various unfinished gadget projects.
AOSP guide says the in order to build, we should run source build/envsetup.sh on the folder where repo cloned all repositories. So let's look at the platform/build on the default.xml from the manifest repository. We get
Building the AOSP. The first step to build the AOSP based on the sources you just downloaded is to set up the build environment. Run this command from /home/aosp/source: source build/envsetup.sh. This will make a set of useful commands — which you’ll need for the next steps — available in your terminal.
You have already found out a lot, and you are right with the link from m
to soong_ui.bash
and then starting microfactory
.
From my reading of the code, the purpose of soong_build_go
is to build the package android/soong/cmd/soong_ui
, with the binary name soong_ui
. Like Yong said in the other answer, this creates the binary soong_ui
under the directory $(getoutdir)
, and the source for that binary is located at build/soong/cmd/soong_ui/main.go
.
As for your updated question about an Android.bp
file, it is symlinked from build/soong/root.bp
when repo sync
is run, but as you can see, the file is empty.
Instead, in m
it tells Soong to build all_modules
, which eventually runs another tool called kati
. From the description in https://github.com/google/kati, Kati processes GNU makefiles and turns them into Ninja build files.
At this point we can (mostly) assume regular Make semantics, even though the underlying build system is actually Kati and Ninja and Soong etc. Since the working directory is $TOP
, the Makefile
at the root directory, which is symlinked from build/make/core/root.mk
is used. Which includes main.mk
which then includes build/make/core/Makefile
. Inside that makefile you can see how the different .img
files are built (e.g. system.img).
Let's take make systemimage as an example:
The call sequence is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With