-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile
60 lines (45 loc) · 2.06 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
# Copyright 2022 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
default: build
GO := GO111MODULE=on go
BUILD_BIN_PATH := $(shell pwd)/bin
PACKAGES := go list ./...
DIRECTORIES := $(PACKAGES) | sed 's|github.com/tikv/migration/gc-worker/||'
TEST_PARALLEL := 8
GCWORKER_PKG := github.com/tikv/migration/gc-worker
LDFLAGS += -X "$(GCWORKER_PKG)/server.GCWorkerVersion=$(shell git describe --tags --dirty --always)"
#### Build ####
build:
$(GO) build -tags codes -gcflags "all=-N -l" -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/tikv-gc-worker cmd/*.go
release:
$(GO) build -tags codes -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/tikv-gc-worker cmd/*.go
check: check/golangci-lint check/gosec
check/golangci-lint: tools/bin/golangci-lint
GO111MODULE=on CGO_ENABLED=0 tools/bin/golangci-lint run -v $$($(DIRECTORIES)) --config ../.golangci.yml --timeout 5m
tools/bin/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v1.41.1
check/gosec: tools/bin/gosec
tools/bin/gosec -fmt=junit-xml -out=results.xml -stdout -verbose=text -exclude=G103,G104,G204,G304,G307,G401,G404,G501,G505,G601 ./...
tools/bin/gosec:
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b ./tools/bin v2.9.1
test:
$(GO) test -p $(TEST_PARALLEL) -race -ldflags '$(LDFLAGS)' -tags leak $$($(PACKAGES))
#### Clean up ####
clean: clean-build
clean-build:
# Cleaning building files...
rm -rf $(BUILD_BIN_PATH)
rm -rf tools/*
rm -rf results.xml
.PHONY: clean clean-build