|
| 1 | +#!/usr/bin/env bash |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-only |
| 3 | + |
| 4 | +set -euo pipefail |
| 5 | + |
| 6 | +target="${1:?usage: scripts/bundle-mac <target-triple>}" |
| 7 | + |
| 8 | +case "${target}" in |
| 9 | + aarch64-*|arm64-*) arch="aarch64" ;; |
| 10 | + x86_64-*) arch="x86_64" ;; |
| 11 | + *) printf 'unsupported target: %s\n' "${target}" >&2; exit 1 ;; |
| 12 | +esac |
| 13 | + |
| 14 | +rustup target add "${target}" 2>/dev/null || true |
| 15 | +cargo build --release --target "${target}" |
| 16 | + |
| 17 | +binary="target/${target}/release/beacon" |
| 18 | +[[ -f "${binary}" ]] || { printf 'binary not found: %s\n' "${binary}" >&2; exit 1; } |
| 19 | +strip "${binary}" |
| 20 | + |
| 21 | +app_dir="target/dist/BEACON.app" |
| 22 | +rm -rf "target/dist" |
| 23 | +mkdir -p "${app_dir}/Contents/MacOS" "${app_dir}/Contents/Resources" |
| 24 | + |
| 25 | +cp "${binary}" "${app_dir}/Contents/MacOS/beacon" |
| 26 | +chmod +x "${app_dir}/Contents/MacOS/beacon" |
| 27 | +cp assets/fonts "${app_dir}/Contents/Resources/" -R |
| 28 | +cp assets/icons/Beacon.icns "${app_dir}/Contents/Resources/Beacon.icns" |
| 29 | + |
| 30 | +cat > "${app_dir}/Contents/Info.plist" <<'PLIST' |
| 31 | +<?xml version="1.0" encoding="UTF-8"?> |
| 32 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 33 | +<plist version="1.0"> |
| 34 | + <dict> |
| 35 | + <key>CFBundleExecutable</key> |
| 36 | + <string>beacon</string> |
| 37 | + <key>CFBundleIdentifier</key> |
| 38 | + <string>dev.beacon.app</string> |
| 39 | + <key>CFBundleName</key> |
| 40 | + <string>BEACON</string> |
| 41 | + <key>CFBundleDisplayName</key> |
| 42 | + <string>BEACON</string> |
| 43 | + <key>CFBundleIconFile</key> |
| 44 | + <string>Beacon</string> |
| 45 | + <key>CFBundleDocumentTypes</key> |
| 46 | + <array> |
| 47 | + <dict> |
| 48 | + <key>CFBundleTypeName</key> |
| 49 | + <string>Intel HEX Firmware</string> |
| 50 | + <key>CFBundleTypeRole</key> |
| 51 | + <string>Viewer</string> |
| 52 | + <key>CFBundleTypeExtensions</key> |
| 53 | + <array> |
| 54 | + <string>hex</string> |
| 55 | + </array> |
| 56 | + <key>LSHandlerRank</key> |
| 57 | + <string>Alternate</string> |
| 58 | + </dict> |
| 59 | + </array> |
| 60 | + <key>CFBundlePackageType</key> |
| 61 | + <string>APPL</string> |
| 62 | + <key>CFBundleVersion</key> |
| 63 | + <string>0.1.0</string> |
| 64 | + <key>CFBundleShortVersionString</key> |
| 65 | + <string>0.1.0</string> |
| 66 | + <key>LSMinimumSystemVersion</key> |
| 67 | + <string>14.0</string> |
| 68 | + <key>NSHighResolutionCapable</key> |
| 69 | + <true/> |
| 70 | + </dict> |
| 71 | +</plist> |
| 72 | +PLIST |
| 73 | + |
| 74 | +mkdir -p target/dist |
| 75 | +hdiutil create -volname BEACON -srcfolder "${app_dir}" -ov -format UDZO \ |
| 76 | + "target/dist/BEACON-macos-${arch}.dmg" |
| 77 | + |
| 78 | +printf 'created target/dist/BEACON-macos-%s.dmg\n' "${arch}" |
0 commit comments