-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·151 lines (134 loc) · 4.38 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·151 lines (134 loc) · 4.38 KB
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
#!/usr/bin/env bash
ORIG_INPUT_PARAMS="$@"
params="$(getopt -o d:hctpg -l directory:,help,clean,torch,python,global,with-cuda,with-deps --name "$(basename "$0")" -- "$@")"
if [ $? -ne 0 ]
then
print_usage
fi
print_usage() {
printf "bash $0 [-h|--help] [-d|--directory <workspace directory>] [-p|--python] [--with-cuda] [--with-deps] [-g|--global] [-c|--clean] [-t|--torch]\n"
printf "Options:\n"
printf " -h, --help : Prints this help message\n"
printf " -d, --directory <workspace directory> : Builds and installs the package in the specified directory\n"
printf " -p, --python : Installs the python bindings\n"
printf " --with-cuda : Builds the package with CUDA support\n"
printf " --with-deps : Installs the dependencies\n"
printf " -g, --global : Installs the package globally. Needs sudo permissions\n"
}
# Get directory of script
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
WITH_TORCH=0
eval set -- "$params"
unset params
INSTALL=true
while true; do
case ${1} in
-h|--help) print_usage; exit 0;;
-c|--clean) CLEAN=true;INSTALL=false;shift;;
-t|--torch) WITH_TORCH=ON; shift;;
-p|--python) WITH_PYTHON=true;shift;;
-d|--directory) WS_DIR+=("${2}");shift 2;;
-g|--global) GLOBAL=true;shift;;
--with-cuda) WITH_CUDA=ON;shift;;
--with-deps) WITH_DEPS=true;shift;;
--) shift;break;;
*) print_usage
exit 1 ;;
esac
done
# Add CMAKE_BUILD_TYPE RelWithDebInfo
CMAKE_END_FLAGS="${CMAKE_END_FLAGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo"
if [[ ${WS_DIR} ]]
then
BUILD_DIR=${WS_DIR}/build/
# If not global then install to workspace
if [[ ! ${GLOBAL} ]]
then
INSTALL_DIR=${WS_DIR}/install/
CMAKE_END_FLAGS="${CMAKE_END_FLAGS} -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}"
fi
else
TMP_DIR=$(mktemp -d)
BUILD_DIR=${TMP_DIR}/build
fi
# Check WITH_CUDA
if [[ ${WITH_CUDA} == "ON" ]]
then
CMAKE_END_FLAGS="${CMAKE_END_FLAGS} -DWITH_CUDA=ON"
else
CMAKE_END_FLAGS="${CMAKE_END_FLAGS}"
fi
if [[ ${WITH_TORCH} == "ON" ]]
then
CMAKE_END_FLAGS="${CMAKE_END_FLAGS} -DCMAKE_PREFIX_PATH=${Torch_DIR}"
fi
InstallCoverageControl () {
export CGAL_DISABLE_GMP=ON
export CGAL_DISABLE_GMP=1; cmake -S ${DIR}/core -B ${BUILD_DIR}/CoverageControl ${CMAKE_END_FLAGS}
cmake --build ${BUILD_DIR}/CoverageControl -j$(nproc)
if [ $? -ne 0 ]; then
echo "CoverageControl build failed"
exit 1
fi
cmake --install ${BUILD_DIR}/CoverageControl
if [ $? -ne 0 ]; then
echo "CoverageControl install failed"
fi
echo "Successfully built and installed CoverageControl"
}
InstallCoverageControlTorch () {
cmake -S ${DIR}/torch -B ${BUILD_DIR}/CoverageControlTorch ${CMAKE_END_FLAGS}
cmake --build ${BUILD_DIR}/CoverageControlTorch -j$(nproc)
if [ $? -ne 0 ]; then
echo "CoverageControlTorch build failed"
exit 1
fi
cmake --install ${BUILD_DIR}/CoverageControlTorch
if [ $? -ne 0 ]; then
echo "CoverageControlTorch install failed"
exit 1
fi
echo "Successfully built and installed CoverageControlTorch"
}
InstallCoverageControlTests () {
cmake -S ${DIR}/tests -B ${BUILD_DIR}/CoverageControlTests ${CMAKE_END_FLAGS} -DWITH_TORCH=${WITH_TORCH}
cmake --build ${BUILD_DIR}/CoverageControlTests -j$(nproc)
if [ $? -ne 0 ]; then
echo "CoverageControlTests build failed"
exit 1
fi
cmake --install ${BUILD_DIR}/CoverageControlTests
if [ $? -ne 0 ]; then
echo "CoverageControlTests install failed"
exit 1
fi
echo "Successfully built and installed CoverageControlTests"
}
InstallCoverageControlMain () {
cmake -S ${DIR}/main -B ${BUILD_DIR}/CoverageControlMain ${CMAKE_END_FLAGS} -DWITH_TORCH=${WITH_TORCH}
cmake --build ${BUILD_DIR}/CoverageControlMain -j$(nproc)
if [ $? -ne 0 ]; then
echo "CoverageControlMain build failed"
exit 1
fi
cmake --install ${BUILD_DIR}/CoverageControlMain
if [ $? -ne 0 ]; then
echo "CoverageControlMain install failed"
fi
echo "Successfully built and installed CoverageControlMain"
}
if [[ ${INSTALL} ]]
then
echo "Installing CoverageControl"
InstallCoverageControl
if [[ ${WITH_TORCH} == "ON" ]]
then
echo "Installing CoverageControlTorch"
InstallCoverageControlTorch
fi
# echo "Installing CoverageControlTests"
# InstallCoverageControlTests
echo "Installing CoverageControlMain"
InstallCoverageControlMain
fi