mac icon added

This commit is contained in:
2025-12-10 19:53:11 +01:00
parent 1e97b3cfa3
commit 5a755e9995
2 changed files with 40 additions and 1 deletions

View File

@ -13,6 +13,8 @@ VERSION="$(date +"%Y.%m.%d")"
CLEAN=0
PACKAGE_ONLY=0
PACKAGE_RUNTIME_DIR=""
APP_ICON_SRC="assets/favicon/favicon-512x512.png"
APP_ICON_ICNS="assets/favicon/AppIcon.icns"
print_usage() {
cat <<'USAGE'
@ -68,6 +70,34 @@ configure_paths() {
PACKAGE_DIR="${OUTPUT_DIR}/TetrisGame-mac"
}
generate_icns_if_needed() {
if [[ -f "$APP_ICON_ICNS" ]]; then
return
fi
if [[ ! -f "$APP_ICON_SRC" ]]; then
log WARN "Icon source PNG not found ($APP_ICON_SRC); skipping .icns generation"
return
fi
if ! command -v iconutil >/dev/null 2>&1; then
log WARN "iconutil not available; skipping .icns generation"
return
fi
log INFO "Generating AppIcon.icns from $APP_ICON_SRC ..."
tmpdir=$(mktemp -d)
iconset="$tmpdir/AppIcon.iconset"
mkdir -p "$iconset"
# Generate required sizes from 512 base; sips will downscale
for size in 16 32 64 128 256 512; do
sips -s format png "$APP_ICON_SRC" --resampleHeightWidth $size $size --out "$iconset/icon_${size}x${size}.png" >/dev/null
sips -s format png "$APP_ICON_SRC" --resampleHeightWidth $((size*2)) $((size*2)) --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$iconset" -o "$APP_ICON_ICNS" || log WARN "iconutil failed to create .icns"
rm -rf "$tmpdir"
if [[ -f "$APP_ICON_ICNS" ]]; then
log OK "Created $APP_ICON_ICNS"
fi
}
clean_previous() {
if (( CLEAN )); then
log INFO "Cleaning previous build artifacts..."
@ -296,6 +326,7 @@ main() {
log INFO "Output: $OUTPUT_DIR"
clean_previous
generate_icns_if_needed
configure_and_build
resolve_executable
prepare_package_dir