-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
281 lines (243 loc) · 10.4 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
YB_BUILD_INFRASTRUCTURE_DOCKER_TAG?=docker.io/radekg/yugabyte-db-build-infrastructure
YB_BUILD_INFRASTRUCTURE_DOCKER_VER=$(shell git rev-parse --short HEAD)
# GCC version, GCC needs to be installed explicitly
GCC_VERSION=11
empty=
# Set known defaults
USE_COMPILER_TYPE=${empty}
USE_COMPILER_ARCH?=x86_64
USE_DOCKER_VER=${YB_BUILD_INFRASTRUCTURE_DOCKER_VER}
YB_REPOSITORY?=https://github.com/yugabyte/yugabyte-db.git
YB_SOURCE_VERSION?=v2.19.0.0
YB_RELEASE_VERSION?=2.19.0.0
ifeq (${USE_COMPILER_ARCH},${empty})
TEMP_ARCH=default
else
TEMP_ARCH=${USE_COMPILER_ARCH}
endif
ifeq ($(USE_COMPILER_TYPE),${empty})
TEMP_PREFIX=clang-default-${TEMP_ARCH}-${YB_SOURCE_VERSION}
else
TEMP_PREFIX=${USE_COMPILER_TYPE}-${TEMP_ARCH}-${YB_SOURCE_VERSION}
endif
YB_RELEASE_DOCKER_TAG?=local/yugabyte-db
YB_RELEASE_DOCKER_VERSION?=${YB_RELEASE_VERSION}
YB_RELEASE_DOCKER_ARG_GID?=1000
YB_RELEASE_DOCKER_ARG_GROUP?=yb
YB_RELEASE_DOCKER_ARG_UID?=1000
YB_RELEASE_DOCKER_ARG_USER?=yb
YB_POSTGRES_WITH_ICU?=true
YB_COMPOSE_SHARED_PRELOAD_LIBRARIES?=${empty}
CURRENT_DIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
PLATFORM=$(shell uname -s)
.PHONY: ybdb-build-infrastructure
ybdb-build-infrastructure:
cd ${CURRENT_DIR}/.docker/build-infrastructure \
&& docker buildx build --no-cache \
--build-arg BUILD_PLATFORM=linux/amd64 \
--build-arg ALMALINUX_VERSION=8.8 \
--build-arg GCC_VERSION=${GCC_VERSION} \
--platform linux/amd64 \
-t ${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${YB_BUILD_INFRASTRUCTURE_DOCKER_VER} . \
&& docker tag ${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${YB_BUILD_INFRASTRUCTURE_DOCKER_VER} \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:latest
# First pass build:
# -----------------
.PHONY: ybdb-build-first-pass-clang
ybdb-build-first-pass-clang:
# Use the default clang version available in the build infrastructure:
$(MAKE) ybdb-build-first-pass
.PHONY: ybdb-build-first-pass-gcc
ybdb-build-first-pass-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-build-first-pass
.PHONY: ybdb-build-first-pass
ybdb-build-first-pass:
ifeq ($(PLATFORM),Linux)
sudo rm -rf ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build \
&& sudo rm -rf ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source \
&& sudo rm -rf ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache
else
rm -rf ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build \
&& rm -rf ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source \
&& rm -rf ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache
endif
mkdir -p ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build \
&& mkdir -p ${CURRENT_DIR}/.tmp/yb-maven \
&& mkdir -p ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source \
&& mkdir -p ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/extensions \
&& mkdir -p ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache \
&& docker run --rm -ti \
--platform linux/amd64 \
-e YB_REPOSITORY=${YB_REPOSITORY} \
-e YB_SOURCE_VERSION=${YB_SOURCE_VERSION} \
-e YB_POSTGRES_WITH_ICU=${YB_POSTGRES_WITH_ICU} \
-e YB_CONFIGURED_COMPILER_TYPE=${USE_COMPILER_TYPE} \
-e YB_CONFIGURED_COMPILER_ARCH=${USE_COMPILER_ARCH} \
-e YB_CCACHE_DIR=/yb-build-cache \
-e LANG=en_US.UTF-8 \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache:/yb-build-cache \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/extensions:/extensions \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${USE_DOCKER_VER} yb-first-pass-build.sh
# Build infrastructure shell:
# ---------------------------
.PHONY: ybdb-infrastructure-shell-clang
ybdb-infrastructure-shell-clang:
$(MAKE) ybdb-infrastructure-shell
.PHONY: ybdb-infrastructure-shell-gcc
ybdb-infrastructure-shell-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-infrastructure-shell
.PHONY: ybdb-infrastructure-shell
ybdb-infrastructure-shell:
docker run --rm -ti \
--platform linux/amd64 \
-e YB_REPOSITORY=${YB_REPOSITORY} \
-e YB_SOURCE_VERSION=${YB_SOURCE_VERSION} \
-e YB_POSTGRES_WITH_ICU=${YB_POSTGRES_WITH_ICU} \
-e YB_CONFIGURED_COMPILER_TYPE=${USE_COMPILER_TYPE} \
-e YB_CONFIGURED_COMPILER_ARCH=${USE_COMPILER_ARCH} \
-e YB_CCACHE_DIR=/yb-build-cache \
-e LANG=en_US.UTF-8 \
-v ${CURRENT_DIR}/.docker/build-infrastructure/patches:/patches \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache:/yb-build-cache \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/extensions:/extensions \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${USE_DOCKER_VER} /bin/bash
# Rebuild extensions:
# -------------------
.PHONY: ybdb-rebuild-extensions-clang
ybdb-rebuild-extensions-clang:
# Use the default clang version available in the build infrastructure:
$(MAKE) ybdb-rebuild-extensions
.PHONY: ybdb-rebuild-extensions-gcc
ybdb-rebuild-extensions-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-rebuild-extensions
.PHONY: ybdb-rebuild-extensions
ybdb-rebuild-extensions:
docker run --rm -ti \
--platform linux/amd64 \
-e YB_SOURCE_VERSION=${YB_SOURCE_VERSION} \
-e YB_POSTGRES_WITH_ICU=${YB_POSTGRES_WITH_ICU} \
-e YB_CONFIGURED_COMPILER_TYPE=${USE_COMPILER_TYPE} \
-e YB_CONFIGURED_COMPILER_ARCH=${USE_COMPILER_ARCH} \
-e YB_CCACHE_DIR=/yb-build-cache \
-e LANG=en_US.UTF-8 \
-v ${CURRENT_DIR}/.docker/build-infrastructure/patches:/patches \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache:/yb-build-cache \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/extensions:/extensions \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${USE_DOCKER_VER} yb-rebuild-extensions.sh
# Rebuild:
# --------
.PHONY: ybdb-rebuild-clang
ybdb-rebuild-clang:
# Use the default clang version available in the build infrastructure:
$(MAKE) ybdb-rebuild
.PHONY: ybdb-rebuild-gcc
ybdb-rebuild-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-rebuild
.PHONY: ybdb-rebuild
ybdb-rebuild:
docker run --rm -ti \
--platform linux/amd64 \
-e YB_SOURCE_VERSION=${YB_SOURCE_VERSION} \
-e YB_POSTGRES_WITH_ICU=${YB_POSTGRES_WITH_ICU} \
-e YB_CONFIGURED_COMPILER_TYPE=${USE_COMPILER_TYPE} \
-e YB_CONFIGURED_COMPILER_ARCH=${USE_COMPILER_ARCH} \
-e YB_CCACHE_DIR=/yb-build-cache \
-e LANG=en_US.UTF-8 \
-v ${CURRENT_DIR}/.docker/build-infrastructure/patches:/patches \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache:/yb-build-cache \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/extensions:/extensions \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${USE_DOCKER_VER} yb-rebuild.sh
# Build a distribution:
# ---------------------
.PHONY: ybdb-distribution-clang
ybdb-distribution-clang:
# Use the default clang version available in the build infrastructure:
$(MAKE) ybdb-distribution
.PHONY: ybdb-distribution-gcc
ybdb-distribution-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-distribution
.PHONY: ybdb-distribution
ybdb-distribution:
docker run --rm -ti \
--platform linux/amd64 \
-e YB_RELEASE_VERSION=${YB_RELEASE_VERSION} \
-e YB_CONFIGURED_COMPILER_TYPE=${USE_COMPILER_TYPE} \
-e YB_CONFIGURED_COMPILER_ARCH=${USE_COMPILER_ARCH} \
-e YB_CCACHE_DIR=/yb-build-cache \
-e LANG=en_US.UTF-8 \
-v ${CURRENT_DIR}/.docker/build-infrastructure/patches:/patches \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache:/yb-build-cache \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/extensions:/extensions \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${USE_DOCKER_VER} yb-release.sh
# Build Docker image from a distribution:
# ---------------------------------------
.PHONY: ybdb-build-docker-clang
ybdb-build-docker-clang:
# Use the default clang version available in the build infrastructure:
$(MAKE) ybdb-build-docker
.PHONY: ybdb-build-docker-gcc
ybdb-build-docker-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-build-docker
.PHONY: ybdb-build-docker
ybdb-build-docker:
ifeq ($(PLATFORM),Linux)
sudo chmod 0644 ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source/build/yugabyte-*.tar.gz
endif
$(eval RELEASE_SPEC := $(shell basename $(shell cat ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source/build/latest-release) | sed 's/.tar.gz//'))
mkdir -p ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-docker-build \
&& cp -v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source/build/yugabyte-*.tar.gz ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-docker-build/ \
&& cp -v ${CURRENT_DIR}/.docker/yugabyte-db/Dockerfile ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-docker-build/ \
&& cd ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-docker-build/ \
&& docker buildx build \
--platform linux/amd64 \
--build-arg BUILD_PLATFORM=linux/amd64 \
--build-arg ALMALINUX_VERSION=8.8 \
--build-arg ALPINE_VERSION=3.18 \
--build-arg RELEASE_SPEC=${RELEASE_SPEC} \
--build-arg GID=${YB_RELEASE_DOCKER_ARG_GID} \
--build-arg GROUPNAME=${YB_RELEASE_DOCKER_ARG_GROUP} \
--build-arg UID=${YB_RELEASE_DOCKER_ARG_UID} \
--build-arg USERNAME=${YB_RELEASE_DOCKER_ARG_USER} \
--build-arg YB_RELEASE_VERSION=${YB_RELEASE_VERSION} \
--build-arg YB_SOURCE_VERSION=${YB_SOURCE_VERSION} \
--build-arg YB_REPOSITORY=${YB_REPOSITORY} \
-t ${YB_RELEASE_DOCKER_TAG}:${YB_RELEASE_DOCKER_VERSION} .
# Test runner:
# ------------
.PHONY: ybdb-tests-clang
ybdb-tests-clang:
# Use the default clang version available in the build infrastructure:
$(MAKE) ybdb-tests
.PHONY: ybdb-tests-gcc
ybdb-tests-gcc:
$(MAKE) USE_COMPILER_TYPE=gcc${GCC_VERSION} ybdb-tests
.PHONY: ybdb-tests
ybdb-tests:
docker run --rm -ti \
--platform linux/amd64 \
--cap-add=SYS_PTRACE \
-p "5433:5433" \
-e YB_CONFIGURED_COMPILER_TYPE=${USE_COMPILER_TYPE} \
-e YB_CONFIGURED_COMPILER_ARCH=${USE_COMPILER_ARCH} \
-e YB_CCACHE_DIR=/yb-build-cache \
-e LANG=en_US.UTF-8 \
-v ${CURRENT_DIR}/.tmp/yb-maven:/root/.m2 \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build:/opt/yb-build \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-source:/yb-source \
-v ${CURRENT_DIR}/.tmp/${TEMP_PREFIX}/yb-build-cache:/yb-build-cache \
${YB_BUILD_INFRASTRUCTURE_DOCKER_TAG}:${USE_DOCKER_VER} /bin/bash -c 'yb-tests.sh; /bin/bash'