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