-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathGNUmakefile
More file actions
62 lines (49 loc) · 1.22 KB
/
GNUmakefile
File metadata and controls
62 lines (49 loc) · 1.22 KB
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
55
56
57
58
59
60
61
62
.PHONY: \
all \
build \
install \
lint \
golangci \
vet \
fmt \
mlint \
fmtcheck \
pretest \
test \
unused \
cov \
clean
SRCS = $(shell git ls-files '*.go')
PKGS = $(shell go list ./...)
VERSION := $(shell git describe --tags --abbrev=0)
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -X 'github.com/vulsio/goval-dictionary/config.Version=$(VERSION)' \
-X 'github.com/vulsio/goval-dictionary/config.Revision=$(REVISION)'
GO := CGO_ENABLED=0 go
all: build test
build: main.go
$(GO) build -a -ldflags "$(LDFLAGS)" -o goval-dictionary $<
install: main.go
$(GO) install -ldflags "$(LDFLAGS)"
lint:
go install github.com/mgechev/revive@latest
revive -config ./.revive.toml -formatter plain $(PKGS)
golangci:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
vet:
echo $(PKGS) | xargs env $(GO) vet || exit;
fmt:
gofmt -s -w $(SRCS)
fmtcheck:
$(foreach file,$(SRCS),gofmt -s -d $(file);)
pretest: lint vet fmtcheck
test: pretest
$(GO) test -cover -v ./... || exit;
cov:
@ go get -v github.com/axw/gocov/gocov
@ go get golang.org/x/tools/cmd/cover
gocov test | gocov report
clean:
echo $(PKGS) | xargs go clean || exit;
echo $(PKGS) | xargs go clean || exit;