36 lines
1.7 KiB
Bash
Executable File
36 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Native macOS build and app bundle. No Docker, mirror configuration, or tests.
|
|
set -eu
|
|
# 此入口只能在 macOS 使用;构建授权由调用方确认,脚本不自动执行测试或部署。
|
|
if [ "$(uname -s)" != Darwin ]; then
|
|
echo "Build this app bundle on macOS." >&2
|
|
exit 1
|
|
fi
|
|
cd "$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
|
|
# 锁定依赖并生成 release 可执行文件;附加参数原样交给 Cargo。
|
|
cargo build --release --locked "$@"
|
|
version=$(awk -F '"' '$1 ~ /^version[[:space:]]*=/ { print $2; exit }' Cargo.toml)
|
|
test -n "$version"
|
|
bundle="$(pwd)/target/release/Tessera.app"
|
|
mkdir -p "$bundle/Contents/MacOS"
|
|
# 先写临时文件再重命名,避免复制途中将半个二进制留作 bundle 的主程序。
|
|
cp target/release/tessera "$bundle/Contents/MacOS/tessera.new"
|
|
mv -f "$bundle/Contents/MacOS/tessera.new" "$bundle/Contents/MacOS/tessera"
|
|
# 生成最小 macOS bundle 元数据;应用名、入口与高分辨率标志供系统启动/显示使用。
|
|
cat > "$bundle/Contents/Info.plist.new" <<PLIST
|
|
<?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>CFBundleIdentifier</key><string>com.entroia.tessera</string>
|
|
<key>CFBundleName</key><string>Tessera</string>
|
|
<key>CFBundleDisplayName</key><string>Tessera</string>
|
|
<key>CFBundleExecutable</key><string>tessera</string>
|
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
<key>CFBundleShortVersionString</key><string>$version</string>
|
|
<key>CFBundleVersion</key><string>$version</string>
|
|
<key>NSHighResolutionCapable</key><true/>
|
|
</dict></plist>
|
|
PLIST
|
|
mv -f "$bundle/Contents/Info.plist.new" "$bundle/Contents/Info.plist"
|
|
printf '%s\n' "$bundle"
|