forked from opencurve/curveadm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (58 loc) · 1.67 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
.PHONY: build debug install test upload lint
# go env
GOPROXY := "https://goproxy.cn,direct"
GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
CGO_LDFLAGS := "-static"
CGO_CFLAGS := "-D_LARGEFILE64_SOURCE"
CC := musl-gcc
GOENV := GO111MODULE=on
GOENV += GOPROXY=$(GOPROXY)
GOENV += CC=$(CC)
GOENV += CGO_ENABLED=1 CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_CFLAGS=$(CGO_CFLAGS)
GOENV += GOOS=$(GOOS) GOARCH=$(GOARCH)
GOLANGCILINT_VERSION ?= v1.50.0
GOBIN := $(shell go env GOPATH)/bin
GOBIN_GOLANGCILINT := $(shell which $(GOBIN)/golangci-lint)
# go
GO := go
# output
OUTPUT := bin/dingoadm
# build flags
LDFLAGS := -s -w
LDFLAGS += -extldflags "-static -fpic"
LDFLAGS += -X github.com/dingodb/curveadm/cli/cli.CommitId=$(shell git rev-parse --short HEAD)
BUILD_FLAGS := -a
BUILD_FLAGS += -trimpath
BUILD_FLAGS += -ldflags '$(LDFLAGS)'
BUILD_FLAGS += $(EXTRA_FLAGS)
# debug flags
GCFLAGS := "all=-N -l"
DEBUG_FLAGS := -gcflags=$(GCFLAGS)
# go test
GO_TEST ?= $(GO) test
# test flags
CASE ?= "."
TEST_FLAGS := -v
TEST_FLAGS += -p 3
TEST_FLAGS += -cover
TEST_FLAGS += -count=1
TEST_FLAGS += $(DEBUG_FLAGS)
TEST_FLAGS += -run $(CASE)
# packages
PACKAGES := $(PWD)/cmd/curveadm/main.go
# tar
VERSION := "unknown"
build:
$(GOENV) $(GO) build -o $(OUTPUT) $(BUILD_FLAGS) $(PACKAGES)
debug:
$(GOENV) $(GO) build -o $(OUTPUT) $(DEBUG_FLAGS) $(PACKAGES)
install:
cp bin/dingoadm ~/.curveadm/bin
test:
$(GO_TEST) $(TEST_FLAGS) ./...
upload:
@NOSCMD=$(NOSCMD) bash build/package/upload.sh $(VERSION)
lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCILINT_VERSION)
$(GOBIN_GOLANGCILINT) run -v