Gue*_*OCs 11 android go android-source android-soong
AOSP 的所有 git 项目都由 repo 工具克隆,该工具读取此 xml:https : //android.googlesource.com/platform/manifest/+/refs/heads/master/default.xml。
AOSP 指南说为了构建,我们应该source build/envsetup.sh在 repo 克隆所有存储库的文件夹上运行。因此,让我们看看platform/build清单存储库中的 default.xml。我们得到
<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>
Run Code Online (Sandbox Code Playgroud)
我们确认envsetup.sh 所在的位置。,它在platform/build。它定义了m根据 AOSP 指南构建整个 AOSP 项目的函数:
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" "$@"
)
Run Code Online (Sandbox Code Playgroud)
好的,看起来build/soong/soong_ui.bash是我们运行m函数时调用的地方,所以这个脚本应该构建一切。
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 $@
}
Run Code Online (Sandbox Code Playgroud)
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" "$@"
Run Code Online (Sandbox Code Playgroud)
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.
您已经发现了很多,并且您正确地使用了从m到 的链接soong_ui.bash,然后开始microfactory。
根据我对代码的阅读,其目的soong_build_go是构建android/soong/cmd/soong_ui具有二进制名称的包soong_ui。就像 Yong 在另一个答案中所说的那样,这会soong_ui在目录下创建二进制文件$(getoutdir),并且该二进制文件的源位于build/soong/cmd/soong_ui/main.go。
至于您关于Android.bp文件的更新问题,它从运行时开始符号链接,但如您所见,该文件是空的。build/soong/root.bprepo sync
相反,m它告诉 Soong 构建all_modules,最终运行另一个名为 的工具kati。根据https://github.com/google/kati中的描述,Kati 处理 GNU makefile 并将它们转换为Ninja构建文件。
此时,我们(大部分)可以假设常规 Make 语义,即使底层构建系统实际上是 Kati、Ninja 和 Soong 等。由于工作目录是$TOP,因此使用Makefile符号链接的根目录中的。build/make/core/root.mk其中包括main.mk,然后包括build/make/core/Makefile。在该 makefile 中,您可以看到不同.img文件是如何构建的(例如system.img)。
| 归档时间: |
|
| 查看次数: |
615 次 |
| 最近记录: |