2024-06-19 15:40:07 +03:00
|
|
|
#!/bin/bash
|
2024-07-02 16:40:07 +03:00
|
|
|
set -e
|
2024-06-19 15:40:07 +03:00
|
|
|
|
2024-10-25 20:03:57 +03:00
|
|
|
case $1 in
|
2024-08-02 17:30:54 +03:00
|
|
|
x86_64|arm|universal)
|
2024-06-19 15:40:07 +03:00
|
|
|
;;
|
|
|
|
*)
|
2024-10-25 20:03:57 +03:00
|
|
|
echo "Usage: release_macos.sh [platform] [version]\n - platform: 'x86_64', 'arm', 'universal'" >&2
|
2024-06-19 15:40:07 +03:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
2024-09-13 14:53:22 +03:00
|
|
|
if [[ "$OSTYPE" != "darwin"* ]]; then
|
|
|
|
if [ -z ${SDKROOT+x} ]; then
|
2024-06-19 15:40:07 +03:00
|
|
|
echo "MacOS SDKROOT is not set"
|
|
|
|
exit 1
|
2024-09-13 14:53:22 +03:00
|
|
|
else
|
2024-06-19 15:40:07 +03:00
|
|
|
echo "Use MacOS SDK: ${SDKROOT}"
|
2024-09-13 14:53:22 +03:00
|
|
|
fi
|
2024-06-19 15:40:07 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup build directory
|
|
|
|
BASEDIR=$(cd $(dirname $0) && pwd)
|
|
|
|
cd ${BASEDIR}
|
|
|
|
cd ..
|
|
|
|
|
2024-07-02 16:40:07 +03:00
|
|
|
# Setup platform
|
2024-10-25 20:03:57 +03:00
|
|
|
[[ $1 == "x86_64" ]] && arch+=(x86_64-apple-darwin)
|
|
|
|
[[ $1 == "arm" ]] && arch+=(aarch64-apple-darwin)
|
2024-07-02 16:40:07 +03:00
|
|
|
|
2024-10-25 20:03:57 +03:00
|
|
|
if [[ "$OSTYPE" != "darwin"* ]]; then
|
|
|
|
# Start release build on non-MacOS with zig linker, requires zig 0.12.1
|
|
|
|
rustup target add x86_64-apple-darwin
|
|
|
|
rustup target add aarch64-apple-darwin
|
|
|
|
[[ $1 == "universal" ]]; arch+=(universal2-apple-darwin)
|
|
|
|
cargo install cargo-zigbuild
|
|
|
|
cargo zigbuild --release --target ${arch}
|
|
|
|
else
|
|
|
|
rustup target add ${arch}
|
|
|
|
if [[ $1 == "universal" ]]; then
|
|
|
|
cargo build --release --target x86_64-apple-darwin
|
|
|
|
cargo build --release --target aarch64-apple-darwin
|
|
|
|
lipo -create -output target/grim target/aarch64-apple-darwin/release/grim target/x86_64-apple-darwin/release/grim
|
|
|
|
else
|
|
|
|
cargo build --release --target ${arch}
|
|
|
|
fi
|
|
|
|
fi
|
2024-06-19 15:40:07 +03:00
|
|
|
|
2024-10-25 20:03:57 +03:00
|
|
|
rm -f .intentionally-empty-file.o
|
2024-09-13 14:56:04 +03:00
|
|
|
|
2024-08-02 00:04:37 +03:00
|
|
|
yes | cp -rf target/${arch}/release/grim macos/Grim.app/Contents/MacOS
|
2024-06-19 15:40:07 +03:00
|
|
|
|
2024-09-13 18:57:09 +03:00
|
|
|
# Sign .app resources on change:
|
2024-07-02 16:40:07 +03:00
|
|
|
#rcodesign generate-self-signed-certificate
|
|
|
|
#rcodesign sign --pem-file cert.pem macos/Grim.app
|
2024-06-19 15:40:07 +03:00
|
|
|
|
|
|
|
# Create release package
|
2024-10-25 20:03:57 +03:00
|
|
|
FILE_NAME=grim-v$2-macos-$1.zip
|
2024-06-20 13:27:14 +03:00
|
|
|
cd macos
|
2024-06-19 15:54:34 +03:00
|
|
|
zip -r ${FILE_NAME} Grim.app
|
2024-08-03 20:32:29 +03:00
|
|
|
mv ${FILE_NAME} ../target/${arch}/release
|