11#! /bin/bash
2- set -ex
2+ set -e
33
44export TC_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
55
@@ -103,6 +103,21 @@ then
103103 all=" 1"
104104fi
105105
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+
106121function set_cache() {
107122 stat --format=" %n %Y %Z %s" ` find $1 -name CMakeLists.txt -o -name autogen.sh -o -name configure -o -name Makefile -exec realpath {} \; ` > $2
108123}
@@ -166,13 +181,13 @@ function install_gflags() {
166181 echo " Reconfiguring GFlags"
167182 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
168183 fi
169- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
184+ make -j $CORES -s || exit 1
170185
171186 set_cache .. .build_cache
172187 set_bcache ${TC_DIR} /third-party/gflags ${TC_DIR} /third-party/.gflags_build_cache
173188 fi
174189
175- VERBOSE= ${VERBOSE} make install -j $CORES -s || exit 1
190+ make install -j $CORES -s || exit 1
176191 echo " Successfully installed GFlags"
177192
178193 fi
@@ -191,13 +206,13 @@ function install_glog() {
191206 echo " Reconfiguring Glog"
192207 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
193208 fi
194- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
209+ make -j $CORES -s || exit 1
195210
196211 set_cache .. .build_cache
197212 set_bcache ${TC_DIR} /third-party/glog ${TC_DIR} /third-party/.glog_build_cache
198213 fi
199214
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
201216 echo " Successfully installed Glog"
202217
203218 fi
@@ -226,13 +241,13 @@ function install_aten() {
226241 export PYTORCH_PYTHON=${PYTHON}
227242 ${CMAKE_VERSION} .. -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DHAS_C11_ATOMICS=OFF -DNO_CUDA=${ATEN_NO_CUDA}
228243 fi
229- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
244+ make -j $CORES -s || exit 1
230245
231246 set_cache .. .build_cache
232247 set_bcache ${TC_DIR} /third-party/ATen ${TC_DIR} /third-party/.aten_build_cache
233248 fi
234249
235- VERBOSE= ${VERBOSE} make install -j $CORES -s || exit 1
250+ make install -j $CORES -s || exit 1
236251 echo " Successfully installed ATen"
237252
238253 fi
@@ -267,7 +282,7 @@ function install_caffe2() {
267282
268283 fi
269284
270- VERBOSE= ${VERBOSE} make -j $CORES install -s || exit 1
285+ make -j $CORES install -s || exit 1
271286
272287 set_cache .. .build_cache
273288 set_bcache ${TC_DIR} /third-party/caffe2 ${CAFFE2_BUILD_CACHE}
@@ -292,7 +307,7 @@ function install_isl() {
292307 rm -rf * || exit 1
293308 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} ..
294309 fi
295- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
310+ make -j $CORES -s || exit 1
296311
297312 set_cache .. .build_cache
298313 set_bcache ${TC_DIR} /third-party/islpp ${TC_DIR} /third-party/.islpp_build_cache
@@ -318,7 +333,7 @@ function install_dlpack() {
318333 rm -rf * || exit 1
319334 VERBOSE=${VERBOSE} ${CMAKE_VERSION} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_C_COMPILER=${CC} -DCMAKE_CXX_COMPILER=${CXX} ..
320335 fi
321- VERBOSE= ${VERBOSE} make -j $CORES -s || exit 1
336+ make -j $CORES -s || exit 1
322337
323338 set_cache .. .build_cache
324339 set_bcache ${TC_DIR} /third-party/dlpack ${TC_DIR} /third-party/.dlpack_build_cache
@@ -332,7 +347,14 @@ function install_dlpack() {
332347}
333348
334349function 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
336358}
337359
338360function install_tc_python() {
@@ -393,8 +415,8 @@ function install_tc() {
393415 fi
394416
395417 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
398420
399421 install_tc_python
400422
0 commit comments