1UNAME_S := $(shell uname -s)
2XARGS:=xargs -r
3ifeq ($(UNAME_S),Darwin)
4 XARGS:=xargs
5endif
6
7SYSTEM=$(shell nix eval --impure --expr 'builtins.currentSystem' --raw 2>/dev/null || echo '')
8
9TAG:=$(shell git name-rev --name-only --tags HEAD)
10LDFLAGS:=-X main.version="${TAG}"
11
12all: build
13
14.PHONY: list-checks
15list-checks:
16 @if test -z "$(SYSTEM)"; then echo "unable to detect system. is nix installed?" && exit 1; fi
17 @printf "Available checks for $(SYSTEM) (run all with \`nix flake check\`):\n"
18 @nix flake show --json 2>/dev/null |\
19 dasel -r json -w plain '.checks.x86_64-linux.keys().all()' |\
20 xargs -I NAME printf '\t%-20s %s\n' "NAME" "nix build .#checks.linux.NAME"
21
22.PHONY: build
23build:
24 go generate
25 go build -ldflags "$(LDFLAGS)" .
26
27# produce a debugger-friendly build
28.PHONY: build/debug
29build/debug:
30 go generate
31 go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
32
33.PHONY: install
34install:
35 go generate
36 go install -ldflags "$(LDFLAGS)" .
37
38.PHONY: releases
39releases:
40 go generate
41 go run github.com/mitchellh/gox@v1.0.1 -ldflags "$(LDFLAGS)" -osarch '!darwin/386' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
42
43.PHONY: secure
44secure:
45 go run golang.org/x/vuln/cmd/govulncheck ./...
46
47.PHONY: test
48test:
49 go test -v -bench=. ./...
50
51.PHONY: pack-webui
52pack-webui:
53 npm run --prefix webui build
54 go run webui/pack_webui.go
55
56# produce a build that will fetch the web UI from the filesystem instead of from the binary
57.PHONY: debug-webui
58debug-webui:
59 go build -ldflags "$(LDFLAGS)" -tags=debugwebui
60
61.PHONY: clean-local-bugs
62clean-local-bugs:
63 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
64 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
65 rm -f .git/git-bug/bug-cache
66
67.PHONY: clean-remote-bugs
68clean-remote-bugs:
69 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
70
71.PHONY: clean-local-identities
72clean-local-identities:
73 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
74 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
75 rm -f .git/git-bug/identity-cache
76
77.PHONY: clean-local-identities
78clean-remote-identities:
79 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d