Reuse the same channel for all precompleted contexts
[go-signalcontext.git] / go.mk
1 GOPKGSRC ?= $(wildcard *.go)
2 GOTESTSRC ?= $(wildcard *_test.go)
3 GOSRC ?= $(filter-out $(GOTESTSRC),$(GOPKGSRC))
4 GOTESTDATA ?= $(shell test ! -d testdata || find testdata)
5
6 GOMAINSRC ?= $(wildcard cmd/*/main.go)
7 GOBIN ?= $(patsubst cmd/%/main.go,%,$(GOMAINSRC))
8
9 GOCOVERAGE ?= go.coverage
10 GOBENCHMARK ?= go.benchmark
11
12 %: cmd/%/main.go $(GOPKGSRC)
13 go build -o $@ $(GOBUILDFLAGS) $<
14
15 test:: $(GOCOVERAGE).out
16
17 $(GOCOVERAGE).out: GOTESTFLAGS ?= -race
18 $(GOCOVERAGE).out: $(GOPKGSRC) $(GOTESTSRC) $(GOTESTDATA) go.mod
19 go test -coverprofile=$@ $(GOTESTFLAGS) ./...
20
21 $(GOCOVERAGE).html: $(GOCOVERAGE).out
22 go tool cover -html $< -o $@
23
24 bench:: $(GOBENCHMARK)
25
26 $(GOBENCHMARK): GOBENCHFLAGS ?= -benchmem
27 $(GOBENCHMARK): $(GOPKGSRC) $(GOTESTSRC) $(GOTESTDATA) go.mod
28 go test -bench . $(GOBENCHFLAGS) | tee $@
29
30 clean::
31 $(RM) $(GOCOVERAGE).{html,out} $(GOBENCHMARK) $(GOBIN)
32
33 .PHONY: clean test $(GOCOVERAGE)
34 .DELETE_ON_ERROR: