Keep the signing identity in the Makefile rather than in shell config. A Mac without the certificate fails at signing, before the running mxd is stopped. Override with SIGN_ID=- for ad-hoc signing. Assisted-by: Claude Sonnet 5.5 Signed-off-by: Yigit BALABAN <balaban@yigid.dev>
51 lines
1.8 KiB
Makefile
51 lines
1.8 KiB
Makefile
SIGN_ID ?= mxd
|
|
ICTOOL ?= /Applications/Icon Composer.app/Contents/Executables/ictool
|
|
LABEL = dev.yigid.mxd
|
|
BUILD_DIR = build
|
|
BUNDLE = $(BUILD_DIR)/mxd.app
|
|
ICONSET = $(BUILD_DIR)/mxd.iconset
|
|
INSTALLED_BUNDLE = $(HOME)/Applications/mxd.app
|
|
LAUNCH_AGENT = $(HOME)/Library/LaunchAgents/$(LABEL).plist
|
|
|
|
.PHONY: app icon install uninstall clean
|
|
|
|
app:
|
|
mkdir -p $(BUILD_DIR)
|
|
swiftc -O -swift-version 5 mxd.swift -o $(BUILD_DIR)/mxd
|
|
rm -rf $(BUNDLE)
|
|
mkdir -p $(BUNDLE)/Contents/MacOS $(BUNDLE)/Contents/Resources
|
|
cp Info.plist $(BUNDLE)/Contents/Info.plist
|
|
cp $(BUILD_DIR)/mxd $(BUNDLE)/Contents/MacOS/mxd
|
|
cp mxd.icns $(BUNDLE)/Contents/Resources/mxd.icns
|
|
codesign --force --sign "$(SIGN_ID)" --identifier $(LABEL) $(BUNDLE)
|
|
|
|
icon:
|
|
rm -rf $(ICONSET)
|
|
mkdir -p $(ICONSET)
|
|
for base in 16 32 128 256 512; do \
|
|
for scale in 1 2; do \
|
|
canvas=$$((base * scale)); \
|
|
tile=$$(( (canvas * 824 + 512) / 1024 )); \
|
|
if [ $$scale -eq 1 ]; then name=icon_$${base}x$${base}.png; else name=icon_$${base}x$${base}@2x.png; fi; \
|
|
"$(ICTOOL)" mxd.icon --export-image --output-file $(ICONSET)/$$name --platform macOS --rendition Default --width $$tile --height $$tile --scale 1 > /dev/null || exit 1; \
|
|
sips --padToHeightWidth $$canvas $$canvas $(ICONSET)/$$name > /dev/null || exit 1; \
|
|
done; \
|
|
done
|
|
iconutil --convert icns --output mxd.icns $(ICONSET)
|
|
|
|
install: app
|
|
-launchctl bootout gui/$$(id -u)/$(LABEL)
|
|
mkdir -p $(HOME)/Applications $(HOME)/Library/LaunchAgents $(HOME)/Library/Logs
|
|
rm -rf $(INSTALLED_BUNDLE)
|
|
ditto $(BUNDLE) $(INSTALLED_BUNDLE)
|
|
sed "s|__HOME__|$(HOME)|g" $(LABEL).plist > $(LAUNCH_AGENT)
|
|
launchctl bootstrap gui/$$(id -u) $(LAUNCH_AGENT)
|
|
|
|
uninstall:
|
|
-launchctl bootout gui/$$(id -u)/$(LABEL)
|
|
rm -rf $(INSTALLED_BUNDLE)
|
|
rm -f $(LAUNCH_AGENT)
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|