build: increment on android development
This commit is contained in:
parent
d7d1c53c52
commit
7f67aa134a
1 changed files with 19 additions and 17 deletions
|
@ -20,8 +20,8 @@ if [[ $1 == "build" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup build directory
|
# Setup build directory
|
||||||
BASEDIR=$(cd $(dirname $0) && pwd)
|
BASEDIR=$(cd "$(dirname "$0")" && pwd)
|
||||||
cd ${BASEDIR}
|
cd "${BASEDIR}" || exit 1
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Install platforms and tools
|
# Install platforms and tools
|
||||||
|
@ -34,30 +34,32 @@ success=1
|
||||||
|
|
||||||
### Build native code
|
### Build native code
|
||||||
function build_lib() {
|
function build_lib() {
|
||||||
[[ $1 == "v7" ]] && arch=(armeabi-v7a)
|
[[ $1 == "v7" ]] && arch=armeabi-v7a
|
||||||
[[ $1 == "v8" ]] && arch=(arm64-v8a)
|
[[ $1 == "v8" ]] && arch=arm64-v8a
|
||||||
[[ $1 == "x86" ]] && arch=(x86_64)
|
[[ $1 == "x86" ]] && arch=x86_64
|
||||||
|
|
||||||
sed -i -e 's/"rlib"/"cdylib","rlib"/g' Cargo.toml
|
sed -i -e 's/"rlib"/"cdylib","rlib"/g' Cargo.toml
|
||||||
|
|
||||||
# Fix for https://stackoverflow.com/questions/57193895/error-use-of-undeclared-identifier-pthread-mutex-robust-cargo-build-liblmdb-s
|
# Fix for https://stackoverflow.com/questions/57193895/error-use-of-undeclared-identifier-pthread-mutex-robust-cargo-build-liblmdb-s
|
||||||
export CPPFLAGS="-DMDB_USE_ROBUST=0" && export CFLAGS="-DMDB_USE_ROBUST=0"
|
# Uncomment lines below for the 1st build:
|
||||||
cargo ndk -t ${arch} build --profile release-apk
|
#export CPPFLAGS="-DMDB_USE_ROBUST=0" && export CFLAGS="-DMDB_USE_ROBUST=0"
|
||||||
unset CPPFLAGS && unset CFLAGS
|
#cargo ndk -t ${arch} build --profile release-apk
|
||||||
cargo ndk -t ${arch} -o android/app/src/main/jniLibs build --profile release-apk
|
#unset CPPFLAGS && unset CFLAGS
|
||||||
|
cargo ndk -t "${arch}" -o android/app/src/main/jniLibs build --profile release-apk
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
success=1
|
success=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i -e 's/"cdylib","rlib"/"rlib"/g' Cargo.toml
|
sed -i -e 's/"cdylib","rlib"/"rlib"/g' Cargo.toml
|
||||||
|
rm -f Cargo.toml-e
|
||||||
}
|
}
|
||||||
|
|
||||||
### Build application
|
### Build application
|
||||||
function build_apk() {
|
function build_apk() {
|
||||||
version=$(grep -m 1 -Po 'version = "\K[^"]*' Cargo.toml)
|
version=$(grep -m 1 -Po 'version = "\K[^"]*' Cargo.toml)
|
||||||
|
|
||||||
cd android
|
cd android || exit 1
|
||||||
./gradlew clean
|
./gradlew clean
|
||||||
# Build signed apk if keystore exists
|
# Build signed apk if keystore exists
|
||||||
if [ ! -f keystore.properties ]; then
|
if [ ! -f keystore.properties ]; then
|
||||||
|
@ -72,22 +74,22 @@ function build_apk() {
|
||||||
# Launch application at all connected devices.
|
# Launch application at all connected devices.
|
||||||
for SERIAL in $(adb devices | grep -v List | cut -f 1);
|
for SERIAL in $(adb devices | grep -v List | cut -f 1);
|
||||||
do
|
do
|
||||||
adb -s $SERIAL install ${apk_path}
|
adb -s "$SERIAL" install ${apk_path}
|
||||||
sleep 1s
|
sleep 1s
|
||||||
adb -s $SERIAL shell am start -n mw.gri.android/.MainActivity;
|
adb -s "$SERIAL" shell am start -n mw.gri.android/.MainActivity;
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
# Setup release file name
|
# Setup release file name
|
||||||
name=grim-${version}-android-$1.apk
|
name=grim-${version}-android-$1.apk
|
||||||
[[ $1 == "arm" ]] && name=grim-${version}-android.apk
|
[[ $1 == "arm" ]] && name=grim-${version}-android.apk
|
||||||
rm -rf ${name}
|
rm -f "${name}"
|
||||||
mv ${apk_path} ${name}
|
mv ${apk_path} "${name}"
|
||||||
|
|
||||||
# Calculate checksum
|
# Calculate checksum
|
||||||
checksum=grim-${version}-android-$1-sha256sum.txt
|
checksum=grim-${version}-android-$1-sha256sum.txt
|
||||||
[[ $1 == "arm" ]] && checksum=grim-${version}-android-sha256sum.txt
|
[[ $1 == "arm" ]] && checksum=grim-${version}-android-sha256sum.txt
|
||||||
rm -rf ${checksum}
|
rm -f "${checksum}"
|
||||||
sha256sum ${name} > ${checksum}
|
sha256sum "${name}" > "${checksum}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
@ -96,7 +98,7 @@ function build_apk() {
|
||||||
rm -rf android/app/src/main/jniLibs/*
|
rm -rf android/app/src/main/jniLibs/*
|
||||||
|
|
||||||
if [[ $1 == "build" ]]; then
|
if [[ $1 == "build" ]]; then
|
||||||
build_lib $2
|
build_lib "$2"
|
||||||
[ $success -eq 1 ] && build_apk
|
[ $success -eq 1 ] && build_apk
|
||||||
else
|
else
|
||||||
rm -rf target/release-apk
|
rm -rf target/release-apk
|
||||||
|
|
Loading…
Reference in a new issue