#!/usr/bin/env bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # Pack a linked macOS program into its app, as make/macos.mk's packing step: # the program as Contents/MacOS/NAME (NAME the app's, without .app), and # Contents/Info.plist, which tells macOS that is the program to run, the # app's identifier and title, its icon (Contents/Resources/icon.icns, baked # by make beside its DATA), the oldest macOS it runs on (cc.sh's), and that # it draws at a Retina screen's own resolution. The program's Apple silicon # half carries the ad hoc signature zig gave it, which a copy keeps. # # Usage: packApp.sh PROGRAM NAME.app IDENTIFIER TITLE set -euo pipefail if [[ $# -ne 4 ]]; then echo "usage: $0 PROGRAM NAME.app IDENTIFIER TITLE" >&2 exit 2 fi program=$1 app=$2 identifier=$3 title=$4 name=$(basename "$app" .app) minimum=$("$(dirname "$0")/cc.sh" --minimum) # The title as XML text. title=${title//&/&} title=${title///>} mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" cp -f "$program" "$app/Contents/MacOS/$name" cat > "$app/Contents/Info.plist" < CFBundleDevelopmentRegion en CFBundleDisplayName $title CFBundleExecutable $name CFBundleIconFile icon CFBundleIdentifier $identifier CFBundleInfoDictionaryVersion 6.0 CFBundleName $name CFBundlePackageType APPL LSMinimumSystemVersion $minimum NSHighResolutionCapable EOF