--
#!/bin/bash#sela.gao#2016.10.12#History:# 1.根据每行查找出来的结果push进去手机#result:# 1:没有编译生成文件# 2:没有设置编译环境echoMsg(){ echo "$1" exit $2}source build/envsetup.sh > /dev/nullif [ $# -lt 0 ];then echoMsg "参数不对,只能输入一个参数" 4fiif [ ! -e $1 ];then echoMsg "$1 不存在,无法编译" 5filsResult=`ls $1 | grep "Android.mk"`echo "lsResult $lsResult"if [ -z $lsResult ];then echoMsg "$1下面没有mk文件,没办法编译" 6fiparam=$1processname=`echo ${param##*/}`if [ -z $processname ];then processname=`echo ${param%*/}` processname=`echo ${processname##*/}`fiecho "final:$processname"`mmm $1> mm.log`grepResult=`cat mm.log | grep Install | cut -d " " -f 2`echo "grepResult:$grepResult"if [ -z "$grepResult" ];then echoMsg "本次编译没有生成文件!!!" 1fiif [ -z "$TARGET_PRODUCT" ];then echoMsg "还没有设置编译项目" 2fiproduct=`echo ${TARGET_PRODUCT} | cut -d "_" -f 2`if [ -z "$product" ];then echoMsg "编译环境有问题" 3fiecho "TOP:${ANDROID_BUILD_TOP}"echo "PRODUCT:${TARGET_PRODUCT}"adb rootadb remountfor ONELINE in $grepResultdo filename=`echo $ONELINE | sed 's/out\/target\/product\/[a-z][0-9][0-9][0-9][0-9]\///g'` echo "filename:$filename" echo "ONELINE:$ONELINE" if [ ! -z "$ONELINE" -a ! -z "$filename" ];then pushResult=`adb push "$ONELINE" "$filename"` echo $pushResult fidoneprocessname=`echo $processname | tr '[A-Z]' '[a-z]'`echo "::::::$processname"containsPackage=`echo $1 | grep "packages"`echo $containsPackageif [ -z `echo $1 | grep "package"` ];then echoMsg "这个可能编译的是库文件,不kill进程" 7fikillphoneprocess $processname
--