-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (111 loc) · 4.52 KB
/
Copy pathMakefile
File metadata and controls
126 lines (111 loc) · 4.52 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
# stack-nudge — local dev/build orchestration.
# Run `make` for the list of targets.
.DEFAULT_GOAL := help
# Bundle name must match what build.sh emits and install.sh installs
# (build/StackNudge.app -> ~/Applications/StackNudge.app). It used to read
# `stack-nudge.app` here, so `make reload` removed a path that didn't exist
# and then died on `cp -R build/stack-nudge.app` under `set -e` — and `make
# dev` swallowed that with `|| true`, so the watch loop silently reloaded
# nothing for the whole session.
BUILT_APP := build/StackNudge.app
APP := $(HOME)/Applications/StackNudge.app
APP_LABEL := com.stackonehq.stack-nudge
BUILD_LOG := /tmp/stack-nudge-dev.log
WATCH_DIRS := panel shared notify.sh phrases
.PHONY: help
help:
@echo "stack-nudge targets:"
@echo " make build build StackNudge.app into build/"
@echo " make install full install (build + copy + register hooks + launchd)"
@echo " make uninstall remove app, hooks, launchd agents, ~/.stack-nudge/"
@echo " make reload rebuild + replace installed app + bounce the daemon"
@echo " make dev watch sources; auto-reload on change (ctrl-c to stop)"
@echo " make test run swift test (needs full Xcode for XCTest)"
@echo " make test-notify run the notify.sh hook tests (macOS, no Xcode)"
@echo " make typecheck-tests compile-check the test sources (no Xcode needed)"
@echo " make test-without-xcode compile AND run the test sources (no Xcode needed)"
@echo " make clean remove build/ and .build/"
.PHONY: build
build:
@./build.sh
.PHONY: install
install:
@./install.sh
.PHONY: uninstall
uninstall:
@./uninstall.sh
.PHONY: clean
clean:
@rm -rf build .build
.PHONY: test
test:
@if ! xcrun --find xctest >/dev/null 2>&1; then \
echo "swift test needs XCTest, which only ships with full Xcode."; \
echo "Install Xcode and run:"; \
echo " sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"; \
exit 1; \
fi
@swift test
# Drive notify.sh against a fake panel socket under a throwaway $HOME, so the
# hook side gets covered too. macOS only; a no-op elsewhere. Needs no Xcode.
.PHONY: test-notify
test-notify:
@python3 ./scripts/test-notify-subagents.py
# Compile-check the XCTest sources without Xcode. Catches the breakage `make
# test` can't reach on a Command Line Tools-only machine — a production API
# change leaving a test call site uncompilable. Does not run assertions.
.PHONY: typecheck-tests
typecheck-tests:
@./scripts/typecheck-tests.sh
# Compile and run the XCTest sources without Xcode, against the same stand-ins.
# `make test` / CI stay the authority (real XCTest, real isolation); this is the
# fast local loop for a machine with only Command Line Tools. Optional NAME=
# filters to matching Class.method.
.PHONY: test-without-xcode
test-without-xcode:
@./scripts/run-tests-without-xcode.sh $(NAME)
# The reference extensions' own tests, the same way CI runs them. They are
# Python rather than XCTest because the extensions are — nothing in an
# extension is Swift, and a script's tests belong beside the script.
.PHONY: test-extensions
test-extensions:
@./scripts/test-extensions.sh
# One-shot dev cycle: rebuild, reinstall the app, refresh notify.sh in
# ~/.stack-nudge so hook-side changes propagate, kickstart the daemon.
# Build output goes to $(BUILD_LOG); on failure, last 20 lines tail to stderr.
.PHONY: reload
reload:
@set -e; \
printf '[%s] rebuilding... ' "$$(date +%H:%M:%S)"; \
if ! ./build.sh > $(BUILD_LOG) 2>&1; then \
printf 'FAILED\n'; \
tail -20 $(BUILD_LOG) | sed 's/^/ /'; \
exit 1; \
fi; \
rm -rf "$(APP)"; \
cp -R "$(BUILT_APP)" "$(APP)"; \
if [ -d "$$HOME/.stack-nudge" ]; then \
cp notify.sh "$$HOME/.stack-nudge/notify.sh"; \
if [ -d phrases ]; then \
rm -rf "$$HOME/.stack-nudge/phrases"; \
cp -R phrases "$$HOME/.stack-nudge/phrases"; \
fi; \
fi; \
launchctl kickstart -k "gui/$$(id -u)/$(APP_LABEL)" 2>/dev/null || true; \
printf 'reloaded\n'
# Watch loop. Polling-based (500 ms) — no fswatch / entr dependency. Uses a
# marker file + `find -newer` so it works regardless of stat flavor (BSD vs
# GNU coreutils on PATH).
WATCH_MARKER := /tmp/stack-nudge-watch.marker
.PHONY: dev
dev:
@$(MAKE) --no-print-directory reload || true
@echo "watching: $(WATCH_DIRS) — ctrl-c to stop"
@touch $(WATCH_MARKER); \
while true; do \
sleep 0.5; \
if find $(WATCH_DIRS) \( -name '*.swift' -o -name '*.sh' -o -name 'Info.plist' \) -newer $(WATCH_MARKER) -print -quit 2>/dev/null | grep -q .; then \
touch $(WATCH_MARKER); \
$(MAKE) --no-print-directory reload || true; \
fi; \
done