-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
54 lines (40 loc) · 1.3 KB
/
Makefile
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
VERSION := $(shell git describe --always --dirty --tags)
# Strip binaries by default to make them smaller.
GO_LDFLAGS = -s -w -X github.com/rstudio/rskey/cmd.Version=$(VERSION)
GO_BUILD_ARGS = -v -trimpath
GOPATH = $(shell go env GOPATH)
ADDLICENSE = go tool github.com/google/addlicense
ADDLICENSE_ARGS = -v -s=only -l=apache -c "Posit Software, PBC" -ignore 'coverage*' -ignore '.github/**' -ignore '.goreleaser.yaml'
NOTICETOOL = go tool go.elastic.co/go-licence-detector
all: rskey
.PHONY: rskey
rskey:
CGO_ENABLED=0 go build -ldflags="$(GO_LDFLAGS)" $(GO_BUILD_ARGS) -o $@ ./$<
.PHONY: static-build
static-build: rskey
ldd $< 2>&1 | grep 'not a dynamic executable'
check: fmt vet
.PHONY: test
test:
go test ./... $(GO_BUILD_ARGS) -coverprofile coverage.out
go tool cover -html=coverage.out -o coverage.html
go test ./... $(GO_BUILD_ARGS) -tags "fips" -coverprofile coverage-fips.out
go tool cover -html=coverage-fips.out -o coverage-fips.html
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: vet
vet:
go vet ./...
.PHONY: check-license
check-license:
$(ADDLICENSE) $(ADDLICENSE_ARGS) -check .
.PHONY: license
license:
$(ADDLICENSE) $(ADDLICENSE_ARGS) .
notice: NOTICE.md
NOTICE.md: NOTICE.md.tmpl go.mod go.sum
go list -m -json all | $(NOTICETOOL) -noticeOut $@ -noticeTemplate $<
.PHONY: clean
clean:
rm -f rskey