Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (55 loc) · 2.46 KB
/
Copy pathMakefile
File metadata and controls
73 lines (55 loc) · 2.46 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
APP := deck
# Install location. Defaults to ~/.local/bin since that's already on PATH on
# most macOS / Linux setups and doesn't need sudo. Override with PREFIX:
# make install PREFIX=/usr/local/bin
#
# Same convention as cathode, so both binaries land side by side.
PREFIX ?= $(HOME)/.local/bin
# Where `make demo` builds its throwaway workspace. Under /tmp because it is
# disposable: three git repositories, their worktrees and a state directory,
# none of which should end up anywhere a backup would find them.
DEMO_DIR ?= /tmp/deck-demo
.PHONY: help build run test race vet fmt tidy hooks install uninstall reinstall watch clean demo
help: ## list the targets
@grep -E '^[a-z-]+:.*?## ' $(MAKEFILE_LIST) \
| awk -F':.*?## ' '{printf " %-11s %s\n", $$1, $$2}'
build: ## compile the single binary
go build -o $(APP) .
run: build ## build then launch in the current repo
./$(APP)
test: ## run the unit and smoke tests
go test ./...
race: ## run the tests under the race detector
go test -race -timeout 300s ./...
vet: ## run go vet
go vet ./...
fmt: ## gofmt the tree
gofmt -w .
tidy: ## resolve deps + write go.sum
go mod tidy
hooks: ## install scripts/commit-msg where git will actually look for it
@dir=$$(git rev-parse --git-path hooks); \
common=$$(git rev-parse --git-common-dir)/hooks; \
mkdir -p "$$dir"; \
ln -sf "$$(pwd)/scripts/commit-msg" "$$dir/commit-msg"; \
echo "installed: $$dir/commit-msg"; \
if [ "$$dir" != "$$common" ]; then \
echo "note: core.hooksPath is shared, so this now runs for every repository."; \
echo "It exits immediately in one with no Go files."; \
fi
install: ## build and copy to $(PREFIX), creating it if needed
@mkdir -p $(PREFIX)
go build -o $(PREFIX)/$(APP) .
@echo "installed: $(PREFIX)/$(APP)"
@case ":$$PATH:" in *":$(PREFIX):"*) ;; *) \
echo "warn: $(PREFIX) is not on PATH — add it to ~/.zshrc or ~/.bashrc";; esac
reinstall: clean install ## rebuild from scratch and reinstall
demo: build ## seed a throwaway workspace to photograph Deck against
go run ./demo -dir $(DEMO_DIR) $(if $(FORCE),-force $(DEMO_DIR))
uninstall: ## remove the installed binary
@rm -f $(PREFIX)/$(APP) && echo "removed: $(PREFIX)/$(APP)" || true
watch: ## rebuild + reinstall on every *.go save (needs entr: `brew install entr`)
@command -v entr >/dev/null || { echo "entr not found — run: brew install entr"; exit 1; }
@find . -name '*.go' -not -path './.git/*' | entr -rc $(MAKE) install
clean: ## remove build artifacts
rm -f $(APP)