forked from mullvad/mullvadvpn-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-apk.sh
executable file
·91 lines (76 loc) · 2.51 KB
/
build-apk.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
#!/usr/bin/env bash
set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
PRODUCT_VERSION="$(node -p "require('$SCRIPT_DIR/gui/package.json').version" | sed -Ee 's/\.0//g')"
if [[ "${1:-""}" == "--dev-build" ]]; then
BUILD_TYPE="debug"
GRADLE_TASK="assembleDebug"
APK_SUFFIX="-debug"
CARGO_FLAGS=""
else
BUILD_TYPE="release"
GRADLE_TASK="assembleRelease"
APK_SUFFIX=""
CARGO_FLAGS="--release"
if [ ! -f "$SCRIPT_DIR/android/keystore.properties" ]; then
echo "ERROR: No keystore.properties file found" >&2
echo " Please configure the signing keys as described in the README" >&2
exit 1
fi
fi
if [[ "$BUILD_TYPE" == "debug" || "$(git describe)" != "$PRODUCT_VERSION" ]]; then
GIT_COMMIT="$(git rev-parse --short HEAD)"
PRODUCT_VERSION="${PRODUCT_VERSION}-dev-${GIT_COMMIT}"
echo "Modifying product version to $PRODUCT_VERSION"
fi
pushd "$SCRIPT_DIR/android"
./gradlew --console plain clean
mkdir -p "build/extraJni"
popd
function restore_metadata_backups() {
pushd "$SCRIPT_DIR"
./version_metadata.sh restore-backup
popd
}
trap 'restore_metadata_backups' EXIT
./version_metadata.sh inject $PRODUCT_VERSION
ARCHITECTURES="aarch64 armv7 x86_64 i686"
for ARCHITECTURE in $ARCHITECTURES; do
case "$ARCHITECTURE" in
"x86_64")
TARGET="x86_64-linux-android"
ABI="x86_64"
;;
"i686")
TARGET="i686-linux-android"
ABI="x86"
;;
"aarch64")
TARGET="aarch64-linux-android"
ABI="arm64-v8a"
;;
"armv7")
TARGET="armv7-linux-androideabi"
ABI="armeabi-v7a"
;;
esac
echo "Building mullvad-daemon for $TARGET"
source env.sh "$TARGET"
cargo build $CARGO_FLAGS --target "$TARGET" --package mullvad-jni
cp -a "$SCRIPT_DIR/dist-assets/binaries/$TARGET" "$SCRIPT_DIR/android/build/extraJni/$ABI"
cp "$SCRIPT_DIR/target/$TARGET/$BUILD_TYPE/libmullvad_jni.so" "$SCRIPT_DIR/android/build/extraJni/$ABI/"
done
cd "$SCRIPT_DIR/android"
./gradlew --console plain "$GRADLE_TASK"
mkdir -p "$SCRIPT_DIR/dist"
cp "$SCRIPT_DIR/android/build/outputs/apk/$BUILD_TYPE/android-$BUILD_TYPE.apk" \
"$SCRIPT_DIR/dist/MullvadVPN-${PRODUCT_VERSION}${APK_SUFFIX}.apk"
echo "**********************************"
echo ""
echo " The build finished successfully! "
echo " You have built:"
echo ""
echo " $PRODUCT_VERSION"
echo ""
echo "**********************************"