1
1
#! /bin/bash
2
- set -ex
2
+ set -e
3
3
4
4
export TC_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
5
5
@@ -103,6 +103,21 @@ then
103
103
all=" 1"
104
104
fi
105
105
106
+ if [[ " ${VERBOSE} " = " 1" ]]; then
107
+ set -x
108
+ fi
109
+
110
+ orig_make=$( which make)
111
+
112
+ function make() {
113
+ # Workaround for https://cmake.org/Bug/view.php?id=3378
114
+ if [[ " ${VERBOSE} " = " 1" ]]; then
115
+ VERBOSE=${VERBOSE} ${orig_make} $@
116
+ else
117
+ ${orig_make} $@
118
+ fi
119
+ }
120
+
106
121
function set_cache() {
107
122
stat --format=" %n %Y %Z %s" ` find $1 -name CMakeLists.txt -o -name autogen.sh -o -name configure -o -name Makefile -exec realpath {} \; ` > $2
108
123
}
@@ -166,13 +181,13 @@ function install_gflags() {
166
181
echo " Reconfiguring GFlags"
167
182
VERBOSE=${VERBOSE} ${CMAKE_VERSION} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DGFLAGS_BUILD_SHARED_LIBS=ON -DGFLAGS_BUILD_STATIC_LIBS=OFF -DGFLAGS_BUILD_TESTING=ON -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} .. || exit 1
168
183
fi
169
- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
184
+ make -j $CORES -s || exit 1
170
185
171
186
set_cache .. .build_cache
172
187
set_bcache ${TC_DIR} /third-party/gflags ${TC_DIR} /third-party/.gflags_build_cache
173
188
fi
174
189
175
- VERBOSE= ${VERBOSE} make install -j $CORES -s || exit 1
190
+ make install -j $CORES -s || exit 1
176
191
echo " Successfully installed GFlags"
177
192
178
193
fi
@@ -191,13 +206,13 @@ function install_glog() {
191
206
echo " Reconfiguring Glog"
192
207
VERBOSE=${VERBOSE} ${CMAKE_VERSION} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RELWITHDEBINFO -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_DEBUG_POSTFIX=" " .. || exit 1
193
208
fi
194
- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
209
+ make -j $CORES -s || exit 1
195
210
196
211
set_cache .. .build_cache
197
212
set_bcache ${TC_DIR} /third-party/glog ${TC_DIR} /third-party/.glog_build_cache
198
213
fi
199
214
200
- CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} VERBOSE= ${VERBOSE} make install -j $CORES -s || exit 1
215
+ CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} make install -j $CORES -s || exit 1
201
216
echo " Successfully installed Glog"
202
217
203
218
fi
@@ -226,13 +241,13 @@ function install_aten() {
226
241
export PYTORCH_PYTHON=${PYTHON}
227
242
${CMAKE_VERSION} .. -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DHAS_C11_ATOMICS=OFF -DNO_CUDA=${ATEN_NO_CUDA}
228
243
fi
229
- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
244
+ make -j $CORES -s || exit 1
230
245
231
246
set_cache .. .build_cache
232
247
set_bcache ${TC_DIR} /third-party/ATen ${TC_DIR} /third-party/.aten_build_cache
233
248
fi
234
249
235
- VERBOSE= ${VERBOSE} make install -j $CORES -s || exit 1
250
+ make install -j $CORES -s || exit 1
236
251
echo " Successfully installed ATen"
237
252
238
253
fi
@@ -267,7 +282,7 @@ function install_caffe2() {
267
282
268
283
fi
269
284
270
- VERBOSE= ${VERBOSE} make -j $CORES install -s || exit 1
285
+ make -j $CORES install -s || exit 1
271
286
272
287
set_cache .. .build_cache
273
288
set_bcache ${TC_DIR} /third-party/caffe2 ${CAFFE2_BUILD_CACHE}
@@ -292,7 +307,7 @@ function install_isl() {
292
307
rm -rf * || exit 1
293
308
VERBOSE=${VERBOSE} ${CMAKE_VERSION} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DISL_INT=gmp -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} ..
294
309
fi
295
- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
310
+ make -j $CORES -s || exit 1
296
311
297
312
set_cache .. .build_cache
298
313
set_bcache ${TC_DIR} /third-party/islpp ${TC_DIR} /third-party/.islpp_build_cache
@@ -318,7 +333,7 @@ function install_dlpack() {
318
333
rm -rf * || exit 1
319
334
VERBOSE=${VERBOSE} ${CMAKE_VERSION} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} ..
320
335
fi
321
- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
336
+ make -j $CORES -s || exit 1
322
337
323
338
set_cache .. .build_cache
324
339
set_bcache ${TC_DIR} /third-party/dlpack ${TC_DIR} /third-party/.dlpack_build_cache
@@ -332,7 +347,14 @@ function install_dlpack() {
332
347
}
333
348
334
349
function install_cub() {
335
- cp -R ${TC_DIR} /third-party/cub/cub ${INSTALL_PREFIX} /include/
350
+ local tp_dir=${TC_DIR} /third-party/cub/cub
351
+ local include_dir=${INSTALL_PREFIX} /include/
352
+ if diff -rq ${tp_dir} ${include_dir} /cub > /dev/null 2>&1 ; then
353
+ echo " CUB is up to date"
354
+ else
355
+ echo " Installing CUB"
356
+ cp -R ${tp_dir} ${include_dir}
357
+ fi
336
358
}
337
359
338
360
function install_tc_python() {
@@ -393,8 +415,8 @@ function install_tc() {
393
415
fi
394
416
395
417
set_cache .. .build_cache
396
- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
397
- VERBOSE= ${VERBOSE} make install -j $CORES -s || exit 1
418
+ make -j $CORES -s || exit 1
419
+ make install -j $CORES -s || exit 1
398
420
399
421
install_tc_python
400
422
0 commit comments