forked from AndreyPavlenko/Fermata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·60 lines (51 loc) · 1.36 KB
/
build.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
#!/bin/sh
set -e
APP_ID_SFX='.dear.google.why'
DIR="$(cd "$(dirname "$0")"; pwd -P)"
DEST_DIR="$DIR/dist"
mkdir -p "$DEST_DIR"
export NO_GS=true
CLEAN='clean'
while [ "$1" != "" ]; do
case "$1" in
-nc)
unset CLEAN
;;
-a)
ARM=true
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
shift
done
if [ -z "$ANDROID_SDK_ROOT" ]; then
if [ -f "$DIR/local.properties" ]; then
ANDROID_SDK_ROOT="$(grep sdk.dir= local.properties | cut -d = -f2)"
fi
fi
if [ -z "$ANDROID_SDK_ROOT" ]; then
echo 'ANDROID_SDK_ROOT environment variable is not set'
exit 1
else
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
fi
CMAKE_PATH="$(find $ANDROID_SDK_ROOT/cmake/* -maxdepth 1 -type d -name bin | sort -V | tail -1)"
echo "CMAKE_PATH=$CMAKE_PATH"
export PATH=$CMAKE_PATH:$PATH
build_apk() {
local sfx='arm64'
local abi='arm64-v8a'
if [ "$1" = 'arm' ]; then
sfx='arm'
abi='armeabi-v7a'
fi
./gradlew $CLEAN fermata:packageAutoReleaseUniversalApk -PABI=$abi -PAPP_ID_SFX=$APP_ID_SFX
local path=$(ls ./fermata/build/outputs/apk_from_bundle/autoRelease/fermata-*.apk)
local name=${path##*/}
mv $path "$DEST_DIR/${name%auto-release-universal.apk}auto-universal-$sfx.apk"
}
[ $ARM ] && build_apk 'arm' || true
build_apk 'arm64'