Files
mxd/Makefile
T
yigid d961a1d927 Wait for launchd to release mxd before reinstalling
launchctl bootout returns while mxd is still restoring its buttons, so
an immediate bootstrap failed with "5: Input/output error". Poll for up
to 10 s until the service is gone.

Assisted-by: Claude Sonnet 5.5
Signed-off-by: Yigit BALABAN <balaban@yigid.dev>
2026-10-31 00:21:41 +03:00

52 lines
1.9 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)
@for attempt in $$(seq 50); do launchctl print gui/$$(id -u)/$(LABEL) >/dev/null 2>&1 || break; sleep 0.2; done
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)