1XARGS:=xargs -r
2ifeq ($(shell uname -s),Darwin)
3 XARGS:=xargs
4endif
5
6TAG:=$(shell git describe --match 'v*' --always --dirty --broken)
7LDFLAGS:=-X main.version="${TAG}"
8
9all: build
10
11.PHONY: build
12build:
13 @nix-build -A default --argstr version "$(TAG)"
14
15# the "debug" build includes a debugger-friendly binary, and fetches the webui
16# from the filesystem instead of packing it into the binary
17.PHONY: build/debug
18build/debug:
19 @nix-build -A default --argstr version "$(TAG)" --arg debug true
20
21.PHONY: build/without-nix
22build/without-nix:
23 @go generate
24 @npm run --prefix webui build
25 @go run webui/pack_webui.go
26 @go build -ldflags "$(LDFLAGS)" .
27
28build/debug/without-nix:
29 @go generate
30 @npm run --prefix webui build
31 @go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
32
33.PHONY: release
34release:
35 @nix-build -A release --argstr version "$(TAG)"
36
37.PHONY: secure
38secure:
39 go run golang.org/x/vuln/cmd/govulncheck ./...
40
41.PHONY: test
42test:
43 go test -v -bench=. ./...
44
45.PHONY: clean-local-bugs
46clean-local-bugs:
47 git for-each-ref refs/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
48 git for-each-ref refs/remotes/origin/bugs/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
49 rm -f .git/git-bug/bug-cache
50
51.PHONY: clean-remote-bugs
52clean-remote-bugs:
53 git ls-remote origin "refs/bugs/*" | cut -f 2 | $(XARGS) git push origin -d
54
55.PHONY: clean-local-identities
56clean-local-identities:
57 git for-each-ref refs/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
58 git for-each-ref refs/remotes/origin/identities/ | cut -f 2 | $(XARGS) -n 1 git update-ref -d
59 rm -f .git/git-bug/identity-cache
60
61.PHONY: clean-local-identities
62clean-remote-identities:
63 git ls-remote origin "refs/identities/*" | cut -f 2 | $(XARGS) git push origin -d