-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.defs
177 lines (125 loc) · 4.35 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
GO_VERSION := 1.21.7
REGISTER ?= ghcr.io
GIT_REPO ?= koffloader-io/koffloader
#======================
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
ARCH = $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH=amd64
endif
DESTDIR_BIN ?= $(ROOT_DIR)/output/$(ARCH)/bin
DESTDIR_BASH_COMPLETION ?= $(ROOT_DIR)/output/$(ARCH)/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
OPENAPI_SDK_DIR := ${ROOT_DIR}/api/v1/http
#===================== 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 := grafana/pyroscope:latest
# empty to disable PYROSCOPE
# PYROSCOPE_LOCAL_PORT :=
PYROSCOPE_LOCAL_PORT := 8040
E2E_KIND_CLUSTER_NAME ?= koffloader
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_KIND_NODE_IMAGE ?=
E2E_INSTALL_NAMESPACE ?= koffloader
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