-
Notifications
You must be signed in to change notification settings - Fork 0
/
android.sh
executable file
·78 lines (67 loc) · 1.74 KB
/
android.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
# #!/usr/bin/env bash
# export ANDROID_SDK_ROOT=/Users/$USER/android
export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk
export NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.4.7075529
echo "Using the following Android and NDK:"
echo $ANDROID_SDK_ROOT
echo $NDK_HOME
BUILD_MODE="release"
for i in "$@"; do
case $i in
-d | --debug)
# for a debug build
BUILD_MODE="debug"
#build the libraries
# We build using cargo apk as we need the libc++ as well
RUST_LOG=trace RUST_BACKTRACE=full cargo apk build
;;
-r | --release)
# for release build
#build the libraries
cargo apk build --$BUILD_MODE
;;
-b | --apk-build)
# APK BUILD
RUST_LOG=trace RUST_BACKTRACE=full cargo apk build
exit
;;
-s | --apk-start)
# APK RUN
RUST_LOG=trace RUST_BACKTRACE=full cargo apk run
exit
;;
-r | --apk-release)
# APK BUILD RELEASE
cargo apk build --$BUILD_MODE
exit
;;
*)
# unknown option
exit
;;
esac
done
#NOTE: Dont't forget to modify these vars to your setup
PROJ_MAIN=./android/app/src/main
LIBS_DIR=$PROJ_MAIN/jniLibs
LIB_NAME=rust_jsx_app
#prepare folders...
rm -rf $LIBS_DIR
mkdir $LIBS_DIR
mkdir $LIBS_DIR/arm64-v8a
mkdir $LIBS_DIR/armeabi-v7a
mkdir $LIBS_DIR/x86
mkdir $LIBS_DIR/x86_64
echo
#..and copy the rust library into the android studio project, ready for beeing included into the APK
cp -rf target/$BUILD_MODE/apk/lib/arm64-v8a $LIBS_DIR
cp -rf target/$BUILD_MODE/apk/lib/armeabi-v7a $LIBS_DIR
cp -rf target/$BUILD_MODE/apk/lib/x86 $LIBS_DIR
cp -rf target/$BUILD_MODE/apk/lib/x86_64 $LIBS_DIR
# Check whether the root assets folder of our main Android app has a symlink to our shared assets
pushd $PROJ_MAIN
if [ ! -d "assets" ]; then
echo "Linking assets to ../../../../assets"
ln -s ../../../../assets .
fi
popd