一、android build system编译系统概述
二、envsetup.sh脚本(Android10)
三、soong_ui.bash脚本
四、soong_ui的main.go
五、kati中调用main.mk
六、make目录中的main.mk
七、AndroidProducts.mk
八、module-info.json
九、子模块的执行
module-info.json文件与envsetup.sh的关系
lunch之后,会增加一些与module-info.json
相关的命令
allmod命令
lunch
之后会增加一个allmod
命令
该命令执行后会显示所有的模块名(该命令需要在lunch之后执行)
我们可以从envsetup.sh
文件查看一下这个命令
# List all modules for the current device, as cached in module-info.json. If any build change is
# made and it should be reflected in the output, you should run 'refreshmod' first.
function allmod() {
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2
return 1
fi
if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then
echo "Could not find module-info.json. It will only be built once, and it can be updated with 'refreshmod'" >&2
refreshmod || return 1
fi
python -c "import json; print '\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys()))"
}
refreshmod命令
更明显模块清单(该命令需要在lunch之后执行)
# Update module-info.json in out.
function refreshmod() {
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2
return 1
fi
echo "Refreshing modules (building module-info.json). Log at $ANDROID_PRODUCT_OUT/module-info.json.build.log." >&2
# for the output of the next command
mkdir -p $ANDROID_PRODUCT_OUT || return 1
# Note, can't use absolute path because of the way make works.
m out/target/product/$(get_build_var TARGET_DEVICE)/module-info.json \
> $ANDROID_PRODUCT_OUT/module-info.json.build.log 2>&1
}
pathmod命令
获得模块路径(该命令需要在lunch之后执行)
# Get the path of a specific module in the android tree, as cached in module-info.json. If any build change
# is made, and it should be reflected in the output, you should run 'refreshmod' first.
function pathmod() {
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2
return 1
fi
if [[ $# -ne 1 ]]; then
echo "usage: pathmod <module>" >&2
return 1
fi
if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then
echo "Could not find module-info.json. It will only be built once, and it can be updated with 'refreshmod'" >&2
refreshmod || return 1
fi
local relpath=$(python -c "import json, os
module = '$1'
module_info = json.load(open('$ANDROID_PRODUCT_OUT/module-info.json'))
if module not in module_info:
exit(1)
print module_info[module]['path'][0]" 2>/dev/null)
if [ -z "$relpath" ]; then
echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)." >&2
return 1
else
echo "$ANDROID_BUILD_TOP/$relpath"
fi
}
gomod命令
调用pathmod
命令获得模块路径,然后cd过去(该命令需要在lunch之后执行)
# Go to a specific module in the android tree, as cached in module-info.json. If any build change
# is made, and it should be reflected in the output, you should run 'refreshmod' first.
function gomod() {
if [[ $# -ne 1 ]]; then
echo "usage: gomod <module>" >&2
return 1
fi
local path="$(pathmod $@)"
if [ -z "$path" ]; then
return 1
fi
cd $path
}