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 describe --match 'v*' --always --dirty --broken)
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-webui
23build-webui:
24 cd webui2 && npm run build
25
26.PHONY: build
27build: build-webui
28 go generate
29 go build -ldflags "$(LDFLAGS)" .
30
31# produce a debugger-friendly build
32.PHONY: build/debug
33build/debug: build-webui
34 go generate
35 go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
36
37.PHONY: install
38install: build-webui
39 go generate
40 go install -ldflags "$(LDFLAGS)" .
41
42.PHONY: releases
43releases: build-webui
44 go generate
45 go run github.com/mitchellh/gox@v1.0.1 -ldflags "$(LDFLAGS)" -osarch '!darwin/386' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
46
47.PHONY: secure
48secure:
49 go run golang.org/x/vuln/cmd/govulncheck ./...
50
51.PHONY: test
52test:
53 go test -v -bench=. ./...
54
55.PHONY: clean-local-bugs
56clean-local-bugs:
57 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
58 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
59 rm -f .git/git-bug/bug-cache
60
61.PHONY: clean-remote-bugs
62clean-remote-bugs:
63 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
64
65.PHONY: clean-local-identities
66clean-local-identities:
67 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
68 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
69 rm -f .git/git-bug/identity-cache
70
71.PHONY: clean-local-identities
72clean-remote-identities:
73 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d