Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (78 loc) · 4.84 KB
/
Copy pathMakefile
File metadata and controls
98 lines (78 loc) · 4.84 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
# Tether — common tasks. `make` builds dist/Tether.app; `make help` lists everything.
APP := dist/Tether.app
VERSION := $(shell tr -d '[:space:]' < VERSION)
ZIP := dist/Tether-$(VERSION).zip
INSTALL_DIR ?= /Applications
# `make install INSTALL_DIR=~/Applications`: the shell leaves ~ alone after =, so expand it here.
override INSTALL_DIR := $(patsubst ~%,$(HOME)%,$(INSTALL_DIR))
NOTES := release-notes/v$(VERSION).md
# SwiftPM's native build system needs no Metal compiler (see scripts/build-app.sh); asked for
# whenever the toolchain offers it. Evaluated only by the targets that build.
SWIFTPM_FLAGS = $(if $(findstring native,$(shell swift build --help 2>/dev/null)),--build-system native)
.DEFAULT_GOAL := app
.PHONY: help build test app debug run demo install install-built uninstall zip check privacy hooks notes clean version signing-identity
help: ## Show this help
@echo "Tether $(VERSION)"
@echo
@awk 'BEGIN {FS = ":.*## "} /^[a-z-]+:.*## / {printf " make %-10s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo
@echo " make same as make app"
version: ## Print the current version
@echo $(VERSION)
build: ## Compile all modules (debug)
swift build $(SWIFTPM_FLAGS)
test: ## Run the unit and integration tests (at a lower priority: the Mac stays usable)
nice -n 10 swift test $(SWIFTPM_FLAGS)
app: ## Build the release app into dist/Tether.app (default)
scripts/build-app.sh release
debug: ## Build a debug app into dist/Tether.app
scripts/build-app.sh debug
run: app ## Build the release app and open it
open $(APP)
demo: ## Open the app with synthetic demo data (your data is not used). SHOTS=1 saves screenshots
scripts/build-app.sh debug demo
@D=$$(mktemp -d -t tether-demo); T=/tmp/tether-demo-$$(id -u); \
echo "Demo files in $$D (removed when the demo quits)"; \
open -W -n "dist/Tether Demo.app" --env TETHER_DEMO="$$D" --env TETHER_SUPPORT_DIR="$$D/support" \
--env TETHER_DEFAULTS_SUITE=tether.demo --env TETHER_SSH_CONFIG="$$D/ssh_config" --env TETHER_DEMO_TMUX="$$T" \
$(if $(SHOTS),--env TETHER_DEMO_SHOTS=1) --args -AppleLanguages "(en)" -AppleLocale en_US; \
if [ -d "$$D/shots" ]; then mkdir -p dist/screenshots && cp "$$D"/shots/*.png dist/screenshots/ && echo "Screenshots in dist/screenshots"; fi; \
for s in "$$T"/tmux-*/*; do [ -S "$$s" ] && TMUX= "$$D/bin/tmux" -S "$$s" kill-server 2>/dev/null; done; \
rm -rf "$$D" "$$T"; defaults delete tether.demo >/dev/null 2>&1; true
signing-identity: ## Create a local signing certificate so macOS keeps Tether's permissions across builds
scripts/make-signing-identity.sh
install: app install-built ## Build and copy Tether.app to /Applications (INSTALL_DIR=… to change)
# The app already built in dist/ (the self-update builds first, then installs this once Tether has
# quit). The new copy is made next to the old one and swapped in: a copy that fails leaves the
# installed Tether as it was.
install-built:
@if pgrep -qf "$(INSTALL_DIR)/Tether.app/Contents/MacOS/Tether"; then echo "Quit Tether first (it may still be in the menu bar), then run make install-built."; exit 1; fi
@test -d $(APP) || { echo "Nothing built in $(APP): run make install."; exit 1; }
mkdir -p "$(INSTALL_DIR)"
rm -rf "$(INSTALL_DIR)/.Tether.app.new" "$(INSTALL_DIR)/.Tether.app.old"
ditto $(APP) "$(INSTALL_DIR)/.Tether.app.new"
if [ -d "$(INSTALL_DIR)/Tether.app" ]; then mv "$(INSTALL_DIR)/Tether.app" "$(INSTALL_DIR)/.Tether.app.old"; fi
mv "$(INSTALL_DIR)/.Tether.app.new" "$(INSTALL_DIR)/Tether.app" || { mv "$(INSTALL_DIR)/.Tether.app.old" "$(INSTALL_DIR)/Tether.app"; exit 1; }
rm -rf "$(INSTALL_DIR)/.Tether.app.old"
@echo "Installed to $(INSTALL_DIR)/Tether.app"
uninstall: ## Remove Tether.app from /Applications (settings and recordings are kept)
rm -rf "$(INSTALL_DIR)/Tether.app"
@echo "Removed. Your data is still in ~/Library/Application Support/Tether."
zip: ## Package dist/Tether-<version>.zip for a GitHub release (Apple silicon and Intel)
UNIVERSAL=1 scripts/build-app.sh release
rm -f $(ZIP)
# Keep the signed app's files and permissions, excluding resource forks, extended attributes,
# Unix owner IDs and access times from the machine that built it.
cd "$(dir $(APP))" && COPYFILE_DISABLE=1 /usr/bin/zip -qryX "$(abspath $(ZIP))" "$(notdir $(APP))"
@echo "Created $(ZIP)"
notes: ## Check that release notes exist for the current version
@test -f $(NOTES) || { echo "Missing $(NOTES) — copy release-notes/TEMPLATE.md"; exit 1; }
@echo "Found $(NOTES)"
privacy: ## Look for personal data and secrets (API keys, tokens, private keys) that must not be published
@scripts/privacy.sh
hooks: ## Run the privacy check before every commit (git pre-commit hook)
git config core.hooksPath scripts/git-hooks
@echo "Commits now run scripts/privacy.sh first."
check: privacy notes test ## Everything that must pass before a release
clean: ## Remove build products
rm -rf .build dist