Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (62 loc) · 2.13 KB
/
Copy pathMakefile
File metadata and controls
74 lines (62 loc) · 2.13 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
BINARY := ttype
CMD := ./cmd/ttype
PREFIX ?= /usr/local
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
TAPES := $(patsubst docs/tapes/%.tape,%,$(wildcard docs/tapes/[!_]*.tape))
.PHONY: build
build:
go build -ldflags "-X main.version=$(VERSION)" -o bin/$(BINARY) $(CMD)
.PHONY: test
test:
go test ./...
.PHONY: cover
cover:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
.PHONY: cover-html
cover-html: cover
go tool cover -html=coverage.out
.PHONY: lint
lint:
go vet ./...
.PHONY: lint-strict
lint-strict:
golangci-lint run ./...
.PHONY: bench
bench:
go test -run XXX -bench . -benchmem ./...
.PHONY: run
run: build
./bin/$(BINARY)
.PHONY: demo
# Record docs/tapes/*.tape into docs/*.svg. `make demo TAPE=modes` for one.
# Each tape is played in a pty and the recording is turned into an animated
# SVG. The recorder isolates the config and data dirs so recording never
# touches real history, which only works on Linux.
demo: build
@python3 -c "import pyte" 2>/dev/null || { echo "pyte not installed: pip install pyte"; exit 1; }
@for t in $(if $(TAPE),$(TAPE),$(TAPES)); do \
test -f docs/tapes/$$t.tape || { echo "no such tape: $$t"; exit 1; }; \
case $$t in demo) size="80 22"; zoom="--zoom-typing 1.4";; help) size="96 40"; zoom="";; *) size="96 28"; zoom="";; esac; \
cast=$$(mktemp); \
python3 docs/tapes/tape2cast.py docs/tapes/$$t.tape $$cast $$size $(CURDIR)/bin && \
python3 docs/tapes/cast2svg.py $$cast docs/$$t.svg $$zoom || exit 1; \
rm -f $$cast; \
done
.PHONY: clean
clean:
rm coverage.out
rm -rf bin/
.PHONY: completions
completions: build
@mkdir -p contrib/completions
./bin/$(BINARY) completion bash > contrib/completions/$(BINARY).bash
./bin/$(BINARY) completion zsh > contrib/completions/_$(BINARY)
./bin/$(BINARY) completion fish > contrib/completions/$(BINARY).fish
./bin/$(BINARY) completion powershell > contrib/completions/$(BINARY).ps1
.PHONY: man-install
man-install:
install -Dm644 man/$(BINARY).1 $(DESTDIR)$(PREFIX)/share/man/man1/$(BINARY).1
.PHONY: release-snapshot
release-snapshot:
goreleaser release --snapshot --clean