-
Notifications
You must be signed in to change notification settings - Fork 183
/
build.sh
executable file
·332 lines (284 loc) · 10.9 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
#!/bin/bash
# Copyright (c) 2019, NVIDIA CORPORATION.
# BlazingSQL build script
# This script is used to build the component(s) in this repo from
# source, and can be called with various options to customize the
# build as needed (see the help output for details)
# Abort script on first error
set -e
NUMARGS=$#
ARGS=$*
# NOTE: ensure all dir changes are relative to the location of this
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)
VALIDARGS="clean update thirdparty io libengine engine pyblazing algebra disable-aws-s3 disable-google-gs disable-mysql disable-sqlite disable-postgresql -t -v -g -n -h"
HELP="$0 [-v] [-g] [-n] [-h] [-t]
clean - remove all existing build artifacts and configuration (start
over) Use 'clean thirdparty' to delete thirdparty folder
update - update cudf conda packages
thirdparty - build the Thirdparty C++ code only
io - build the IO C++ code only
libengine - build the engine C++ code only
engine - build the engine Python package
pyblazing - build the pyblazing Python package
algebra - build the algebra Python package
disable-aws-s3 - flag to disable AWS S3 support for libengine
disable-google-gs - flag to disable Google Cloud Storage support for libengine
disable-mysql - flag to enable MySQL support for libengine
disable-sqlite - flag to enable SQLite support for libengine
disable-postgresql - flag to enable PostgreSQL support for libengine
-t - skip tests
-v - verbose build mode
-g - build for debug
-n - no install step
-h - print this text
default action (no args) is to build and install all code and packages
"
THIRDPARTY_BUILD_DIR=${REPODIR}/thirdparty/aws-cpp/build
IO_BUILD_DIR=${REPODIR}/io/build
LIBENGINE_BUILD_DIR=${REPODIR}/engine/build
ENGINE_BUILD_DIR=${REPODIR}/engine
PYBLAZING_BUILD_DIR=${REPODIR}/pyblazing
ALGEBRA_BUILD_DIR=${REPODIR}/algebra
BUILD_DIRS="${THIRDPARTY_BUILD_DIR} ${IO_BUILD_DIR} ${LIBENGINE_BUILD_DIR}"
# Set defaults for vars modified by flags to this script
VERBOSE=""
QUIET="--quiet"
BUILD_TYPE=RelWithDebInfo
INSTALL_TARGET=install
TESTS="ON"
# Set defaults for vars that may not have been defined externally
# FIXME: if INSTALL_PREFIX is not set, check PREFIX, then check
# CONDA_PREFIX, but there is no fallback from there!
INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX}}}
PARALLEL_LEVEL=${PARALLEL_LEVEL:="4"}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_PREFIX/lib:$INSTALL_PREFIX/lib64
export CXXFLAGS="-L$INSTALL_PREFIX/lib"
export CFLAGS=$CXXFLAGS
if [ -z $CUDACXX ]; then
export CUDACXX=/usr/local/cuda/bin/nvcc
fi
function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}
function buildAll {
((${NUMARGS} == 0 )) || !(echo " ${ARGS} " | grep -q " [^-]\+ ")
}
if hasArg -h; then
echo "${HELP}"
exit 0
fi
# Check for valid usage
if (( ${NUMARGS} != 0 )); then
for a in ${ARGS}; do
if ! (echo " ${VALIDARGS} " | grep -q " ${a} "); then
echo "Invalid option: ${a}"
exit 1
fi
done
fi
# Get version number
export GIT_DESCRIBE_TAG=`git describe --tags`
export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'`
export UCX_PY_VERSION="0.21"
# Process flags
if hasArg -v; then
VERBOSE=1
QUIET=""
fi
if hasArg -g; then
BUILD_TYPE=Debug
fi
if hasArg -n; then
INSTALL_TARGET=""
fi
if hasArg -t; then
TESTS="OFF"
fi
# If clean given, run it prior to any other steps
if hasArg clean; then
# If the dirs to clean are mounted dirs in a container, the
# contents should be removed but the mounted dirs will remain.
# The find removes all contents but leaves the dirs, the rmdir
# attempts to remove the dirs but can fail safely.
for bd in ${BUILD_DIRS}; do
if [ -d ${bd} ]; then
find ${bd} -mindepth 1 -delete
rmdir ${bd} || true
fi
done
if hasArg thirdparty; then
rm -rf ${REPODIR}/thirdparty/aws-cpp/
fi
exit 0
fi
################################################################################
if buildAll || hasArg io || hasArg libengine || hasArg thirdparty || hasArg update; then
if hasArg disable-aws-s3; then
echo "AWS S3 thirdparty won't be downloaded"
else
if [ ! -d "${REPODIR}/thirdparty/aws-cpp/" ]; then
cd ${REPODIR}/thirdparty/
aws_cpp_version=$(conda list | grep aws-sdk-cpp|tail -n 1|awk '{print $2}')
echo "aws_cpp_version for aws cpp sdk 3rdparty is: $aws_cpp_version"
git clone -b $aws_cpp_version --depth=1 https://github.com/aws/aws-sdk-cpp.git ${REPODIR}/thirdparty/aws-cpp/
mkdir -p ${THIRDPARTY_BUILD_DIR}
cd ${THIRDPARTY_BUILD_DIR}
cmake -GNinja \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_ONLY='s3-encryption' \
-DENABLE_UNITY_BUILD=on \
-DENABLE_TESTING=off \
-DCMAKE_BUILD_TYPE=Release \
..
ninja install
else
echo "thirdparty/aws-cpp/ is already installed in ${INSTALL_PREFIX}"
fi
fi
fi
################################################################################
if hasArg update; then
conda install --yes -c rapidsai-nightly -c nvidia -c conda-forge -c defaults librmm=$MINOR_VERSION rmm=$MINOR_VERSION libcudf=$MINOR_VERSION cudf=$MINOR_VERSION dask-cudf=$MINOR_VERSION dask-cuda=$MINOR_VERSION ucx-py=$UCX_PY_VERSION ucx-proc=*=gpu
fi
################################################################################
if buildAll || hasArg io; then
disabled_aws_s3_flag=""
if hasArg disable-aws-s3; then
disabled_aws_s3_flag="-DS3_SUPPORT=OFF"
echo "AWS S3 support disabled for io"
fi
disabled_google_gs_flag=""
if hasArg disable-google-gs; then
disabled_google_gs_flag="-DGCS_SUPPORT=OFF"
echo "Google Cloud Storage support disabled for io"
fi
mkdir -p ${IO_BUILD_DIR}
cd ${IO_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DBUILD_TESTING=${TESTS} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} $disabled_aws_s3_flag $disabled_google_gs_flag ..
if [[ ${TESTS} == "ON" ]]; then
make -j${PARALLEL_LEVEL} all
else
make -j${PARALLEL_LEVEL} VERBOSE=${VERBOSE}
fi
if [[ ${INSTALL_TARGET} != "" ]]; then
make -j${PARALLEL_LEVEL} install VERBOSE=${VERBOSE}
fi
fi
if buildAll || hasArg libengine; then
disabled_aws_s3_flag=""
if hasArg disable-aws-s3; then
disabled_aws_s3_flag="-DS3_SUPPORT=OFF"
echo "AWS S3 support disabled for libengine"
fi
disabled_google_gs_flag=""
if hasArg disable-google-gs; then
disabled_google_gs_flag="-DGCS_SUPPORT=OFF"
echo "Google Cloud Storage support disabled for libengine"
fi
disable_mysql_flag=""
if hasArg disable-mysql; then
disable_mysql_flag="-DMYSQL_SUPPORT=OFF"
echo "MySQL database support disabled for engine"
fi
disable_sqlite_flag=""
if hasArg disable-sqlite; then
disable_sqlite_flag="-DSQLITE_SUPPORT=OFF"
echo "SQLite database support disabled for engine"
fi
disable_postgresql_flag=""
if hasArg disable-postgresql; then
disable_postgresql_flag="-DPOSTGRESQL_SUPPORT=OFF"
echo "PostgreSQL database support disabled for engine"
fi
echo "Building libengine"
mkdir -p ${LIBENGINE_BUILD_DIR}
cd ${LIBENGINE_BUILD_DIR}
echo "cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DBUILD_TESTING=${TESTS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=$CXXFLAGS .."
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DBUILD_TESTING=${TESTS} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_EXE_LINKER_FLAGS="$CXXFLAGS" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
$disabled_aws_s3_flag \
$disabled_google_gs_flag \
$disable_mysql_flag \
$disable_sqlite_flag \
$disable_postgresql_flag ..
echo "Building libengine: make step"
if [[ ${TESTS} == "ON" ]]; then
echo "make -j${PARALLEL_LEVEL} all"
make -j${PARALLEL_LEVEL} all
else
echo "make -j${PARALLEL_LEVEL} blazingsql-engine VERBOSE=${VERBOSE}"
make -j${PARALLEL_LEVEL} blazingsql-engine VERBOSE=${VERBOSE}
fi
if [[ ${INSTALL_TARGET} != "" ]]; then
echo "make -j${PARALLEL_LEVEL} install VERBOSE=${VERBOSE}"
make -j${PARALLEL_LEVEL} install VERBOSE=${VERBOSE}
cp libblazingsql-engine.so ${INSTALL_PREFIX}/lib/libblazingsql-engine.so
fi
fi
if buildAll || hasArg engine; then
echo "Building engine (cython wrapper)"
cd ${ENGINE_BUILD_DIR}
rm -f ./bsql_engine/io/io.h
rm -f ./bsql_engine/io/io.cpp
if [[ ${INSTALL_TARGET} != "" ]]; then
python setup.py build_ext --inplace
if [ $? != 0 ]; then
exit 1
fi
python setup.py install --single-version-externally-managed --record=record.txt
if [ $? != 0 ]; then
exit 1
fi
if [[ $CONDA_BUILD -eq 1 ]]; then
cp `pwd`/cio*.so `pwd`/../../_h_env*/lib/python*/site-packages
cp -r `pwd`/bsql_engine `pwd`/../../_h_env*/lib/python*/site-packages
fi
else
python setup.py build_ext --inplace --library-dir=${LIBENGINE_BUILD_DIR}
if [ $? != 0 ]; then
exit 1
fi
fi
fi
if buildAll || hasArg pyblazing; then
cd ${PYBLAZING_BUILD_DIR}
if [[ ${INSTALL_TARGET} != "" ]]; then
python setup.py build_ext --inplace
if [ $? != 0 ]; then
exit 1
fi
python setup.py install --single-version-externally-managed --record=record.txt
if [ $? != 0 ]; then
exit 1
fi
if [[ $CONDA_BUILD -eq 1 ]]; then
cp -r `pwd`/pyblazing `pwd`/../../_h_env*/lib/python*/site-packages
cp -r `pwd`/blazingsql `pwd`/../../_h_env*/lib/python*/site-packages
fi
else
python setup.py build_ext --inplace
if [ $? != 0 ]; then
exit 1
fi
fi
fi
if buildAll || hasArg algebra; then
cd ${ALGEBRA_BUILD_DIR}
if [[ ${TESTS} == "ON" ]]; then
mvn clean install -f pom.xml -Dmaven.repo.local=$INSTALL_PREFIX/blazing-protocol-mvn/ $QUIET
else
mvn clean install -Dmaven.test.skip=true -f pom.xml -Dmaven.repo.local=$INSTALL_PREFIX/blazing-protocol-mvn/ $QUIET
fi
if [[ ${INSTALL_TARGET} != "" ]]; then
cp blazingdb-calcite-application/target/BlazingCalcite.jar $INSTALL_PREFIX/lib/blazingsql-algebra.jar
cp blazingdb-calcite-core/target/blazingdb-calcite-core.jar $INSTALL_PREFIX/lib/blazingsql-algebra-core.jar
fi
fi