【shell】编译脚本
#!/bin/bash
#设置环境变量
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
echo "ANDROID_JACK_VM_ARGS=$ANDROID_JACK_VM_ARGS"
#用户授权
export USER=$(whoami)
source /home/lenovosh/.bashrc
#copy函数 拷贝编译后需要的文件
fileCopy(){
cp /home/lenovosh/work/sunflower/LINUX/android/out/target/product/$folder_name/boot.img .
cp /home/lenovosh/work/sunflower/LINUX/android/out/target/product/$folder_name/emmc_appsboot.mbn .
cp /home/lenovosh/work/sunflower/LINUX/android/out/target/product/$folder_name/splash.img .
cp /home/lenovosh/work/sunflower/LINUX/android/out/target/product/$folder_name/system.img .
cp /home/lenovosh/work/sunflower/LINUX/android/out/target/product/$folder_name/userdata.img .
cp /home/lenovosh/work/sunflower/LINUX/android/out/target/product/$folder_name/obj/KERNEL_OBJ/vmlinux .
}
#add tag
daTag(){
cd /home/lenovosh/work/sunflower/
repo forall -c 'pwd && git tag -a '$tmp1' -m '$tmp1''
(repo forall -c 'pwd && git push gerrit_lv '$tmp1'')2>&1 | tee pushtag.log
}
#上传文件到ftp 重定向
uploadFile(){
cd /home/lenovosh/work/SunFlower_Version/
lftp <<-EOF
open 10.4.64.116
user SDU lenovo
set ssl:verify-certificate no
cd SW\ release/5AR_POC_2.0/2017_7.0/
mkdir $tmp2
cd $tmp2
mirror -R -c -e /home/lenovosh/work/SunFlower_Version/$tmp2/ .
EOF
}
#生成本地文件夹 以做备份
newFolder(){
#进入sunflower版本目录
cd /home/lenovosh/work/SunFlower_Version
#生成日期文件夹
mkdir -p $tmp2
cd $tmp2
#新建文件夹
mkdir 1NDP_USER
mkdir 2Lumus_USER
mkdir 3NDP_Debug
mkdir 4Lumus_Debug
}
#判断编译成功与否
bianyiOk(){
cd /home/lenovosh/work/sunflower/LINUX/android/
result=$(cat $logname | tail -3 | grep -iE "make completed successfully")
if [ "$result" != "" ]; then
echo "build success"
cd /home/lenovosh/work/SunFlower_Version/$tmp2
cd $VersionName
#调用copy函数开始Copy
fileCopy folder_name
uploadFile
daTag
else
echo "build failed"
fi
}
#日期变量tmp
tmp=$(date +%Y%-m%-d)
#目标文件夹
tmp1="AR_POC_2.0_"${tmp}
tmp2="ARVR_SW_ReleaseNote_"${tmp}
newFolder
#进入sunflower同步项目
cd /home/lenovosh/work/sunflower/
pwd
repo sync -j16 >> /home/lenovosh/work/sunflower/LINUX/android/all_log
cd /home/lenovosh/work/sunflower/LINUX/android
#选择编译版本
#选择编译lumus
if [ "$1" == "lumus" ]; then
folder_name=msm8996
cd /home/lenovosh/work/sunflower/LINUX/android
pwd
rm -rf out
source build/envsetup.sh
lunch msm8996-user
env >> /home/lenovosh/work/sunflower/LINUX/android/env_log
(make -j4)2>&1 | tee lumusbuild.log
if [ "$?" == "0" ]; then
logname=lumusbuild.log
VersionName=2Lumus_USER
bianyiOk logname VersionName
else
echo "make LumusVersion error!!!!"
fi
else
echo "first paramtes wrong!!!"
fi
#选择编译ned+
if [ "$2" == "nedp" ]; then
folder_name=nedplus
cd /home/lenovosh/work/sunflower/LINUX/android
rm -rf out
source build/envsetup.sh
lunch nedplus-user
(make -j4)2>&1 | tee nedpbuild.log
if [ "$?" == "0" ]; then
logname=nedpbuild.log
VersionName=1NDP_USER
bianyiOk logname VersionName
else
echo "make NedPVersion error!!!!"
fi
else
echo "second paramters wrong!!!"
fi
#选择编译lumusDebug
if [ "$3" == "lumusD" ]; then
folder_name=msm8996
cd /home/lenovosh/work/sunflower/LINUX/android
rm -rf out
source build/envsetup.sh
lunch msm8996-userdebug
(make -j4)2>&1 | tee lumusDebugbuild.log
if [ "$?" == "0" ]; then
logname=lumusDebugbuild.log
VersionName=4Lumus_Debug
bianyiOk logname VersionName
else
echo "make LumusDebugVersion error!!!!"
fi
else
echo "third paramtes wrong!!!"
fi
#选择编译ned+Debug
if [ "$4" == "nedpD" ]; then
folder_name=nedplus
cd /home/lenovosh/work/sunflower/LINUX/android
rm -rf out
source build/envsetup.sh
lunch nedplus-userdebug
(make -j4)2>&1 | tee nedpDebugbuild.log
if [ "$?" == "0" ]; then
logname=nedpDebugbuild.log
VersionName=3NDP_Debug
bianyiOk logname VersionName
else
echo "make LumusVersion error!!!!"
fi
else
echo "first paramtes wrong!!!"
fi
|