Skip to content

Commit 4dd47c4

Browse files
committed
build app manifest dynamically
1 parent fe85f11 commit 4dd47c4

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

macos/makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ else
77
VERSION := $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
88
endif
99

10+
# Extract semantic version for Info.plist (e.g., "1.0.3" from tag "v1.0.3")
11+
SHORT_VERSION := $(shell echo $(VERSION) | grep -oE 'v?[0-9]+\.[0-9]+\.[0-9]+' || echo "0.0.0")
12+
1013
APP_NAME_VERSION = $(APP_NAME) $(VERSION)
11-
APP_EXE = $(APP_NAME)
14+
APP_MANIFEST = src/Info.plist
1215
APP_BUNDLE = $(APP_NAME).app
16+
APP_EXE = $(APP_NAME)
17+
18+
1319

1420
CC = clang++
1521
CFLAGS = -std=c++17 -Wall -mmacosx-version-min=11.0 -arch x86_64 -arch arm64 -MMD -MP -DAPPNAME_VERSION='"$(APP_NAME_VERSION)"'
@@ -60,6 +66,10 @@ $(LICENSE_HEADER): ../LICENSE
6066
$(BOOTROM_HEADER): $(BOOTROM_SOURCE)
6167
python3 ../tools/generate_bootrom_header.py $(BOOTROM_SOURCE) $(BOOTROM_HEADER)
6268

69+
# Generate Info.plist from template with version substitution
70+
$(APP_MANIFEST): $(APP_MANIFEST).in
71+
sed -e 's/@VERSION@/$(VERSION)/g' -e 's/@SHORT_VERSION@/$(SHORT_VERSION)/g' $< > $@
72+
6373
# Pattern rules for incremental compilation
6474
%.o: ../shared/%.cc $(LICENSE_HEADER) $(BOOTROM_HEADER)
6575
$(CC) $(CFLAGS) $(INCS) -c $< -o $@
@@ -88,15 +98,15 @@ release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE): $(SDL_LIB) $(OBJS)
8898
$(CC) $(CFLAGS) $(LIBS) $(INCS) $(OBJS) -o $@ $(LFLAGS)
8999

90100
# .app bundle
91-
release/$(APP_BUNDLE): release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE) $(SDL_LIB) resources/Kiwi8.icns src/Info.plist
101+
release/$(APP_BUNDLE): release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE) $(SDL_LIB) resources/Kiwi8.icns $(APP_MANIFEST)
92102
mkdir -p release/$(APP_BUNDLE)/Contents/{Resources,Frameworks}
93103

94104
# Copying the frameworks into .app bundle
95105
cp $(SDL_LIB) release/$(APP_BUNDLE)/Contents/Frameworks/libSDL2-2.0.0.dylib
96106

97107
# Moving other files into .app bundle
98108
cp resources/Kiwi8.icns release/$(APP_BUNDLE)/Contents/Resources/Kiwi8.icns
99-
cp src/Info.plist release/$(APP_BUNDLE)/Contents/Info.plist
109+
cp $(APP_MANIFEST) release/$(APP_BUNDLE)/Contents/Info.plist
100110

101111
# Set the dylib's install name to be relative to the bundle
102112
install_name_tool -id @executable_path/../Frameworks/libSDL2-2.0.0.dylib release/$(APP_BUNDLE)/Contents/Frameworks/libSDL2-2.0.0.dylib
@@ -119,6 +129,7 @@ clean:
119129
$(RM) -r debug
120130
$(RM) -r release
121131
$(RM) $(LICENSE_HEADER) $(BOOTROM_HEADER)
132+
$(RM) $(APP_MANIFEST)
122133

123134
# Removes everything including SDL installation and build artifacts (full reset)
124135
distclean: clean

macos/src/Info.plist.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleExecutable</key>
6+
<string>Kiwi8</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>net.kiwi-labs.kiwi8</string>
9+
<key>CFBundleIconFile</key>
10+
<string>Kiwi8.icns</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>1.0</string>
13+
<key>CFBundlePackageType</key>
14+
<string>APPL</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>@SHORT_VERSION@</string>
17+
<key>CFBundleVersion</key>
18+
<string>@VERSION@</string>
19+
<key>LSMinimumSystemVersion</key>
20+
<string>11.0</string>
21+
<key>NSHighResolutionCapable</key>
22+
<true/>
23+
<key>NSHumanReadableCopyright</key>
24+
<string>Copyright © 2016-2026 Kiwi Labs.</string>
25+
<key>NSSupportsAutomaticGraphicsSwitching</key>
26+
<true/>
27+
28+
</dict>
29+
</plist>

0 commit comments

Comments
 (0)