-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.defs
208 lines (146 loc) · 5.25 KB
/
Makefile.defs
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
GO_VERSION := 1.20
REGISTER ?= ghcr.io
GIT_REPO ?= spidernet-io/spiderdoctor
#======================
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
RELATIVE_DIR := $(shell echo $(realpath .) | sed "s;$(ROOT_DIR)[/]*;;")
INSTALL = install
PREFIX?=/usr
BINDIR?=$(PREFIX)/bin
TARGETARCH ?= amd64
DESTDIR_BIN ?= $(ROOT_DIR)/output/$(TARGETARCH)/bin
DESTDIR_BASH_COMPLETION ?= $(ROOT_DIR)/output/$(TARGETARCH)/bash-completion
CHART_DIR := $(ROOT_DIR)/charts
DESTDIR_CHART ?= $(ROOT_DIR)/output/chart
UNITEST_OUTPUT ?= $(ROOT_DIR)/output/test
DOC_OUTPUT ?= $(ROOT_DIR)/output/docs
GO_MAJOR_AND_MINOR_VERSION := $(shell grep -o -E '^[0-9]+\.[0-9]+' <<< "${GO_VERSION}" )
GO_IMAGE_VERSION := $(shell awk -F. '{ z=$$3; if (z == "") z=0; print $$1 "." $$2 "." z}' <<< "${GO_VERSION}" )
CONTAINER_ENGINE?=docker
VERSION = $(shell cat $(dir $(lastword $(MAKEFILE_LIST)))/VERSION)
GIT_COMMIT_VERSION = $(shell git show -s --format='format:%H')
GIT_COMMIT_TIME = $(shell git show -s --format='format:%aI')
FULL_BUILD_VERSION = $(VERSION) $(GIT_COMMIT_VERSION)
#------------------
# define a function replacing spaces with commas in a list
empty :=
space := $(empty) $(empty)
comma := ,
join-with-comma = $(subst $(space),$(comma),$(strip $1))
#------------------
GO ?= go
GO_BUILD_FLAGS =
GO_TEST_FLAGS =
GO_CLEAN_FLAGS =
GO_BUILD_LDFLAGS =
# go build/test -tags values
GO_TAGS_FLAGS = osusergo
# This is declared here as it is needed to change the covermode depending on if
# RACE is specified.
GOTEST_COVER_OPTS =
#strip binary
ifeq ($(NOSTRIP),)
# Note: these options will not remove annotations needed for stack
# traces, so panic backtraces will still be readable.
#
# -w: Omit the DWARF symbol table.
# -s: Omit the symbol table and debug information.
GO_BUILD_LDFLAGS += -s -w
endif
GO_BUILD_FLAGS += -mod=vendor
GO_TEST_FLAGS += -mod=vendor
GO_CLEAN_FLAGS += -mod=vendor
GO_BUILD = CGO_ENABLED=0 $(GO) build
# Currently crosscompiling only enabled for arm64 targets
CGO_CC =
ifeq ($(GOARCH),arm64)
CGO_CC = CC=aarch64-linux-gnu-gcc
endif
GO_BUILD_WITH_CGO = CGO_ENABLED=1 $(CGO_CC) $(GO) build
#data race and lock debug
ifeq ($(RACE),1)
GO_BUILD_FLAGS += -race
GO_TEST_FLAGS += -race
GOTEST_COVER_OPTS += -covermode=atomic
# GO_BUILD becomes GO_BUILD_WITH_CGO as `-race` requires CGO
GO_BUILD = $(GO_BUILD_WITH_CGO)
ifeq ($(LOCKDEBUG),)
LOCKDEBUG=1
endif
else
GOTEST_COVER_OPTS += -covermode=count
endif
ifneq ($(LOCKDEBUG),)
GO_TAGS_FLAGS += lockdebug
endif
GO_BUILD_FLAGS += -ldflags '$(GO_BUILD_LDFLAGS) $(EXTRA_GO_BUILD_LDFLAGS)' -tags=$(call join-with-comma,$(GO_TAGS_FLAGS)) $(EXTRA_GO_BUILD_FLAGS)
GO_TEST_FLAGS += -tags=$(call join-with-comma,$(GO_TAGS_FLAGS))
#no optimize for binary
ifeq ($(NOOPT),1)
GO_BUILD_FLAGS += -gcflags="all=-N -l"
endif
GO_BUILD += $(GO_BUILD_FLAGS)
GO_BUILD_WITH_CGO += $(GO_BUILD_FLAGS)
GO_TEST = $(GO) test $(GO_TEST_FLAGS)
GO_CLEAN = $(GO) clean $(GO_CLEAN_FLAGS)
GO_VET = $(GO) vet
GO_LIST = $(GO) list
GOFILES_EVAL := $(subst _$(ROOT_DIR)/,,$(shell $(GO_LIST) -find -e $(ROOT_DIR)/...))
GOFILES ?= $(GOFILES_EVAL)
# LINT_TRIVY_SEVERITY_LEVEL ?= CRITICAL,HIGH
LINT_TRIVY_SEVERITY_LEVEL ?= CRITICAL
#===================== E2E
PROJECT_IMAGE_VERSION ?= $(GIT_COMMIT_VERSION)
ifeq ($(PROJECT_IMAGE_VERSION),)
PROJECT_IMAGE_VERSION = $(shell cat $(ROOT_DIR)/VERSION | tr -d ' ' | tr -d '\n' )
endif
#====== pyroscope
PYROSCOPE_CONTAINER_NAME := pyroscope
PYROSCOPE_IMAGE_NAME := pyroscope/pyroscope:latest
# if PYROSCOPE_LOCAL_PORT not defined, PYROSCOPE will not installed
PYROSCOPE_LOCAL_PORT :=
# PYROSCOPE_LOCAL_PORT := 8040
E2E_KIND_CLUSTER_NAME ?= spiderdoctor
E2E_KIND_MASTER_NODE_NAME = $(E2E_KIND_CLUSTER_NAME)-control-plane
E2E_KIND_WORKER_NODE_NAME = $(E2E_KIND_CLUSTER_NAME)-worker
E2E_RUNTIME_DIR := $(ROOT_DIR)/test/runtime
E2E_KIND_KUBECONFIG_PATH := $(E2E_RUNTIME_DIR)/kubeconfig_$(E2E_KIND_CLUSTER_NAME).config
E2E_LOG_FILE ?= $(E2E_RUNTIME_DIR)/e2edebugLog.txt
E2E_GINKGO_REPORT_FILE ?= $(E2E_RUNTIME_DIR)/ginkgoreport.json
E2E_MULTUS_CNI_CONFIG_DIR ?= $(E2E_RUNTIME_DIR)/multus
E2E_KIND_NODE_IMAGE ?=
E2E_GINKGO_LABELS ?=
E2E_GINKGO_OPTION ?=
E2E_TIMEOUT ?= 60m
E2E_GINKGO_PROCS ?= 4
# ipv4 or ipv6 or dual, default ipv4
E2E_IP_FAMILY ?= dual
E2E_KIND_IPV4_SERVICE_CIDR = 172.41.0.0/16
E2E_KIND_IPV6_SERVICE_CIDR = fd41::/108
E2E_KIND_IPV4_POD_CIDR = 172.40.0.0/16
E2E_KIND_IPV6_POD_CIDR = fd40::/48
E2E_PROXY_REGISTER := m.daocloud.
#E2E_PROXY_REGISTER :=
E2E_ENABLE_MULTUS = false
MULTUS_CHART_VERSION = 0.1.4
MULTUS_CHART_REPO = https://release.daocloud.io/chartrepo/system
MULTUS_REPO_NAME = network-release
MULTUS_CHART_NAME = multus-underlay
E2E_ENABLE_METALLB = true
METALLB_CHART_VERSION = 0.13.7
METALLB_CHART_REPO ?= https://metallb.github.io/metallb
METALLB_REPO_NAME = metallb
METALLB_CHART_NAME = metallb
E2E_ENABLE_CONTOUR = true
CONTOUR_CHART_VERSION = 10.1.1
CONTOUR_CHART_REPO ?= https://charts.bitnami.com/bitnami
CONTOUR_REPO_NAME = contour
CONTOUR_CHART_NAME = contour
E2E_ENABLE_NGINX = false
NGINX_CHART_VERSION = 4.4.0
NGINX_CHART_REPO ?= https://kubernetes.github.io/ingress-nginx
NGINX_REPO_NAME = ingress-nginx
NGINX_CHART_NAME = ingress-nginx
EXAMPLE_APP_IMAGE_TAG = v0.2.2