我知道这是一个老问题,但我最近经历了同样的经历,并想我会分享我学到的东西。
要回答问题 #1:
我不切换分支。你同步所有你想要的分支的代码,然后构建那个分支。例如,我有两个:master 和 4.3_r1,在一个文件夹中。为此,我创建了两个文件夹:
mkdir /Volumes/android_source/master
mkdir /Volumes/android_source/4.3_r1
要初始化和同步 master,我输入:
cd /Volumes/android_source/master
repo init -u https://android.googlesource.com/platform/manifest
repo sync
然后,为了初始化和同步 4.3_r1 构建,我输入:
cd /Volumes/android_source/4.3_r1
repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r1
repo sync
在构建之前,切换到基本目录并获取 envsetup.sh 文件:
# cd /Volumes/android_source/master
# source build/envsetup.sh
including device/asus/deb/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/asus/grouper/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/samsung/toroplus/vendorsetup.sh
including device/samsung_slsi/arndale/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
要回答问题 #2,一旦您运行了 envsetup.sh,午餐将在您的 PATH 中。然后,告诉它你想要构建什么。对于调试版本,告诉午餐你想要全英文。您可以在没有参数的情况下启动午餐以获得午餐菜单。
mbpr15:Android awt$ lunch full-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.2.1.000.000
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86
HOST_OS=darwin
HOST_OS_EXTRA=Darwin-13.0.0-x86_64-i386-64bit
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
OUT_DIR=out
============================================
现在您已准备好构建:
# make -j16
我有一个 8 核处理器,所以我在运行构建时使用 -j16,它大大提高了速度。
希望有帮助。