Deploy.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #!/bin/sh
  2. #定义当前工作空间
  3. BDFACE_WORKSPACE_DIR=`pwd`
  4. BDFACE_WORKSPACE="${BDFACE_WORKSPACE_DIR}"
  5. BDFACE_WORKSPACE_OUTPUT="${BDFACE_WORKSPACE_DIR}/output"
  6. workpath=$(cd `dirname $0`; pwd)
  7. outputpath=$workpath"/output"
  8. outputsdklibspath=$outputpath"/libs"
  9. outputsdkassetpath=$outputpath"/assets"
  10. outputsdkdemopath=$outputpath"/demo"
  11. outputsdkapkpath=$outputpath"/apk"
  12. function BDFaceSubmodule
  13. {
  14. # submodule update
  15. git submodule update --init --recursive
  16. }
  17. function BDFaceConfig
  18. {
  19. # submodule update
  20. BDFaceSubmodule
  21. # config agile compile
  22. ANDROID_SDK_HOME=/home/scmtools/buildkit/android-sdk
  23. if [ -d "$ANDROID_SDK_HOME" ]; then
  24. echo "ANDROID_SDK_HOME exist,so current is aigile"
  25. JAVA_HOME=/home/scmtools/buildkit/jdk-1.8u92
  26. ANDROID_NDK_HOME=/home/scmtools/buildkit/android-ndk-r12b
  27. JAVA_GRADLE=/home/scmtools/buildkit/gradle/gradle-2.4/bin
  28. PATH=$JAVA_GRADLE:$ANDROID_SDK_HOME:$JAVA_HOME:$ANDROID_NDK_HOME:$PATH
  29. fi
  30. clear
  31. date
  32. }
  33. # clean old products
  34. function BDFaceCleanOldProducts()
  35. {
  36. echo 1.------- create dir -------
  37. rm -rf $outputpath
  38. mkdir $outputpath
  39. echo $outputpath
  40. rm -rf $outputsdklibspath
  41. mkdir $outputsdklibspath
  42. echo $outputsdklibspath
  43. rm -rf $outputsdkassetpath
  44. mkdir $outputsdkassetpath
  45. echo $outputsdkassetpath
  46. rm -rf $outputsdkdemopath
  47. mkdir $outputsdkdemopath
  48. echo $outputsdkdemopath
  49. rm -rf $outputsdkapkpath
  50. mkdir $outputsdkapkpath
  51. echo $outputsdkapkpath
  52. # output最终输出产物路径
  53. # rm -rf "${BDFACE_WORKSPACE_OUTPUT}"
  54. # mkdir -p "${BDFACE_WORKSPACE_OUTPUT}"
  55. echo ---------------------------------------------------------------
  56. }
  57. function BDFaceBuildProduts()
  58. {
  59. echo 2 ------- begin build -------
  60. echo "${BDFACE_WORKSPACE}"
  61. cd "${BDFACE_WORKSPACE}"
  62. chmod +x $workpath"/gradlew"
  63. echo ------- build clean-------
  64. ./gradlew clean
  65. echo ------- build assembleRelease-------
  66. ./gradlew assembleRelease
  67. echo ---------------------------------------------------------------
  68. }
  69. function BDFaceCopyProducts()
  70. {
  71. echo 3 ------- copy assets -------
  72. sdkassetpath=$workpath"/faceplatform/src/main/assets/*"
  73. cp -rf $sdkassetpath $outputsdkassetpath
  74. echo ---------------------------------------------------------------
  75. echo 4.1 ------- copy FaceSDK lib -------
  76. facelibrarysopath=$workpath"/faceplatform-ui/build/intermediates/library_and_local_jars_jni/release/*"
  77. facelibraryjarspath=$workpath"/faceplatform/build/intermediates/packaged-classes/release/libs/*"
  78. facelibraryclassspath=$workpath"/faceplatform/build/intermediates/packaged-classes/release/classes.jar"
  79. ls $workpath"/faceplatform-ui/build/intermediates/bundles/library_and_local_jars_jni/release/armeabi-v7a/"
  80. cp -rf $facelibrarysopath $outputsdklibspath
  81. echo ====after copy==
  82. ls $outputsdklibspath"/armeabi-v7a/"
  83. cp -rf $facelibraryjarspath $outputsdklibspath
  84. cp -f $facelibraryclassspath $outputsdklibspath"/FaceSDK.jar"
  85. echo ---------------------------------------------------------------
  86. echo 4.2 ------- copy demo -------
  87. #demoapppath=$workpath"/app"
  88. #buildgradlepath=$workpath"/build.gradle"
  89. #gradlepath=$workpath"/gradle"
  90. #gradlepropertiespath=$workpath"/gradle.properties"
  91. #gradlewpath=$workpath"/gradlew"
  92. #localpropertiespath=$workpath"/local.properties"
  93. #settingsgradlepath=$workpath"/settings.gradle"
  94. #cp -r -f $demoapppath $outputsdkdemopath
  95. #cp $buildgradlepath $outputsdkdemopath
  96. #cp -r $gradlepath $outputsdkdemopath
  97. #cp $gradlepropertiespath $outputsdkdemopath
  98. #cp $gradlewpath $outputsdkdemopath
  99. #cp $localpropertiespath $outputsdkdemopath
  100. #cp $settingsgradlepath $outputsdkdemopath
  101. echo ---------------------------------------------------------------
  102. echo 4.3 copy sdklib to demo
  103. cp -r $outputsdklibspath $outputsdkdemopath"/app/"
  104. echo
  105. echo 4.4 copy others
  106. democoverpath=$workpath
  107. cp -f $democoverpath"/settings.gradle" $outputsdkdemopath"/settings.gradle"
  108. cp -f $democoverpath"/app/build.gradle" $outputsdkdemopath"/app/build.gradle"
  109. echo ---------------------------------------------------------------
  110. }
  111. function BDFaceRunDemo()
  112. {
  113. echo 5.0 ------- create apk demo -------
  114. demoapkpath=$demoapppath"/build/outputs/apk/*"
  115. cp -rf $demoapkpath $outputsdkapkpath
  116. #删除demo中的build目录
  117. rm -r $outputsdkdemopath"/app/build/"
  118. #rm -r $outputsdkdemopath"/build/"
  119. echo ---------------------------------------------------------------
  120. }
  121. function BDFaceZipProducts()
  122. {
  123. echo 6.0 ------- to zip -------
  124. cd $outputpath
  125. time="`date +%Y%m%d%H%M%S`"
  126. zip -r FaceSDK_${time}_R.zip .
  127. # 清除多余文件
  128. rm -rf $outputsdklibspath
  129. rm -rf $outputsdkassetpath
  130. rm -rf $outputsdkdemopath
  131. rm -rf $outputsdkapkpath
  132. # copy需要zip的产物到output,如果输出产物直接到output,请去掉这个cp
  133. faceOutputAll=$outputpath"/*"
  134. #cp -rf $faceOutputAll "${BDFACE_WORKSPACE_OUTPUT}"
  135. }
  136. # start
  137. function StartBDFaceBuild()
  138. {
  139. # 0. agile config
  140. BDFaceConfig
  141. # 1. rm old products
  142. BDFaceCleanOldProducts
  143. # 2. build new products
  144. BDFaceBuildProduts
  145. # 3. copy products
  146. BDFaceCopyProducts
  147. # 4. demo
  148. BDFaceRunDemo
  149. # 5. zip products
  150. #BDFaceZipProducts
  151. }
  152. echo "\033[01;36m===Begin==="
  153. # 记录起始时间
  154. StartDate=`date +%s`
  155. # 启动
  156. StartBDFaceBuild;
  157. # 结束时间
  158. EndDate=`date +%s`;
  159. # 编译总时间
  160. _USED_TIME=$[ EndDate - StartDate ]
  161. echo "\033[01;36m *****build all times : ${_USED_TIME} s******"
  162. echo "\033[01;36m===End==="