-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (128 loc) · 5.21 KB
/
Makefile
File metadata and controls
142 lines (128 loc) · 5.21 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
-include .env
APP_NAME ?= Wispah Dev
DISPLAY_NAME ?= Wispah Flow Dev
BUNDLE_ID ?= com.idanyekutiel.wispah.dev
BUILD_DIR = build
APP_BUNDLE = $(BUILD_DIR)/$(APP_NAME).app
CODESIGN_IDENTITY ?= Wispah Dev
DEV_CODESIGN_IDENTITY ?= -
CONTENTS = $(APP_BUNDLE)/Contents
MACOS_DIR = $(CONTENTS)/MacOS
SOURCES = $(shell find Sources -name '*.swift')
RESOURCES = $(CONTENTS)/Resources
ARCH ?= $(shell uname -m)
ICON_SOURCE = Resources/AppIcon-Source.png
ICON_ICNS = Resources/AppIcon.icns
ADAPTER_DIR = Resources/MediaRemoteAdapter
.PHONY: all clean run dev dev-run watch icon dmg codesign-dmg notarize
all: $(MACOS_DIR)/$(APP_NAME)
$(MACOS_DIR)/$(APP_NAME): $(SOURCES) Info.plist $(ICON_ICNS)
@mkdir -p "$(MACOS_DIR)" "$(RESOURCES)"
ifeq ($(ARCH),universal)
swiftc \
-parse-as-library \
-o "$(MACOS_DIR)/$(APP_NAME)-arm64" \
-sdk $(shell xcrun --show-sdk-path) \
-target arm64-apple-macosx13.0 \
$(SOURCES)
swiftc \
-parse-as-library \
-o "$(MACOS_DIR)/$(APP_NAME)-x86_64" \
-sdk $(shell xcrun --show-sdk-path) \
-target x86_64-apple-macosx13.0 \
$(SOURCES)
lipo -create -output "$(MACOS_DIR)/$(APP_NAME)" \
"$(MACOS_DIR)/$(APP_NAME)-arm64" \
"$(MACOS_DIR)/$(APP_NAME)-x86_64"
@rm "$(MACOS_DIR)/$(APP_NAME)-arm64" "$(MACOS_DIR)/$(APP_NAME)-x86_64"
else
swiftc \
-parse-as-library \
-o "$(MACOS_DIR)/$(APP_NAME)" \
-sdk $(shell xcrun --show-sdk-path) \
-target $(ARCH)-apple-macosx13.0 \
$(SOURCES)
endif
@cp Info.plist "$(CONTENTS)/"
@plutil -replace CFBundleName -string "$(APP_NAME)" "$(CONTENTS)/Info.plist"
@plutil -replace CFBundleDisplayName -string "$(DISPLAY_NAME)" "$(CONTENTS)/Info.plist"
@plutil -replace CFBundleExecutable -string "$(APP_NAME)" "$(CONTENTS)/Info.plist"
@plutil -replace CFBundleIdentifier -string "$(BUNDLE_ID)" "$(CONTENTS)/Info.plist"
@cp $(ICON_ICNS) "$(RESOURCES)/"
@cp -R "$(ADAPTER_DIR)/MediaRemoteAdapter.framework" "$(RESOURCES)/"
@cp "$(ADAPTER_DIR)/mediaremote-adapter.pl" "$(RESOURCES)/"
@codesign --force --timestamp --options runtime --sign "$(CODESIGN_IDENTITY)" "$(RESOURCES)/MediaRemoteAdapter.framework"
@codesign --force --timestamp --options runtime --sign "$(CODESIGN_IDENTITY)" --entitlements Wispah.entitlements "$(APP_BUNDLE)"
@echo "Built $(APP_BUNDLE)"
icon: $(ICON_ICNS)
$(ICON_ICNS): $(ICON_SOURCE)
@mkdir -p $(BUILD_DIR)/AppIcon.iconset
@sips -z 16 16 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_16x16.png > /dev/null
@sips -z 32 32 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_16x16@2x.png > /dev/null
@sips -z 32 32 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_32x32.png > /dev/null
@sips -z 64 64 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_32x32@2x.png > /dev/null
@sips -z 128 128 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_128x128.png > /dev/null
@sips -z 256 256 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_128x128@2x.png > /dev/null
@sips -z 256 256 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_256x256.png > /dev/null
@sips -z 512 512 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_256x256@2x.png > /dev/null
@sips -z 512 512 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_512x512.png > /dev/null
@sips -z 1024 1024 $< --out $(BUILD_DIR)/AppIcon.iconset/icon_512x512@2x.png > /dev/null
@iconutil -c icns -o $@ $(BUILD_DIR)/AppIcon.iconset
@rm -rf $(BUILD_DIR)/AppIcon.iconset
@echo "Generated $@"
dmg: all
@rm -f $(BUILD_DIR)/$(APP_NAME).dmg
@echo "Creating DMG..."
@create-dmg \
--volname "$(APP_NAME)" \
--volicon "$(ICON_ICNS)" \
--window-pos 200 120 \
--window-size 660 400 \
--icon-size 128 \
--icon "$(APP_NAME).app" 180 170 \
--hide-extension "$(APP_NAME).app" \
--app-drop-link 480 170 \
--no-internet-enable \
$(BUILD_DIR)/$(APP_NAME).dmg \
$(APP_BUNDLE)
@echo "Created $(BUILD_DIR)/$(APP_NAME).dmg"
codesign-dmg: dmg
codesign --force --timestamp --sign "$(CODESIGN_IDENTITY)" $(BUILD_DIR)/$(APP_NAME).dmg
notarize:
xcrun notarytool submit $(BUILD_DIR)/$(APP_NAME).dmg \
--keychain-profile "$(NOTARIZE_PROFILE)" --wait
xcrun stapler staple $(BUILD_DIR)/$(APP_NAME).dmg
dev: $(SOURCES) Info.plist $(ICON_ICNS)
@mkdir -p "$(MACOS_DIR)" "$(RESOURCES)"
swiftc \
-parse-as-library \
-o "$(MACOS_DIR)/$(APP_NAME)" \
-sdk $(shell xcrun --show-sdk-path) \
-target $(ARCH)-apple-macosx13.0 \
$(SOURCES)
@cp Info.plist "$(CONTENTS)/"
@plutil -replace CFBundleName -string "$(APP_NAME)" "$(CONTENTS)/Info.plist"
@plutil -replace CFBundleDisplayName -string "$(DISPLAY_NAME)" "$(CONTENTS)/Info.plist"
@plutil -replace CFBundleExecutable -string "$(APP_NAME)" "$(CONTENTS)/Info.plist"
@plutil -replace CFBundleIdentifier -string "$(BUNDLE_ID)" "$(CONTENTS)/Info.plist"
@cp $(ICON_ICNS) "$(RESOURCES)/"
@cp -R "$(ADAPTER_DIR)/MediaRemoteAdapter.framework" "$(RESOURCES)/"
@cp "$(ADAPTER_DIR)/mediaremote-adapter.pl" "$(RESOURCES)/"
@codesign --force --sign "$(DEV_CODESIGN_IDENTITY)" "$(APP_BUNDLE)"
@echo "Dev build ready: $(APP_BUNDLE)"
dev-run: dev
@pkill -f "$(APP_NAME)" 2>/dev/null || true
@sleep 0.5
@open "$(APP_BUNDLE)"
watch:
@$(MAKE) dev-run
@echo "Watching Sources/ for changes... (Ctrl+C to stop)"
@fswatch -o Sources/ | while read; do \
echo ""; \
echo "=== Change detected, rebuilding... ==="; \
$(MAKE) dev-run && echo "=== Restarted ===" || echo "=== Build failed ==="; \
done
clean:
rm -rf $(BUILD_DIR)
run: all
open "$(APP_BUNDLE)"