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-08-02 17:30:54 +03:00
|
|
|
case $2 in
|
|
|
|
x86_64|arm|universal)
|
2024-06-19 15:40:07 +03:00
|
|
|
;;
|
|
|
|
*)
|
2024-08-02 17:30:54 +03:00
|
|
|
echo "Usage: release_macos.sh [platform]\n - platform: 'x86_64', 'arm', 'universal'" >&2
|
2024-06-19 15:40:07 +03:00
|
|
|
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 ..
|
|
|
|
|
2024-07-02 16:40:07 +03:00
|
|
|
# Setup platform
|
|
|
|
rustup target add x86_64-apple-darwin
|
|
|
|
rustup target add aarch64-apple-darwin
|
|
|
|
|
|
|
|
rm -rf target/x86_64-apple-darwin
|
|
|
|
rm -rf target/aarch64-apple-darwin
|
|
|
|
|
2024-08-02 17:30:54 +03:00
|
|
|
[[ $2 == "x86_64" ]] && arch+=(x86_64-apple-darwin)
|
|
|
|
[[ $2 == "arm" ]] && arch+=(aarch64-apple-darwin)
|
|
|
|
[[ $2 == "universal" ]] && arch+=(universal2-apple-darwin)
|
2024-06-19 15:40:07 +03:00
|
|
|
|
|
|
|
# Start release build with zig linker for cross-compilation
|
2024-07-02 16:40:07 +03:00
|
|
|
# zig 0.12 required
|
|
|
|
cargo install cargo-zigbuild@0.18.4
|
2024-06-19 15:40:07 +03:00
|
|
|
cargo zigbuild --release --target ${arch}
|
2024-07-02 16:40:07 +03:00
|
|
|
rm -rf .intentionally-empty-file.o
|
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-07-02 16:40:07 +03:00
|
|
|
### Sign .app resources:
|
|
|
|
#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-08-02 17:30:54 +03:00
|
|
|
FILE_NAME=Grim-$1-macos-$2.zip
|
2024-07-02 16:40:07 +03:00
|
|
|
rm -rf target/${arch}/release/${FILE_NAME}
|
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-06-20 13:27:14 +03:00
|
|
|
mv ${FILE_NAME} ../target/${arch}/release
|