-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile.common
102 lines (86 loc) · 4.1 KB
/
Makefile.common
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Copyright 2020 PingCAP
#
# 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.
PROJECT=tiunimanager
GOPATH ?= $(shell go env GOPATH)
P=8
# Get system info, include OS and ARCH
OS ?= $(shell uname -s)
ifeq ($(OS), Darwin)
OS := osx
else ifeq ($(OS), darwin)
OS := osx
else ifeq ($(OS), Linux)
OS := linux
endif
ARCH ?= $(shell uname -m)
ifeq ($(ARCH), arm64)
ARCH := x86_64
else ifeq ($(ARCH), amd64)
ARCH := x86_64
else ifeq ($(ARCH), aarch64)
ARCH := aarch_64
endif
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'
CURDIR := $(shell pwd)
TEST_DIR := /tmp/tidb_em_test
CODECOV_BASH := /tmp/codecov_bash
EXTERN_PATH := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(EXTERN_PATH):$(PATH)
GO := GO111MODULE=on go
GOBUILD := $(GO) build $(BUILD_FLAG) -tags codes
#GOBUILDCOVERAGE := GOPATH=$(GOPATH) cd tidb-server; $(GO) test -coverpkg="../..." -c .
GOTEST := $(GO) test -p $(P)
OVERALLS := GO111MODULE=on overalls
STATICCHECK := GO111MODULE=on staticcheck
TIUNIMANAGER_EDITION ?= Enterprise
# Ensure TIUNIMANAGER_EDITION is set to Community or Enterprise before running build process.
ifneq "$(TIUNIMANAGER_EDITION)" "Enterprise"
$(error Please set the correct environment variable TIUNIMANAGER_EDITION before running `make`)
endif
# use 'make <target> PREFIX=/path/for/prefix' to overwrite the PREFIX value
ifeq (${PREFIX},)
PREFIX := /usr/local
endif
LINUX := "Linux"
MAC := "Darwin"
PACKAGE_LIST := go list ./...| grep -vE "docs|proto|common|message|micro-cluster/service|util|micro-cluster/registry|micro-cluster/platform/telemetry|library/framework|micro-api|workflow|file-server|test/mock|deprecated|util/scp|^github.com/pingcap/tiunimanager/micro-cluster$$|library/secondparty|micro-cluster/resourcemanager/management|models/resource/management|micro-cluster/cluster/switchover"
PACKAGES ?= $$($(PACKAGE_LIST))
LINT_PACKAGE_LIST := go list ./...| grep -vE "docs|proto|test"
LINT_PACKAGES ?= $$($(LINT_PACKAGE_LIST))
#PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/$(PROJECT)||'
PACKAGE_DIRECTORIES := $(PACKAGE_LIST)
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
FAILPOINT_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git)" | xargs bin/failpoint-ctl enable)
FAILPOINT_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git)" | xargs bin/failpoint-ctl disable)
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/fristparty/util/versioninfo.TiUniManagerReleaseVersion=$(shell git describe --tags --dirty --always)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerBuildTS=$(shell date -u '+%Y-%m-%d %H:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
LDFLAGS += -X "github.com/pingcap/tiunimanager/library/firstparty/util/versioninfo.TiUniManagerEdition=$(TIUNIMANAGER_EDITION)"
#TODO TEST_LDFLAGS = -X "github.com/pingcap/tidb/config.checkBeforeDropLDFlag=1"
#TODO COVERAGE_SERVER_LDFLAGS = -X "github.com/pingcap/tidb/tidb-server.isCoverageServer=1"
# TODO CHECK_LDFLAGS += $(LDFLAGS) ${TEST_LDFLAGS}
RACE_FLAG =
ifeq ("$(WITH_RACE)", "1")
RACE_FLAG = -race
GOBUILD = GOPATH=$(GOPATH) $(GO) build
endif
CHECK_FLAG =
ifeq ("$(WITH_CHECK)", "1")
CHECK_FLAG = $(TEST_LDFLAGS)
endif