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

5
.gitignore vendored
View file

@ -10,8 +10,9 @@ android/keystore.properties
.externalNativeBuild
.cxx
*.so
# Added by cargo
/target
/.cargo/
/app/src/main/jniLibs
/macos/Grim.app/Contents/MacOS/grim-bin
/macos/cert.pem
.intentionally-empty-file.o

View file

@ -28,7 +28,7 @@ Install Android SDK / NDK / Platform Tools for your OS according to this [FAQ](h
#### Build the project
Run Android emulator or connect a real device. Command `adb devices` should show at least one device.
In the root of the repo run `./build_run_android.sh release arch`, where is `arch` is `v7` or `v8` based on device CPU architecture.
In the root of the repo run `./scripts/build_run_android.sh debug|release v7|v8`, where is `v7`, `v8` - device CPU architecture.
## License

View file

@ -1,18 +0,0 @@
#!/bin/bash
case $1 in
debug|release)
;;
*)
echo "Usage: build_and_run.sh [type] where is type is 'debug' or 'release'" >&2
exit 1
esac
type=$1
[[ ${type} == "release" ]] && release_param+=(--release)
cargo build ${release_param[@]} --target x86_64-unknown-linux-gnu
if [ $? -eq 0 ]
then
./target/x86_64-unknown-linux-gnu/${type}/grim
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Grim</string>
<key>CFBundleExecutable</key>
<string>grim-bin</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>mw.grin.macos</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Grim</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.finance</string>
<key>NSHumanReadableCopyright</key>
<string>2024</string>
</dict>
</plist>

Binary file not shown.

View file

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Resources/AppIcon.icns</key>
<data>
F0XBdu5xI+eXrj78HQf2Qr9SKio=
</data>
</dict>
<key>files2</key>
<dict>
<key>Resources/AppIcon.icns</key>
<dict>
<key>hash2</key>
<data>
ZjAn1LaNzSeTeUtKbWKWE7W2ELzhYyrHjKYOXUkQvcI=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>

25
scripts/build_run.sh Executable file
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

View file

@ -1,6 +1,6 @@
#!/bin/bash
usage="Usage: build_and_run.sh [type] [platform]\n - type: debug, release\n - platform: v7, v8"
usage="Usage: build_run_android.sh [type] [platform]\n - type: 'debug', 'release'\n - platform: 'v7', 'v8'"
case $1 in
debug|release)
;;
@ -17,6 +17,11 @@ case $2 in
exit 1
esac
# Setup build directory
BASEDIR=$(cd $(dirname $0) && pwd)
cd ${BASEDIR}
cd ..
# Setup release argument
type=$1
[[ ${type} == "release" ]] && release_param+=(--release)
@ -33,9 +38,11 @@ type=$1
[[ $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}
@ -43,7 +50,6 @@ then
./gradlew clean
# ./gradlew assembleRelease
./gradlew build
# Install on several devices
for SERIAL in $(adb devices | grep -v List | cut -f 1);
do
# adb -s $SERIAL install app/build/outputs/apk/release/app-release.apk

43
scripts/release_macos.sh Executable file
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