forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·431 lines (382 loc) · 12.7 KB
/
build.sh
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
##############################################################
# This script is used to compile Apache Doris(incubating).
# Usage:
# sh build.sh --help
#
# You need to make sure all thirdparty libraries have been
# compiled and installed correctly.
##############################################################
set -eo pipefail
ROOT=`dirname "$0"`
ROOT=`cd "$ROOT"; pwd`
export DORIS_HOME=${ROOT}
. ${DORIS_HOME}/env.sh
# Check args
usage() {
echo "
Usage: $0 <options>
Optional options:
[no option] build all components
--fe build Frontend and Spark DPP application
--be build Backend
--meta-tool build Backend meta tool
--broker build Broker
--spark-dpp build Spark DPP application
--hive-udf build Hive UDF library for Spark Load
--java-udf build Java UDF library
--clean clean and build target
-j build Backend parallel
Environment variables:
USE_AVX2 If the CPU does not support AVX2 instruction set, please set USE_AVX2=0. Default is ON.
STRIP_DEBUG_INFO If set STRIP_DEBUG_INFO=ON, the debug information in the compiled binaries will be stored separately in the 'be/lib/debug_info' directory. Default is OFF.
Eg.
$0 build all
$0 --be build Backend
$0 --meta-tool build Backend meta tool
$0 --fe --clean clean and build Frontend and Spark Dpp application
$0 --fe --be --clean clean and build Frontend, Spark Dpp application and Backend
$0 --spark-dpp build Spark DPP application alone
$0 --broker build Broker
$0 --be --fe --java-udf build Backend, Frontend, Spark Dpp application and Java UDF library
USE_AVX2=0 $0 --be build Backend and not using AVX2 instruction.
USE_AVX2=0 STRIP_DEBUG_INFO=ON $0 build all and not using AVX2 instruction, and strip the debug info for Backend
"
exit 1
}
clean_gensrc() {
pushd ${DORIS_HOME}/gensrc
make clean
rm -rf ${DORIS_HOME}/fe/fe-common/target
rm -rf ${DORIS_HOME}/fe/fe-core/target
popd
}
clean_be() {
pushd ${DORIS_HOME}
# "build.sh --clean" just cleans and exits, however CMAKE_BUILD_DIR is set
# while building be.
CMAKE_BUILD_TYPE=${BUILD_TYPE:-Release}
CMAKE_BUILD_DIR=${DORIS_HOME}/be/build_${CMAKE_BUILD_TYPE}
rm -rf $CMAKE_BUILD_DIR
rm -rf ${DORIS_HOME}/be/output/
popd
}
clean_fe() {
pushd ${DORIS_HOME}/fe
${MVN_CMD} clean
popd
}
OPTS=$(getopt \
-n $0 \
-o '' \
-l 'fe' \
-l 'be' \
-l 'broker' \
-l 'meta-tool' \
-l 'spark-dpp' \
-l 'java-udf' \
-l 'hive-udf' \
-l 'clean' \
-l 'help' \
-o 'hj:' \
-- "$@")
if [ $? != 0 ] ; then
usage
fi
eval set -- "$OPTS"
PARALLEL=$[$(nproc)/4+1]
BUILD_FE=0
BUILD_BE=0
BUILD_BROKER=0
BUILD_META_TOOL=OFF
BUILD_SPARK_DPP=0
BUILD_JAVA_UDF=0
BUILD_HIVE_UDF=0
CLEAN=0
HELP=0
PARAMETER_COUNT=$#
PARAMETER_FLAG=0
if [ $# == 1 ] ; then
# default
BUILD_FE=1
BUILD_BE=1
BUILD_BROKER=1
BUILD_META_TOOL=ON
BUILD_SPARK_DPP=1
BUILD_JAVA_UDF=0 # TODO: open it when ready
BUILD_HIVE_UDF=1
CLEAN=0
else
while true; do
case "$1" in
--fe) BUILD_FE=1 BUILD_SPARK_DPP=1 ; shift ;;
--be) BUILD_BE=1 ; shift ;;
--broker) BUILD_BROKER=1 ; shift ;;
--meta-tool) BUILD_META_TOOL=ON ; shift ;;
--spark-dpp) BUILD_SPARK_DPP=1 ; shift ;;
--java-udf) BUILD_JAVA_UDF=1 BUILD_FE=1 BUILD_SPARK_DPP=1 ; shift ;;
--hive-udf) BUILD_HIVE_UDF=1 ; shift ;;
--clean) CLEAN=1 ; shift ;;
-h) HELP=1; shift ;;
--help) HELP=1; shift ;;
-j) PARALLEL=$2; PARAMETER_FLAG=1; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error" ; exit 1 ;;
esac
done
#only ./build.sh -j xx then build all
if [[ ${PARAMETER_COUNT} -eq 3 ]] && [[ ${PARAMETER_FLAG} -eq 1 ]];then
BUILD_FE=1
BUILD_BE=1
BUILD_BROKER=1
BUILD_META_TOOL=ON
BUILD_SPARK_DPP=1
BUILD_JAVA_UDF=1
BUILD_HIVE_UDF=1
CLEAN=0
fi
fi
if [[ ${HELP} -eq 1 ]]; then
usage
exit
fi
# build thirdparty libraries if necessary
if [[ ! -f ${DORIS_THIRDPARTY}/installed/lib/libbacktrace.a ]]; then
echo "Thirdparty libraries need to be build ..."
# need remove all installed pkgs because some lib like lz4 will throw error if its lib alreay exists
rm -rf ${DORIS_THIRDPARTY}/installed
${DORIS_THIRDPARTY}/build-thirdparty.sh -j $PARALLEL
fi
if [ ${CLEAN} -eq 1 -a ${BUILD_BE} -eq 0 -a ${BUILD_FE} -eq 0 -a ${BUILD_SPARK_DPP} -eq 0 ]; then
clean_gensrc
clean_be
clean_fe
exit 0
fi
if [[ -z ${WITH_MYSQL} ]]; then
WITH_MYSQL=OFF
fi
if [[ -z ${GLIBC_COMPATIBILITY} ]]; then
GLIBC_COMPATIBILITY=ON
fi
if [[ -z ${USE_AVX2} ]]; then
USE_AVX2=ON
fi
if [[ -z ${WITH_LZO} ]]; then
WITH_LZO=OFF
fi
if [[ -z ${USE_LIBCPP} ]]; then
USE_LIBCPP=OFF
fi
if [[ -z ${USE_LLD} ]]; then
USE_LLD=OFF
fi
if [[ -z ${STRIP_DEBUG_INFO} ]]; then
STRIP_DEBUG_INFO=OFF
fi
echo "Get params:
BUILD_FE -- $BUILD_FE
BUILD_BE -- $BUILD_BE
BUILD_BROKER -- $BUILD_BROKER
BUILD_META_TOOL -- $BUILD_META_TOOL
BUILD_SPARK_DPP -- $BUILD_SPARK_DPP
BUILD_JAVA_UDF -- $BUILD_JAVA_UDF
BUILD_HIVE_UDF -- $BUILD_HIVE_UDF
PARALLEL -- $PARALLEL
CLEAN -- $CLEAN
WITH_MYSQL -- $WITH_MYSQL
WITH_LZO -- $WITH_LZO
GLIBC_COMPATIBILITY -- $GLIBC_COMPATIBILITY
USE_AVX2 -- $USE_AVX2
USE_LIBCPP -- $USE_LIBCPP
USE_LLD -- $USE_LLD
STRIP_DEBUG_INFO -- $STRIP_DEBUG_INFO
"
# Clean and build generated code
if [ ${CLEAN} -eq 1 ]; then
clean_gensrc
fi
echo "Build generated code"
cd ${DORIS_HOME}/gensrc
# DO NOT using parallel make(-j) for gensrc
python --version
make
# Assesmble FE modules
FE_MODULES=
BUILD_DOCS=OFF
modules=("")
if [ ${BUILD_FE} -eq 1 ]; then
modules+=("fe-common")
modules+=("fe-core")
BUILD_DOCS=ON
fi
if [ ${BUILD_SPARK_DPP} -eq 1 ]; then
modules+=("fe-common")
modules+=("spark-dpp")
fi
if [ ${BUILD_JAVA_UDF} -eq 1 ]; then
modules+=("java-udf")
fi
if [ ${BUILD_HIVE_UDF} -eq 1 ]; then
modules+=("fe-common")
modules+=("hive-udf")
fi
FE_MODULES=$(IFS=, ; echo "${modules[*]}")
# Clean and build Backend
if [ ${BUILD_BE} -eq 1 ] ; then
CMAKE_BUILD_TYPE=${BUILD_TYPE:-Release}
echo "Build Backend: ${CMAKE_BUILD_TYPE}"
CMAKE_BUILD_DIR=${DORIS_HOME}/be/build_${CMAKE_BUILD_TYPE}
if [ ${CLEAN} -eq 1 ]; then
clean_be
fi
MAKE_PROGRAM="$(which "${BUILD_SYSTEM}")"
echo "-- Make program: ${MAKE_PROGRAM}"
mkdir -p ${CMAKE_BUILD_DIR}
cd ${CMAKE_BUILD_DIR}
${CMAKE_CMD} -G "${GENERATOR}" \
-DCMAKE_MAKE_PROGRAM="${MAKE_PROGRAM}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DMAKE_TEST=OFF \
${CMAKE_USE_CCACHE} \
-DWITH_MYSQL=${WITH_MYSQL} \
-DWITH_LZO=${WITH_LZO} \
-DUSE_LIBCPP=${USE_LIBCPP} \
-DBUILD_META_TOOL=${BUILD_META_TOOL} \
-DUSE_LLD=${USE_LLD} \
-DBUILD_JAVA_UDF=${BUILD_JAVA_UDF} \
-DSTRIP_DEBUG_INFO=${STRIP_DEBUG_INFO} \
-DUSE_AVX2=${USE_AVX2} \
-DGLIBC_COMPATIBILITY=${GLIBC_COMPATIBILITY} ../
${BUILD_SYSTEM} -j ${PARALLEL}
${BUILD_SYSTEM} install
cd ${DORIS_HOME}
fi
if [ "${BUILD_DOCS}" = "ON" ] ; then
# Build docs, should be built before Frontend
echo "Build docs"
cd ${DORIS_HOME}/docs
./build_help_zip.sh
cd ${DORIS_HOME}
fi
function build_ui() {
NPM=npm
if ! ${NPM} --version; then
echo "Error: npm is not found"
exit 1
fi
if [[ ! -z ${CUSTOM_NPM_REGISTRY} ]]; then
${NPM} config set registry ${CUSTOM_NPM_REGISTRY}
npm_reg=`${NPM} get registry`
echo "NPM registry: $npm_reg"
fi
echo "Build Frontend UI"
ui_dist=${DORIS_HOME}/ui/dist/
if [[ ! -z ${CUSTOM_UI_DIST} ]]; then
ui_dist=${CUSTOM_UI_DIST}
else
cd ${DORIS_HOME}/ui
${NPM} install
${NPM} run build
fi
echo "ui dist: ${ui_dist}"
rm -rf ${DORIS_HOME}/fe/fe-core/src/main/resources/static/
mkdir -p ${DORIS_HOME}/fe/fe-core/src/main/resources/static
cp -r ${ui_dist}/* ${DORIS_HOME}/fe/fe-core/src/main/resources/static
}
# FE UI must be built before building FE
if [ ${BUILD_FE} -eq 1 ] ; then
build_ui
fi
# Clean and build Frontend
if [ ${FE_MODULES}x != ""x ]; then
echo "Build Frontend Modules: $FE_MODULES"
cd ${DORIS_HOME}/fe
if [ ${CLEAN} -eq 1 ]; then
clean_fe
fi
${MVN_CMD} package -pl ${FE_MODULES} -DskipTests
cd ${DORIS_HOME}
fi
# Clean and prepare output dir
DORIS_OUTPUT=${DORIS_HOME}/output/
mkdir -p ${DORIS_OUTPUT}
# Copy Frontend and Backend
if [ ${BUILD_FE} -eq 1 ]; then
install -d ${DORIS_OUTPUT}/fe/bin ${DORIS_OUTPUT}/fe/conf \
${DORIS_OUTPUT}/fe/webroot/ ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/bin/*_fe.sh ${DORIS_OUTPUT}/fe/bin/
cp -r -p ${DORIS_HOME}/conf/fe.conf ${DORIS_OUTPUT}/fe/conf/
rm -rf ${DORIS_OUTPUT}/fe/lib/*
cp -r -p ${DORIS_HOME}/fe/fe-core/target/lib/* ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/fe/fe-core/target/palo-fe.jar ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/docs/build/help-resource.zip ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/webroot/static ${DORIS_OUTPUT}/fe/webroot/
cp -r -p ${DORIS_THIRDPARTY}/installed/webroot/* ${DORIS_OUTPUT}/fe/webroot/static/
mkdir -p ${DORIS_OUTPUT}/fe/log
mkdir -p ${DORIS_OUTPUT}/fe/doris-meta
fi
if [ ${BUILD_SPARK_DPP} -eq 1 ]; then
install -d ${DORIS_OUTPUT}/fe/spark-dpp/
rm -rf ${DORIS_OUTPUT}/fe/spark-dpp/*
cp -r -p ${DORIS_HOME}/fe/spark-dpp/target/spark-dpp-*-jar-with-dependencies.jar ${DORIS_OUTPUT}/fe/spark-dpp/
fi
if [ ${BUILD_BE} -eq 1 ]; then
install -d ${DORIS_OUTPUT}/be/bin \
${DORIS_OUTPUT}/be/conf \
${DORIS_OUTPUT}/be/lib/ \
${DORIS_OUTPUT}/be/www \
${DORIS_OUTPUT}/udf/lib \
${DORIS_OUTPUT}/udf/include
cp -r -p ${DORIS_HOME}/be/output/bin/* ${DORIS_OUTPUT}/be/bin/
cp -r -p ${DORIS_HOME}/be/output/conf/* ${DORIS_OUTPUT}/be/conf/
cp -r -p ${DORIS_HOME}/be/output/lib/palo_be ${DORIS_OUTPUT}/be/lib/
if [ "${BUILD_META_TOOL}" = "ON" ]; then
cp -r -p ${DORIS_HOME}/be/output/lib/meta_tool ${DORIS_OUTPUT}/be/lib/
fi
cp -r -p ${DORIS_HOME}/be/output/udf/*.a ${DORIS_OUTPUT}/udf/lib/
cp -r -p ${DORIS_HOME}/be/output/udf/include/* ${DORIS_OUTPUT}/udf/include/
cp -r -p ${DORIS_HOME}/webroot/be/* ${DORIS_OUTPUT}/be/www/
if [ "${STRIP_DEBUG_INFO}" = "ON" ]; then
cp -r -p ${DORIS_HOME}/be/output/lib/debug_info ${DORIS_OUTPUT}/be/lib/
fi
java_udf_path=${DORIS_HOME}/fe/java-udf/target/java-udf-jar-with-dependencies.jar
if [ -f ${java_udf_path} ];then
cp ${java_udf_path} ${DORIS_OUTPUT}/be/lib/
fi
cp -r -p ${DORIS_THIRDPARTY}/installed/webroot/* ${DORIS_OUTPUT}/be/www/
mkdir -p ${DORIS_OUTPUT}/be/log
mkdir -p ${DORIS_OUTPUT}/be/storage
fi
if [ ${BUILD_BROKER} -eq 1 ]; then
install -d ${DORIS_OUTPUT}/apache_hdfs_broker
cd ${DORIS_HOME}/fs_brokers/apache_hdfs_broker/
./build.sh
rm -rf ${DORIS_OUTPUT}/apache_hdfs_broker/*
cp -r -p ${DORIS_HOME}/fs_brokers/apache_hdfs_broker/output/apache_hdfs_broker/* ${DORIS_OUTPUT}/apache_hdfs_broker/
cd ${DORIS_HOME}
fi
echo "***************************************"
echo "Successfully build Doris"
echo "***************************************"
if [[ ! -z ${DORIS_POST_BUILD_HOOK} ]]; then
eval ${DORIS_POST_BUILD_HOOK}
fi
exit 0