A practical approach to the AOSP build system what does envsetup.sh and lunch command do? - sharmasadhna/mylearnings GitHub Wiki
envsetup.sh When building, you usually start with build/envsetup.sh to setup your build environment. It basically adds a lot of shell commands to your bash environment, e.g:
hmm() – print short help menu
lunch() – prints lunch menu (available build targets)
add_lunch_combo() – adds a new entry to the lunch menu
mm() – Builds all of the modules in the current directory
It also sources any vendorsetup.sh files found under vendor//vendorsetup.sh, vendor///vendorsetup.sh and device//*/vendorsetup.sh, which allows vendors to add their own products to the lunch menu using the add_lunch_combo function.
lunch Next thing is to select target using the lunch menu, which was added to your bash shell environment after sourcing envsetup.sh. After making your selection, the chosen product and variant is verified and environment variables are set, including:
export TARGET_PRODUCT=$product – The chosen product
export TARGET_BUILD_VARIANT=$variant – The chosen variant
export TARGET_BUILD_TYPE=release – Only release type is available. Use choosecombo if you want to select type.
export ANDROID_BUILD_TOP=$(gettop) – The build root directory.
export ANDROID_TOOLCHAIN=... – The toolchain directory for the prebuilt cross-compiler matching the target architecture
export PATH=... – Among other stuff, the prebuilt toolchain is added to PATH.
export ANDROID_PRODUCT_OUT=... – Absolute path to the target product out directory
export ANDROID_HOST_OUT=... – Absolute path to the host out directory
make -j$proc finish a platform build by running the make -j$proc command Depending on the type of build you selected, the result can be varying. However, a typical build results in the following images: boot.img – Native system boot image. ramdisk.img – Ramdisk rootfs. recovery.img – Recovery image. ramdisk-recovery.img – Ramdisk rootfs for Recovery. system.img – System data (/system directory) userdata.img – User data (/data directory)
These images is what makes up the Android system, with one exception. The Android kernel is not a part of the AOSP, and must be built separately.
****References: https://blog.jayway.com/2012/10/24/a-practical-approach-to-the-aosp-build-system/