-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·102 lines (85 loc) · 2.01 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
#!/usr/bin/env bash
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
git submodule update --recursive --init
if [ -f "build/CMakeCache.txt" ] ; then
RUN_CMAKE=false
else
RUN_CMAKE=true
fi
BUILD_GUI_VIEWERS=ON
builder_args=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--force-cmake)
shift # past argument
RUN_CMAKE=true
;;
--headless)
shift
BUILD_GUI_VIEWERS=OFF
;;
--run-tests)
shift
RUN_TESTS=true
;;
*) # Forward unknown args to builder
shift
builder_args+=("$key")
;;
esac
done
if [ -f "build/CMakeCache.txt" ] ; then
current_value=$(cat "build/CMakeCache.txt" | grep BUILD_GUI_VIEWERS:BOOL)
if ! [ "$current_value" = "BUILD_GUI_VIEWERS:BOOL=${BUILD_GUI_VIEWERS}" ] ; then
RUN_CMAKE=true
fi
fi
mkdir -p build
cd build
cmake_args=()
cmake_args+=('-DBUILD_TEST=1')
cmake_args+=('-DCMAKE_EXPORT_COMPILE_COMMANDS=ON')
cmake_args+=('-DBUILD_GUI_VIEWERS='${BUILD_GUI_VIEWERS})
# devfair/learnfair custom stuff: EGL path, and module loads
my_hostname=`hostname`
if [[ $my_hostname =~ "fair" ]]; then
module purge
module load anaconda3/5.0.1
module load cuda/9.0
module load cudnn/v7.0-cuda.9.0
module load gcc/7.1.0
module load cmake/3.10.1/gcc.5.4.0
fi
# use ninja build if ninja is available
if hash ninja 2>/dev/null; then
cmake_args+=('-GNinja')
fi
if [ "$RUN_CMAKE" = true ] ; then
cmake "${cmake_args[@]}" \
../src
fi
if hash ninja 2>/dev/null; then
ninja "${builder_args[@]}"
else
make "${builder_args[@]}"
fi
if [ "$RUN_TESTS" = true ] ; then
cd ..
echo "Running tests..."
TEST_SCRIPTS=$(find "build/tests" -type f -perm +111)
declare -i RET_VAL=0
for test_script in $TEST_SCRIPTS ; do
echo "Running $test_script"
$test_script
RET_VAL+=$?
done
if [ "$RET_VAL" -ne 0 ] ; then
echo "Some tests failed."
else
echo "All tests passed."
fi
fi