參考資料:理解 Android Build 系統android
make clean | 執行清理,等同於:rm -rf out/。 |
make sdk | 編譯出 Android 的 SDK。 |
make clean-sdk | 清理 SDK 的編譯產物。 |
make update-api | 更新 API。在 framework API 改動以後,須要首先執行該命令來更新 API,公開的 API 記錄在 frameworks/base/api 目錄下。 |
make dist | 執行 Build,並將 MAKECMDGOALS 變量定義的輸出文件拷貝到 /out/dist 目錄。 |
make all | 編譯全部內容,無論當前產品的定義中是否會包含。 |
make help | 幫助信息,顯示主要的 make 目標。 |
make snod | 從已經編譯出的包快速重建系統鏡像。 |
make libandroid_runtime | 編譯全部 JNI framework 內容。 |
make framework | 編譯全部 Java framework 內容。 |
make services | 編譯系統服務和相關內容。 |
make <local_target> | 編譯一個指定的模塊,local_target 爲模塊的名稱。 |
make clean-<local_target> | 清理一個指定模塊的編譯結果。 |
make dump-products | 顯示全部產品的編譯配置信息,例如:產品名,產品支持的地區語言,產品中會包含的模塊等信息。 |
make PRODUCT-xxx-yyy | 編譯某個指定的產品。 |
make bootimage | 生成 boot.img |
make recoveryimage | 生成 recovery.img |
make userdataimage | 生成 userdata.img |
make cacheimage | 生成 cache.img |
咱們正常步驟爲:shell
1). source build/envsetup.shapi
2). lunchbash
3). make -jxapp
打開build/envsetup.sh,發現裏面全都是函數,摺疊所有函數,一直拖到最後,發現代碼函數
if [ "x$SHELL" != "x/bin/bash" ]; then case `ps -o command -p $$` in *bash*) ;; *) echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results" ;; esac fi # Execute the contents of any vendorsetup.sh files we can find.
#包含各類vendorsetup.s腳本文件進來,而後去執行
for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
`test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` do echo "including $f" . $f done
unset f addcompletions
查看發現沒錯,查看lunchui
function lunch() { local answer #若是有第一個參數 if [ "$1" ] ; then answer=$1 else #若是沒有參數,就進入print_lunch_menu函數 print_lunch_menu echo -n "Which would you like? [aosp_arm-eng] " read answer fi local selection= if [ -z "$answer" ] then selection=aosp_arm-eng elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") then if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] then selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} fi elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$") then selection=$answer fi if [ -z "$selection" ] then echo echo "Invalid lunch combo: $answer" return 1 fi export TARGET_BUILD_APPS= local product=$(echo -n $selection | sed -e "s/-.*$//") check_product $product if [ $? -ne 0 ] then echo echo "** Don't have a product spec for: '$product'" echo "** Do you have the right repo manifest?" product= fi local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//") check_variant $variant if [ $? -ne 0 ] then echo echo "** Invalid variant: '$variant'" echo "** Must be one of ${VARIANT_CHOICES[@]}" variant= fi if [ -z "$product" -o -z "$variant" ] then echo return 1 fi #處處環境變量 export TARGET_PRODUCT=$product export TARGET_BUILD_VARIANT=$variant export TARGET_BUILD_TYPE=release echo set_stuff_for_environment printconfig }
function hmm() { cat <<EOF Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment: - lunch: lunch <product_name>-<build_variant> - tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user] - croot: Changes directory to the top of the tree. - m: Makes from the top of the tree. - mm: Builds all of the modules in the current directory, but not their dependencies. - mmm: Builds all of the modules in the supplied directories, but not their dependencies. To limit the modules being built use the syntax: mmm dir/:target1,target2. - mma: Builds all of the modules in the current directory, and their dependencies. - mmma: Builds all of the modules in the supplied directories, and their dependencies. - cgrep: Greps on all local C/C++ files. - ggrep: Greps on all local Gradle files. - jgrep: Greps on all local Java files. - resgrep: Greps on all local res/*.xml files. - sgrep: Greps on all local source files. - godir: Go to the directory containing a file. Look at the source to view more functions. The complete list is: EOF T=$(gettop) local A A="" for i in `cat $T/build/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do A="$A $i" done echo $A }