-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmakefile
More file actions
147 lines (135 loc) · 5.91 KB
/
makefile
File metadata and controls
147 lines (135 loc) · 5.91 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
143
144
145
146
147
VERSION ?= 0.0.0-SNAPSHOT
CODESIGN_IDENTITY ?= Apple Development
EXPECTED_CODESIGN_AUTHORITY ?= Apple Development: zxzimeng@gmail.com (4F7GA4MB42)
DEVELOPMENT_TEAM ?= W9C2P3N7Q2
RELEASE_DIR ?= .release
RELEASE_TAG ?= v$(VERSION)
RELEASE_NOTES ?= auto
PUBLISH ?= 1
APP_INSTALL_DIR ?= /Applications
ARGS ?=
.PHONY: generate xcodeproj build build-clean run run-clean cli release install installed clean
generate:
/bin/bash -lc 'cd "$(CURDIR)" && \
printf "%s\n" "// FILE IS GENERATED BY Makefile" "public let winMuxAppVersion = \"$(VERSION)\"" > Sources/Common/versionGenerated.swift && \
git_hash="$$(git rev-parse HEAD 2>/dev/null || echo SNAPSHOT)"; \
git_short_hash="$$(git rev-parse --short HEAD 2>/dev/null || echo SNAPSHOT)"; \
printf "%s\n" "// FILE IS GENERATED BY Makefile" "public let gitHash = \"$$git_hash\"" "public let gitShortHash = \"$$git_short_hash\"" > Sources/Common/gitHashGenerated.swift'
xcodeproj:
$(MAKE) generate VERSION="$(VERSION)"
/bin/bash -lc 'cd "$(CURDIR)" && \
source ./script/setup.sh && \
export XCODEGEN_WINMUX_VERSION="$(VERSION)" && \
export XCODEGEN_WINMUX_CODE_SIGN_IDENTITY="$(CODESIGN_IDENTITY)" && \
export XCODEGEN_WINMUX_DEVELOPMENT_TEAM="$(DEVELOPMENT_TEAM)" && \
./script/install-dep.sh --xcodegen && \
./.deps/xcodegen/xcodegen'
build:
$(MAKE) generate VERSION="$(VERSION)"
/bin/bash -lc 'cd "$(CURDIR)" && \
source ./script/setup.sh && \
swift build && \
swift build --target AppBundleTests && \
rm -rf .debug && \
mkdir .debug && \
cp -r .build/debug/winmux .debug && \
cp -r .build/debug/WinMuxApp .debug'
build-clean:
/bin/bash -lc 'cd "$(CURDIR)" && rm -rf .build .debug'
$(MAKE) build VERSION="$(VERSION)"
run:
$(MAKE) build VERSION="$(VERSION)"
/bin/bash -lc 'cd "$(CURDIR)" && \
if pgrep -x yabai >/dev/null 2>&1; then echo "warning: yabai is still running and may conflict with WinMux" >&2; fi && \
if pgrep -x skhd >/dev/null 2>&1; then echo "warning: skhd is still running; its yabai shortcuts will keep firing" >&2; fi && \
config_path="$${WINMUX_CONFIG_PATH:-}"; \
if [ -n "$$config_path" ]; then \
if [ ! -f "$$config_path" ]; then \
echo "Missing WinMux config: $$config_path" >&2; \
exit 1; \
fi; \
exec ./.debug/WinMuxApp --config-path "$$config_path" $(ARGS); \
else \
exec ./.debug/WinMuxApp $(ARGS); \
fi'
run-clean:
$(MAKE) build-clean VERSION="$(VERSION)"
/bin/bash -lc 'cd "$(CURDIR)" && \
if pgrep -x yabai >/dev/null 2>&1; then echo "warning: yabai is still running and may conflict with WinMux" >&2; fi && \
if pgrep -x skhd >/dev/null 2>&1; then echo "warning: skhd is still running; its yabai shortcuts will keep firing" >&2; fi && \
config_path="$${WINMUX_CONFIG_PATH:-}"; \
if [ -n "$$config_path" ]; then \
if [ ! -f "$$config_path" ]; then \
echo "Missing WinMux config: $$config_path" >&2; \
exit 1; \
fi; \
exec ./.debug/WinMuxApp --config-path "$$config_path" $(ARGS); \
else \
exec ./.debug/WinMuxApp $(ARGS); \
fi'
cli:
$(MAKE) build VERSION="$(VERSION)"
/bin/bash -lc 'cd "$(CURDIR)" && exec ./.debug/winmux $(ARGS)'
release:
$(MAKE) xcodeproj VERSION="$(VERSION)" CODESIGN_IDENTITY="$(CODESIGN_IDENTITY)"
/bin/bash -lc 'cd "$(CURDIR)" && \
set -euo pipefail && \
source ./script/setup.sh && \
test -n "$(VERSION)" && \
app_name="WinMux"; \
release_dir="$(RELEASE_DIR)"; \
archive_path="$$release_dir/$$app_name-$(VERSION).xcarchive"; \
derived_data_path="$$release_dir/$$app_name-$(VERSION).deriveddata"; \
app_path="$$archive_path/Products/Applications/$$app_name.app"; \
zip_path="$$release_dir/$$app_name-$(VERSION).zip"; \
log_path="$$release_dir/$$app_name-$(VERSION)-xcodebuild.log"; \
rm -rf "$$archive_path" "$$zip_path" "$$derived_data_path"; \
mkdir -p "$$release_dir"; \
xcodebuild-pretty "$$log_path" \
-project WinMux.xcodeproj \
-scheme WinMux \
-configuration Release \
-archivePath "$$archive_path" \
-derivedDataPath "$$derived_data_path" \
CODE_SIGN_IDENTITY="$(CODESIGN_IDENTITY)" \
DEVELOPMENT_TEAM="$(DEVELOPMENT_TEAM)" \
CODE_SIGN_STYLE=Automatic \
archive; \
test -d "$$app_path"; \
codesign --verify --deep --strict --verbose=2 "$$app_path"; \
codesign -dv --verbose=4 "$$app_path" 2>&1 | grep -F "Authority=$(EXPECTED_CODESIGN_AUTHORITY)" >/dev/null; \
ditto -c -k --sequesterRsrc --keepParent "$$app_path" "$$zip_path"; \
if [ "$(PUBLISH)" != "1" ]; then \
echo "Skipping GitHub release publish because PUBLISH=$(PUBLISH)"; \
elif /usr/bin/which gh >/dev/null 2>&1; then \
if gh release view "$(RELEASE_TAG)" >/dev/null 2>&1; then \
gh release upload "$(RELEASE_TAG)" "$$zip_path" --clobber; \
else \
if [ "$(RELEASE_NOTES)" = "auto" ]; then \
gh release create "$(RELEASE_TAG)" "$$zip_path" --title "$$app_name $(VERSION)" --generate-notes; \
else \
gh release create "$(RELEASE_TAG)" "$$zip_path" --title "$$app_name $(VERSION)" --notes "$(RELEASE_NOTES)"; \
fi; \
fi; \
else \
echo "warning: gh is not installed; built $$zip_path but did not publish a GitHub release" >&2; \
fi'
install:
$(MAKE) release VERSION="$(VERSION)" CODESIGN_IDENTITY="$(CODESIGN_IDENTITY)" DEVELOPMENT_TEAM="$(DEVELOPMENT_TEAM)" PUBLISH=0
/bin/bash -lc 'cd "$(CURDIR)" && \
set -euo pipefail && \
app_name="WinMux"; \
release_dir="$(RELEASE_DIR)"; \
app_path="$$release_dir/$$app_name-$(VERSION).xcarchive/Products/Applications/$$app_name.app"; \
install_dir="$(APP_INSTALL_DIR)"; \
install_path="$$install_dir/$$app_name.app"; \
test -d "$$app_path"; \
mkdir -p "$$install_dir"; \
osascript -e "tell application \"$$app_name\" to quit" >/dev/null 2>&1 || true; \
rm -rf "$$install_path"; \
ditto "$$app_path" "$$install_path"; \
xattr -dr com.apple.quarantine "$$install_path" >/dev/null 2>&1 || true; \
open "$$install_path"'
installed: install
clean:
/bin/bash -lc 'cd "$(CURDIR)" && rm -rf .build .debug .deps .derived "$(RELEASE_DIR)" WinMux.xcodeproj'