-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathbuild_macos_app.sh
More file actions
executable file
·56 lines (46 loc) · 1.62 KB
/
build_macos_app.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/zsh
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$ROOT_DIR/build/macos"
ICONSET_DIR="$BUILD_DIR/Mouser.iconset"
COMMITTED_ICON="$ROOT_DIR/images/AppIcon.icns"
GENERATED_ICON="$BUILD_DIR/Mouser.icns"
SOURCE_ICON="$ROOT_DIR/images/logo_icon.png"
TARGET_ARCH="${PYINSTALLER_TARGET_ARCH:-}"
export PYINSTALLER_CONFIG_DIR="$BUILD_DIR/pyinstaller"
if [[ "$(uname -s)" != "Darwin" ]]; then
echo "This build script must be run on macOS."
exit 1
fi
mkdir -p "$BUILD_DIR"
if [[ -f "$COMMITTED_ICON" ]]; then
echo "Using committed macOS app icon: $COMMITTED_ICON"
else
rm -rf "$ICONSET_DIR"
mkdir -p "$ICONSET_DIR"
for size in 16 32 128 256 512; do
sips -z "$size" "$size" "$SOURCE_ICON" --out "$ICONSET_DIR/icon_${size}x${size}.png" >/dev/null
double_size=$((size * 2))
sips -z "$double_size" "$double_size" "$SOURCE_ICON" --out "$ICONSET_DIR/icon_${size}x${size}@2x.png" >/dev/null
done
if ! iconutil -c icns "$ICONSET_DIR" -o "$GENERATED_ICON"; then
echo "warning: iconutil failed, continuing without a custom .icns icon"
rm -f "$GENERATED_ICON"
fi
fi
if [[ -n "$TARGET_ARCH" ]]; then
case "$TARGET_ARCH" in
arm64|x86_64|universal2) ;;
*)
echo "Unsupported PYINSTALLER_TARGET_ARCH: $TARGET_ARCH"
echo "Expected one of: arm64, x86_64, universal2"
exit 1
;;
esac
echo "Building macOS app for target architecture: $TARGET_ARCH"
fi
python3 -m PyInstaller "$ROOT_DIR/Mouser-mac.spec" --noconfirm
if command -v codesign >/dev/null 2>&1; then
codesign --force --deep --sign - "$ROOT_DIR/dist/Mouser.app"
fi
echo "Build complete: $ROOT_DIR/dist/Mouser.app"