-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (48 loc) · 1.77 KB
/
Makefile
File metadata and controls
50 lines (48 loc) · 1.77 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
APP_NAME := Stack
BUNDLE_ID := com.erazemk.Stack
APP_BUNDLE := $(APP_NAME).app
PACKAGE_DIR := src
BUILD_DIR := .build
APP_DIR := $(BUILD_DIR)/$(APP_BUNDLE)
INSTALL_DIR := $(HOME)/Applications
INSTALLED_APP := $(INSTALL_DIR)/$(APP_BUNDLE)
BUNDLE_DIR := $(PACKAGE_DIR)/Bundle
LOCALIZATION_DIR := $(PACKAGE_DIR)/Sources/Stack/en.lproj
install: build
@set -eu; \
was_running=0; \
if pgrep -x "$(APP_NAME)" >/dev/null; then \
was_running=1; \
echo "Stopping $(APP_NAME)..."; \
osascript -e 'tell application id "$(BUNDLE_ID)" to quit' >/dev/null 2>&1 || true; \
for _ in $$(seq 1 50); do \
pgrep -x "$(APP_NAME)" >/dev/null || break; \
sleep 0.1; \
done; \
if pgrep -x "$(APP_NAME)" >/dev/null; then \
killall "$(APP_NAME)" >/dev/null 2>&1 || true; \
while pgrep -x "$(APP_NAME)" >/dev/null; do sleep 0.1; done; \
fi; \
fi; \
mkdir -p "$(INSTALL_DIR)"; \
if [ -d "$(INSTALLED_APP)" ]; then \
echo "Replacing $(INSTALLED_APP)..."; \
rm -rf "$(INSTALLED_APP)"; \
fi; \
echo "Installing $(APP_BUNDLE) to $(INSTALL_DIR)..."; \
ditto "$(APP_DIR)" "$(INSTALLED_APP)"; \
if [ "$$was_running" -eq 1 ]; then \
echo "Restarting $(APP_NAME)..."; \
open "$(INSTALLED_APP)"; \
else \
echo "Installed $(APP_NAME) to $(INSTALLED_APP)"; \
fi
.PHONY: install
build:
swift build --package-path $(PACKAGE_DIR) --scratch-path $(BUILD_DIR) -c release
mkdir -p $(APP_DIR)/Contents/MacOS $(APP_DIR)/Contents/Resources $(APP_DIR)/Contents/Resources/en.lproj
cp $(BUILD_DIR)/release/$(APP_NAME) $(APP_DIR)/Contents/MacOS/$(APP_NAME)
cp $(BUNDLE_DIR)/Info.plist $(APP_DIR)/Contents/Info.plist
cp $(BUNDLE_DIR)/Resources/AppIcon.icns $(APP_DIR)/Contents/Resources/AppIcon.icns
cp $(LOCALIZATION_DIR)/Localizable.strings $(APP_DIR)/Contents/Resources/en.lproj/Localizable.strings
.PHONY: build