build: release package for macos

This commit is contained in:
ardocrat
2024-06-19 15:40:07 +03:00
parent 5f56042dc8
commit db09df3663
12 changed files with 259 additions and 25 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
case $1 in
debug|release)
;;
*)
echo "Usage: build_run.sh [type] where is type is 'debug' or 'release'" >&2
exit 1
esac
# Setup build directory
BASEDIR=$(cd $(dirname $0) && pwd)
cd ${BASEDIR}
cd ..
# Build application
type=$1
[[ ${type} == "release" ]] && release_param+=(--release)
cargo build ${release_param[@]}
# Start application
if [ $? -eq 0 ]
then
./target/${type}/grim
fi
+60
View File
@@ -0,0 +1,60 @@
#!/bin/bash
usage="Usage: build_run_android.sh [type] [platform]\n - type: 'debug', 'release'\n - platform: 'v7', 'v8'"
case $1 in
debug|release)
;;
*)
printf "$usage"
exit 1
esac
case $2 in
v7|v8)
;;
*)
printf "$usage"
exit 1
esac
# Setup build directory
BASEDIR=$(cd $(dirname $0) && pwd)
cd ${BASEDIR}
cd ..
# Setup release argument
type=$1
[[ ${type} == "release" ]] && release_param+=(--release)
# Setup platform argument
[[ $2 == "v7" ]] && arch+=(armeabi-v7a)
[[ $2 == "v8" ]] && arch+=(arm64-v8a)
# Setup platform path
[[ $2 == "v7" ]] && platform+=(armv7-linux-androideabi)
[[ $2 == "v8" ]] && platform+=(aarch64-linux-android)
# Install platform
[[ $2 == "v7" ]] && rustup target install armv7-linux-androideabi
[[ $2 == "v8" ]] && rustup target install aarch64-linux-android
# Build native code
export CPPFLAGS="-DMDB_USE_ROBUST=0" && export CFLAGS="-DMDB_USE_ROBUST=0" \
&& cargo ndk -t ${arch} build ${release_param[@]}
# Build Android application and launch at all connected devices
if [ $? -eq 0 ]
then
yes | mkdir -p android/app/src/main/jniLibs/${arch} && cp -f target/${platform}/${type}/libgrim.so android/app/src/main/jniLibs/${arch}
cd android
./gradlew clean
# ./gradlew assembleRelease
./gradlew build
for SERIAL in $(adb devices | grep -v List | cut -f 1);
do
# adb -s $SERIAL install app/build/outputs/apk/release/app-release.apk
adb -s $SERIAL install app/build/outputs/apk/debug/app-debug.apk
sleep 1s
adb -s $SERIAL shell am start -n mw.gri.android/.MainActivity;
done
fi
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
case $1 in
x86|arm)
;;
*)
echo "Usage: release_macos.sh [platform]\n - platform: 'x86', 'arm'" >&2
exit 1
esac
if [[ ! -v SDKROOT ]]; then
echo "MacOS SDKROOT is not set"
exit 1
elif [[ -z "SDKROOT" ]]; then
echo "MacOS SDKROOT is set to the empty string"
exit 1
else
echo "Use MacOS SDK: ${SDKROOT}"
fi
# Setup build directory
BASEDIR=$(cd $(dirname $0) && pwd)
cd ${BASEDIR}
cd ..
# Setup platform argument
[[ $1 == "x86" ]] && arch+=(x86_64-apple-darwin)
[[ $1 == "arm" ]] && arch+=(aarch64-apple-darwin)
# Start release build with zig linker for cross-compilation
cargo install cargo-zigbuild
cargo zigbuild --release --target ${arch}
rm .intentionally-empty-file.o
yes | cp -rf target/${arch}/release/grim macos/Grim.app/Contents/MacOS/grim-bin
### Sign .app before distribution:
### rcodesign generate-self-signed-certificate
### rcodesign sign --pem-file test.pem macos/Grim.app
# Create release package
FILE_NAME=Grim-0.1.0-macos-$1.zip
zip ${FILE_NAME} target/${arch}/release/grim macos/Grim.app
mv -f ${FILE_NAME} target/${arch}/release