-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build
executable file
·600 lines (511 loc) · 15 KB
/
build
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
#!/bin/bash
function begin_stage() {
local stage_name=$1
local distfile_mask=$2
echo -ne "\033]0;${stage_name} stage\007"
echo " * Cleaning and unpacking ${stage_name}"
rm -rf $WORK/*
if echo $distfile_mask | grep -q '\.tgz$' ; then
tar -xzf ${DIST}/$distfile_mask -C $WORK
elif echo $distfile_mask | grep -q '\.tar\.gz$' ; then
tar -xzf ${DIST}/$distfile_mask -C $WORK
elif echo $distfile_mask | grep -q '\.tar\.bz2$' ; then
tar -xjf ${DIST}/$distfile_mask -C $WORK
elif echo $distfile_mask | grep -q '\.tar\.xz$' ; then
tar --xz -xf ${DIST}/$distfile_mask -C $WORK
elif echo $distfile_mask | grep -q '\.zip$' ; then
unzip -d $WORK ${DIST}/$distfile_mask
fi
cd $WORK/`echo $distfile_mask | sed 's/\*.*//'`*
echo " * Compiling ${stage_name}"
sleep $PAUSE
}
function complete_stage() {
local next=$1
cd $ROOT
echo -n $next > $TARGET/stage
sleep $PAUSE
}
if [[ ! ${8} ]] ; then
echo
echo "Pass all build options or use build-* wrappers instead."
echo
echo "<1 build env path> <2 target path> <3 work dir> <4 distfiles dir> <5 lux src>..."
echo "...<6 generic build flags> <7 lux build flags> <8 CHOST> [9 stage]"
echo
echo " Stage 0.1 - zlib"
echo " Stage 0.2 - bzip2"
echo " Stage 0.3 - lzma"
echo " Stage 1.1 - boost"
echo " Stage 1.2 - jpeg"
echo " Stage 1.3 - tiff"
echo " Stage 1.4 - png"
echo " Stage 1.5 - freetype"
echo " Stage 1.6 - openexr"
echo " Stage 2.1 - openimageio"
echo " Stage 3 - Qt"
echo " Stage 4.1 - Embree"
echo " Stage 4.2 - Oidn"
echo " Stage 4.3 - C-blosc"
echo " Stage 4.4 - TBB"
echo " Stage 4.5 - NVRTC"
echo " Stage 5 - luxcore"
echo " Stage 6 - luxmark (optional)"
echo
exit 1
fi
STAGE=$9
ROOT="$1"
TARGET="$2"
WORK="$3"
DIST="$4"
LUX_TAG="$5"
PAUSE=1
if [[ ! -d "$1" ]] ; then
echo
echo "LuxCore src path is incorrect"
exit 1
fi
# enable LuxCore DLL building if sources dir contains "dll" or "sdk" postfix
# and it's not a LuxMark source tree
if echo $LUX_TAG | grep -iq -e 'dll' -e 'sdk' ; then
echo " * LuxCore DLL enabled"
BUILD_LUXCORE_DLL="-D BUILD_LUXCORE_DLL=1"
else
echo " * LuxCore static enabled"
fi
# compile pyluxcore target only if sources dir contains "pyluxcore"
if echo $LUX_TAG | grep -iq 'pyluxcore' ; then
echo " * pyluxcore target only"
LUXCORE_TARGET='pyluxcore'
else
LUXCORE_TARGET='luxrays luxcore pyluxcore luxcoreui'
fi
# build flags
LUXCORE_FLAGS=`echo $6 | sed s/'-fvisibility=hidden'//`" -pthread -lrt"
# platform specs
export CHOST="$7"
export CBUILD=$CHOST
export LDFLAGS="-static-libgcc -static-libstdc++"
CONFIGOPTS="--build=$CBUILD --host=$CHOST"
export CFLAGS="$6"
export CXXFLAGS="${CFLAGS}"
export CORE_COUNT=$(( `grep processor /proc/cpuinfo | wc -l` + 1))
export MAKEOPTS="-j $CORE_COUNT"
export TMP="$WORK"
export TEMP="$WORK"
export TMPDIR="$WORK"
export PYTHON_CMD="python3.10"
#export PYTHON_CMD="python3"
unset CC CXX
if [[ -e "${ROOT}"/use_clang ]] ; then
echo " * Using Clang compiler"
CLANG=1
LUXCORE_FLAGS="-mtune=generic -mno-ssse3 -mmmx -msse -msse2 -O3 -pipe -fvisibility-inlines-hidden -fno-stack-protector -fPIC -fopenmp=libomp"
export CC="clang"
export CXX="clang++"
export LDFLAGS="${LDFLAGS} -O3 -Wl,-plugin,/usr/lib64/LLVMgold.so -L${TARGET}/lib -static-libgcc -static-libstdc++"
export AR="${ROOT}/clang-ar"
export NM="nm --plugin /usr/lib64/LLVMgold.so"
else
echo " * Using GCC compiler"
fi
#####################################
mkdir -p $WORK 2>/dev/null
cd $ROOT
# compilation prechecks
echo -ne "\033]0;Preparing\007"
if [[ ! $STAGE ]] ; then
S=`cat $TARGET/stage 2>/dev/null`
if [[ ! $S ]] ; then
STAGE=0
else
STAGE=$S
fi
fi
if ! $ROOT/utils/prepare "$TARGET" "$DIST" ; then exit 1 ; fi
PYTHON_LIB=`find $TARGET -name 'libpython*'`
PYTHON_VARIANT=`if $(basename "$PYTHON_LIB" | grep -q 'm') ; then echo 'm' ; fi`
PYTHON_INCLUDE=`find /usr/include -type d -name "${PYTHON_CMD}*${PYTHON_VARIANT}" | awk '{ print length($0) " " $0; }' $file | sort -r -n | cut -d ' ' -f 2- | tail -n1 | sed s/'\n'//`
echo " * Using Python library path: $PYTHON_LIB"
echo " * Using Python include path: $PYTHON_INCLUDE"
echo
# STAGE 0.1 -- zlib
NEXT=0.2
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage zlib zlib*.tar.gz
if echo $TARGET | grep -q '\-64' ; then
ZLIB_PLATFORM="--64"
else
ZLIB_PLATFORM=""
fi
if ! ./configure --static $ZLIB_PLATFORM --prefix=$TARGET ; then
echo " !!! zlib configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install ; then
echo " * zlib compiled and installed successfully"
else
echo " !!! zlib compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 0.2 -- bzip2
NEXT=0.3
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage bzip2 bzip2*.tar.gz
echo " * Patching bzip2 Makefile for -fPIC support"
patch Makefile $DIST/bzip2-1.0.8-fpic.patch
if make $MAKEOPTS && make install PREFIX=$TARGET ; then
echo " * bzip2 compiled and installed successfully"
else
echo " !!! bzip2 compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 0.3 -- lzma
NEXT=0.4
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage lzma xz*.tar.xz
if ! ./configure --enable-static --disable-shared --disable-scripts --disable-xz \
--disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-lzma-links \
$CONFIGOPTS --prefix=$TARGET ; then
echo " !!! lzma configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install ; then
echo " * lzma compiled and installed successfully"
else
echo " !!! lzma compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 1.1 -- Boost
NEXT=1.2
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage boost boost*.tar.gz
echo " * Patching Boost Python support"
patch libs/python/src/exec.cpp $DIST/boost.python-1.72.0.patch
PYVER=`${PYTHON_CMD} --version 2>&1 | cut -d' ' -f2 | cut -d '.' -f'1 2'`
TOOLSET=`if [[ $CLANG ]] ; then echo clang ; else echo gcc ; fi`
echo " * Compiling boost for python-${PYVER}"
sleep 1
if ! ./bootstrap.sh --with-toolset=$TOOLSET --without-icu --prefix=$TARGET/boost \
--with-python=/usr/bin/python${PYVER} \
--with-python-root=`python${PYVER} -c "import sys; print(sys.prefix)"` ; then
echo " !!! Boost bootstrap failed"
exit 1
fi
# b2 debug options --debug-configuration -d0
if ./b2 $MAKEOPTS --debug-configuration -d0 -aq --toolset=$TOOLSET cflags="$CFLAGS" cxxflags="$CXXFLAGS" \
$CONFIGOPTS --prefix=$TARGET --layout=system --with-date_time --with-filesystem \
--with-iostreams --with-locale --with-program_options --with-python --with-regex \
--with-serialization --with-system --with-thread --with-chrono \
threading=multi link=static \
release install ; then
# Fix boost python lib names
mv -f $TARGET/lib/libboost_python*.a $TARGET/lib/libboost_python.a
mv -f $TARGET/lib/libboost_numpy*.a $TARGET/lib/libboost_numpy.a
echo " * Boost compiled and installed successfully"
else
echo " !!! Boost compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 1.2 -- Jpeg
NEXT=1.3
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage jpeg jpeg*.tar.gz
cp /usr/bin/libtool .
if ! ./configure $CONFIGOPTS --enable-static --prefix=$TARGET ; then
echo " !!! Jpeg configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && cp -vf .libs/libjpeg.a $TARGET/lib && \
cp -vf *.h $TARGET/include ; then
echo " * Jpeg compiled and installed successfully"
else
echo " !!! Jpeg compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 1.3 -- Tiff
NEXT=1.4
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage tiff tiff*.tar.gz
if ! ./configure --enable-static --disable-shared --disable-jbig $CONFIGOPTS --prefix=$TARGET ; then
echo " !!! TIFF configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install ; then
echo " * TIFF compiled and installed successfully"
else
echo " !!! TIFF compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 1.4 -- PNG
NEXT=1.5
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage png libpng*.tar.gz
# --with-libpng-prefix=lux_
if ! ./configure --enable-static --disable-shared $CONFIGOPTS --prefix=$TARGET ; then
echo " !!! PNG configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install && cd $TARGET/include && ln -vs libpng* libpng ; then
echo " * PNG compiled and installed successfully"
else
echo " !!! PNG compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 1.5 -- FreeType
NEXT=1.6
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage freetype freetype*.tar.bz2
if ! ./configure --enable-static --disable-shared $CONFIGOPTS --prefix=$TARGET ; then
echo " !!! freetype configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install ; then
echo " * freetype compiled and installed successfully"
else
echo " !!! freetype compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 1.6 -- OpenEXR
NEXT=2.1
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage openexr openexr*.tar.gz
cd IlmBase
if ! ./bootstrap ; then
echo " !!! ilmbase bootstrap failed"
exit 1
fi
if ! ./configure --enable-static --disable-shared $CONFIGOPTS --prefix=$TARGET ; then
echo " !!! ilmbase configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install ; then
echo " * ilmbase compiled and installed successfully"
else
echo " !!! ilmbase compilation failed"
exit 1
fi
cd ../OpenEXR
if ! ./bootstrap ; then
echo " !!! openexr bootstrap failed"
exit 1
fi
if ! ./configure --enable-static --disable-shared $CONFIGOPTS --prefix=$TARGET --with-ilmbase-prefix=$TARGET ; then
echo " !!! openexr configuration failed"
exit 1
fi
sleep $PAUSE
if make $MAKEOPTS && make install ; then
echo " * openexr compiled and installed successfully"
else
echo " !!! openexr compilation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 2.1 -- OpenImageIO
NEXT=2.2
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage openimageio oiio*.tar.gz
echo " * Patching OpenImageIO"
cp -vf $DIST/oiio-2.2.13.1-compiler.cmake src/cmake/compiler.cmake
if CMAKE_BUILD_PARALLEL_LEVEL=$CORE_COUNT CMAKE_PREFIX_PATH=$TARGET make $MAKEOPTS BOOST_HOME=$TARGET ILMBASE_HOME=$TARGET \
VERBOSE=1 USE_FFMPEG=0 EMBEDPLUGINS=1 \
USE_OPENGL=0 USE_QT=0 USE_GIF=0 USE_OPENJPEG=0 USE_OPENSSL=0 \
USE_FIELD3D=0 USE_OCIO=0 USE_OPENCV=0 USE_PYTHON=0 \
BUILD_SHARED_LIBS=0 LINKSTATIC=1 OIIO_BUILD_TOOLS=0 OIIO_BUILD_TESTS=0 \
STOP_ON_WARNING=0 ; then
echo " * openimageio compiled successfully"
else
echo " !!! openimageio compilation failed"
exit 1
fi
echo " * Installing openimageio library and headers"
sleep $PAUSE
if cp -vr dist/linux*/* $TARGET && cd $TARGET/lib && \
mv -v libOpenImageIO.a libOpenImageIOBase.a && \
ar -rcT libOpenImageIO.a libOpenImageIOBase.a libpng.a libjpeg.a libtiff.a libHalf.a \
libIex.a libIexMath.a libIlmImf.a libIlmThread.a libImath.a libz.a libbz2.a liblzma.a \
libfreetype.a ; then
echo " * openimageio installed successfully"
else
echo " !!! openimageio installation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 3 -- Qt
NEXT=4.1
if [[ $STAGE && $STAGE < $NEXT ]] ; then
if [[ ! -d "LuxMark" ]] ; then
echo
echo "LuxMark src not available, skipping the Qt stage"
else
begin_stage Qt qt-*.tar.gz
cp -v ${DIST}/qt-install.sh .
sleep 1
if ./qt-install.sh $TARGET ; then
echo " * Qt library and headers installed successfully"
else
echo " !!! Qt library and headers installation failed"
exit 1
fi
fi
complete_stage $NEXT
fi
# STAGE 4.1 -- Embree
NEXT=4.2
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage Embree embree-*.tar.gz
cp -v ${DIST}/embree-install.sh .
sleep 1
if ./embree-install.sh $TARGET ; then
echo " * Embree library and headers installed successfully"
else
echo " !!! Embree library and headers installation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 4.2 -- Oidn
NEXT=4.3
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage Oidn oidn-*.tar.gz
cp -v ${DIST}/oidn-install.sh .
sleep 1
if ./oidn-install.sh $TARGET ; then
echo " * Oidn library and headers installed successfully"
else
echo " !!! Oidn library and headers installation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 4.3 -- C-blosc
NEXT=4.4
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage C-blosc c-blosc-*.tgz
cp -v ${DIST}/cblosc-install.sh .
sleep 1
if ./cblosc-install.sh $TARGET ; then
echo " * C-blosc library and headers installed successfully"
else
echo " !!! C-blosc library and headers installation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 4.4 -- TBB
NEXT=4.5
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage TBB tbb*_lin.tgz
cp -v ${DIST}/tbb-install.sh .
sleep 1
if ./tbb-install.sh $TARGET ; then
echo " * TBB library and headers installed successfully"
else
echo " !!! TBB library and headers installation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 4.5 -- NVRTC
NEXT=5
if [[ $STAGE && $STAGE < $NEXT ]] ; then
begin_stage NVRTC cuda*nvrtc*.tar.gz
cp -v ${DIST}/nvrtc-install.sh .
sleep 1
if ./nvrtc-install.sh $TARGET ; then
echo " * NVRTC library installed successfully"
else
echo " !!! NVRTC library installation failed"
exit 1
fi
complete_stage $NEXT
fi
# STAGE 5 -- LuxCore
NEXT=6
if [[ $STAGE && $STAGE < $NEXT ]] ; then
echo -ne "\033]0;LuxCore stage\007"
cd $ROOT/$LUX_TAG
echo " * Configuring $LUXCORE_TARGET"
if ! cmake -G "Unix Makefiles" $BUILD_LUXCORE_DLL -Wno-dev \
-D LUXRAYS_CUSTOM_CONFIG=cmake/SpecializedConfig/Config_Linux-Static.cmake \
-D PYTHON_LIBRARY:FILEPATH="$PYTHON_LIB" \
-D PYTHON_INCLUDE_DIR:PATH="$PYTHON_INCLUDE" \
-D PYTHON_INCLUDE_DIRS:PATH="$PYTHON_INCLUDE" . ; then
echo " !!! $LUXCORE_TARGET configuration failed"
exit 1
fi
sleep $PAUSE
echo " * Compiling $LUXCORE_TARGET"
if cmake --build . -- $MAKEOPTS ; then
echo " * $LUXCORE_TARGET compiled successfully"
else
echo " !!! $LUXCORE_TARGET compilation failed"
exit 1
fi
mkdir ${TARGET}/$LUX_TAG 2>/dev/null
if echo $LUX_TAG | grep -iq 'pyluxcore' ; then
cp -vf lib/*.so ${TARGET}/$LUX_TAG
sleep $PAUSE
cd $ROOT
exit 0
fi
complete_stage $NEXT
sleep $PAUSE
cd $ROOT
fi
# STAGE 6 -- LuxMark
NEXT=7
if [[ $STAGE && $STAGE < $NEXT ]] ; then
echo -ne "\033]0;LuxMark stage\007"
if [[ ! -d "LuxMark" ]] ; then
echo
echo "LuxMark src not available, skipping the stage"
else
cd $ROOT/LuxMark
echo " * Configuring LuxMark"
if ! cmake -G "Unix Makefiles" -Wno-dev \
-D LUXMARK_CUSTOM_CONFIG=cmake/SpecializedConfig/Config_Linux-Static.cmake \
-D LuxRays_HOME="$ROOT/$LUX_TAG" . ; then
echo " !!! LuxMark configuration failed"
exit 1
fi
sleep $PAUSE
echo " * Compiling LuxMark"
if cmake --build . --target all -- $MAKEOPTS ; then
echo " * LuxMark compiled successfully"
else
echo " !!! LuxMark compilation failed"
exit 1
fi
fi
complete_stage $NEXT
sleep $PAUSE
cd $ROOT
fi