forked from secretflow/scql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (57 loc) · 2.16 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
export GO111MODULE=on
GOPATH := ${GOPATH}:${PWD}
TOOLBIN := ${PWD}/tool-bin
export PATH := ${TOOLBIN}:$(PATH)
export GOFLAGS=-buildmode=pie
export CGO_CPPFLAGS=-fstack-protector-strong -D_FORTIFY_SOURCE=2
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
export CGO_LDFLAGS=-Wl,-z,relro,-z,now,-z,noexecstack
endif
.PHONY: clean vet lint test detect-shadowing fast pb prepare fmt gogenerate
default: install
install: clean prepare fmt vet gogenerate
GOBIN=${PWD}/bin go install ./cmd/...
gogenerate:
go generate ./pkg/...
go generate ./cmd/...
fast: fmt vet
GOBIN=${PWD}/bin go install ./cmd/...
parser:
cd pkg/parser && make
build: fmt vet
go build ./cmd/...
pb: clean
$(RM) -rf pkg/proto-gen/*
./api/generate_proto.sh
fmt:
go fmt ./pkg/...
vet:
go vet -unsafeptr=false ./pkg/...
doc:
go run ./cmd/docgen/main.go
lint: GOLINT-exists
-${TOOLBIN}/golangci-lint run ./pkg/scdb/...
detect-shadowing:
go vet -vettool=$(shell which shadow) -strict ./...
clean:
$(RM) bin/*
$(RM) *.coverprofile
test:
go test -v -cover ./pkg/...
coverage: install
go list -f '{{if gt (len .TestGoFiles) 0}}"go test -covermode count -coverprofile {{.Name}}.coverprofile -coverpkg ./... {{.ImportPath}}"{{end}}' ./... | xargs -I {} bash -c {}
find . -name "*.coverprofile"
$(info Use `go tool cover -html MODULE_NAME.coverprofile`)
prepare: GO-exists GO-package
GO-exists:
$(if $(shell command -v go 2> /dev/null),$(info Found `go`),$(error Please install go (prefer v1.19.6): refer to `https://golang.org/dl/`))
GOLINT-exists:
$(if $(shell command -v golangci-lint 2> /dev/null),$(info Found `golangci-lint`),$(shell curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ${TOOLBIN} v1.42.0))
GO-package:
@GOBIN=${TOOLBIN} go install github.com/golang/mock/mockgen@v1.6.0 && \
GOBIN=${TOOLBIN} go install golang.org/x/tools/cmd/goyacc@latest && \
GOBIN=${TOOLBIN} go install golang.org/x/tools/cmd/cover@latest && \
GOBIN=${TOOLBIN} go install github.com/mattn/goveralls@latest && \
GOBIN=${TOOLBIN} go install github.com/rakyll/gotest@latest && \
GOBIN=${TOOLBIN} go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest