msm8909+android5.1.1编译前配置及增加新项目和产品所需分支
msm8909+android5.1.1编译前配置及增加新项目和产品所需分支
编译前的选项配置:
(1)source build/envseutp.sh
(2)choosecomb
1.source build/envsetup.sh
source 是用来运行 shell 脚本的命令 功能和 "." 和相同,因此 也可以写作: . build/envsetup.sh
including device/lge/mako/vendorsetup.sh includingdevice/generic/mini-emulator-x86/vendorsetup.sh includingdevice/generic/mini-emulator-armv7-a-neon/vendorsetup.sh includingdevice/generic/mini-emulator-x86_64/vendorsetup.sh including device/generic/mini-emulator-mips/vendorsetup.sh includingdevice/generic/mini-emulator-arm64/vendorsetup.sh including device/qcom/common/vendorsetup.sh includingdevice/htc/flounder/vendorsetup.sh including device/asus/fugu/vendorsetup.sh includingdevice/asus/tilapia/vendorsetup.sh includingdevice/asus/grouper/vendorsetup.sh including device/asus/deb/vendorsetup.sh includingdevice/samsung/manta/vendorsetup.sh includingvendor/qcom/proprietary/common/vendorsetup.sh including sdk/bash_completion/adb.bash
2.choosecombo
Project choices are:
1. CB03
Which would you like? [CB03] 1
Build type choices are:
1. release
2. debug
Which would you like? [1] 1
Product choices are:
1. msm8909
Which product would you like? [msm8909] 1
Variant choices are:
1. user
2. userdebug
3. eng
Which would you like? [eng] 1
chipset are:
1. 8909
2. 8209
Which would you like? [8909] 1
Multisim choices are:
1. ssss
2. dsds
Which would you like? [ssss] 1
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=msm8909
TARGET_BUILD_VARIANT=user
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-30-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=LMY47V
SIMCOM_PROJECT=CB03
SIMCOM_MULTISIM=ssss
OUT_DIR=out
============================================
上面内容对应envseup.sh的choosecombo函数,主要调用choosetype,chooseproduct,choosevariant等函数,确定TARGET_PRODUCT,TARGET_BUILD_TYPE,TARGET_BUILD_VARIANT。
function choosecombo()
{
chooseproject $1
echo
choosetype $2
echo
echo
chooseproduct $3
echo
echo
choosevariant $4
#modify to display TARGET_CHIPSET and builddate dynamicly by xueguobing begin
echo
echo
choose_CHIPSET $5
#modify to display TARGET_CHIPSET and builddate dynamicly by xueguobing end
echo
echo
echo
echo
chooseMultisim $6
initbuildspec
echo
set_stuff_for_environment
printconfig
}
下面我们具体来看每个选项的内容
2.1 project choices(项目选择)
Project choices are:
1. CB03
Which would you like? [CB03] 1
实现如下:
PROJECT_CHOICES=(CB03 C6000)
function chooseproject()
{
T=$(gettop) #获取Android源码根目录
echo "Project choices are:"
local index=1
local v
for v in ${PROJECT_CHOICES[@]}
do
# The product name is the name of the directory containing
# the makefile we found, above.
echo " $index. $v" #比如显示1.CB03
index=$(($index+1))
done
local default_value=CB03
local ANSWER
export SIMCOM_PROJECT= #导出环境变量
while [ -z "$SIMCOM_PROJECT" ]
do
echo -n "Which would you like? [$default_value] "
if [ -z "$1" ] ; then
read ANSWER
else
echo $1
ANSWER=$1
fi
if [ -z "$ANSWER" ] ; then
export SIMCOM_PROJECT=$default_value
elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
if [ "$ANSWER" -le "${#PROJECT_CHOICES[@]}" ] ; then
exportSIMCOM_PROJECT=${PROJECT_CHOICES[$(($ANSWER-1))]}
fi
else
if check_project $ANSWER
then
export SIMCOM_PROJECT=$ANSWER
else
echo "** Not a validproject: $ANSWER"
fi
fi
if [ -n "$1" ] ; then
break
fi
done
}
这里导出了SIMCOM_PROJECT变量的值,比如C6000
加入我们要增加另个工程,比如C6000,要修改PROJECT_CHOICES的值,
修改前:
PROJECT_CHOICES=(CB03)
修改后:
PROJECT_CHOICES=(CB03 C6000)
中间不能用逗号。
基于上面的修改,所有项选择之后输出
read(): can't openbuild/buildplus/namespace/names.ini for read: 没有那个文件或目录 atbuild/buildplus/tool/qrdplus_target_gen.pl line 98.
target build Env generate failed, yourshould abort continuous make procedure!
此错误信息是initbuildspec()输出的
function initbuildspec()
{
local -a GEN_QRDPLUS_ENV_RET
GEN_QRDPLUS_ENV_PL=build/buildplus/tool/qrdplus_target_gen.pl
#modify by lzq default mode is ct
GEN_QRDPLUS_ENV_RET=(`perl $GEN_QRDPLUS_ENV_PL $SIMCOM_PROJECT`)
if [ "$GEN_QRDPLUS_ENV_RET" != "GEN_SUCCESS" ] ;then
echo "target build Env generate failed, your should abortcontinuous make procedure!"
fi
}
这里会找build\buildplus\namespace\目录下是否有names_ $(SIMCOM_PROJECT).ini的文件。所以需要在此目录下增加names_C6000.ini文件才可以编译通过。
2.2 build type选择
Build type choices are:
1. release
2. debug
Which would you like? [1] 1
实现如下:
function choosetype()
{
echo "Build type choices are:"
echo " 1. release"
echo " 2. debug"
echo
local DEFAULT_NUM DEFAULT_VALUE
DEFAULT_NUM=1
DEFAULT_VALUE=release
export TARGET_BUILD_TYPE=
local ANSWER
while [ -z $TARGET_BUILD_TYPE ]
do
echo -n "Which would you like? ["$DEFAULT_NUM"] "
if [ -z "$1" ] ; then
read ANSWER
else
echo $1
ANSWER=$1
fi
case $ANSWER in
"")
export TARGET_BUILD_TYPE=$DEFAULT_VALUE
;;
1)
export TARGET_BUILD_TYPE=release
;;
release)
export TARGET_BUILD_TYPE=release
;;
2)
export TARGET_BUILD_TYPE=debug
;;
debug)
export TARGET_BUILD_TYPE=debug
;;
*)
echo
echo "I didn't understand your response. Please try again."
echo
;;
esac
if [ -n "$1" ] ; then
break
fi
done
set_stuff_for_environment # 设置环境变量
}
这里导出环境变量TARGET_BUILD_TYPE,其值为release或是debug,调用set_stuff_for_environment()来设置环境变量,如下:
function set_stuff_for_environment()
{
settitle
set_java_home
setpaths
set_sequence_number
export ANDROID_BUILD_TOP=$(gettop)
#With this environment variable new GCC can apply colors to warnings/errors
exportGCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
}
2.3 product choices(产品选择)
Product choices are:
1. msm8909
Which product would you like? [msm8909] 1
实现如下:
#
# This function isn't really right: It chooses a TARGET_PRODUCT
# based on the list of boards. Usually, that gets you something
# that kinda works with a generic product,but really, you should
# pick a product by name.
#
function chooseproduct()
{
# Find the list of all products by lookingfor all AndroidProducts.mk files under the
# device/, vendor/ andbuild/target/product/ directories and look for the format
# LOCAL_DIR/and extract the na

