-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·191 lines (188 loc) · 4.88 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
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
#!/bin/bash -e
#
# This scripts builds Coek in the `_build` directory to support local
# development and debugging.
#
# This uses Spack to install third-party dependencies in the `_spack` directory.
#
clang=0
compact="OFF"
debug="OFF"
python_exe=""
scip_config="OFF"
spack_dev=0
spack_env="coekenv"
spack_home=`pwd`/_spack
spack_reinstall=0
with_asl="ON"
with_catch="ON"
with_fmtlib="ON"
with_highs="ON"
with_python="OFF"
with_rapidjson="ON"
with_scip=""
with_spack=0
with_valgrind=""
while [[ $# -gt 0 ]]; do
case $1 in
--help)
echo "build.sh [--help] [--clang] [--compact] [--debug] [--python] [--python-exe <file>] [--scip] [--spack-dev] [--spack-env <env>] [--spack-home <dir>] [--spack-reinstall] [--valgrind] [--with-spack]"
exit
;;
--clang)
clang=1
shift
;;
--compact)
compact="ON"
shift
;;
--debug)
debug="ON"
shift
;;
--spack-env)
spack_env="$2"
shift
shift
;;
--python)
with_python="ON"
shift
;;
--python-exe)
python_exe="-DPython_EXECUTABLE=$2"
shift
;;
--scip)
with_scip="scip"
scip_config="ON"
shift
;;
--spack-dev)
spack_dev=1
shift
;;
--spack-home)
spack_home="$2"
shift
shift
;;
--spack-reinstall)
spack_reinstall=1
shift
;;
--valgrind)
with_valgrind="valgrind"
shift
;;
--with-spack)
with_spack=1
shift
;;
*)
echo "unknown option: $1"
exit
;;
esac
done
if [[ "$with_spack" -eq 1 ]]; then
#
# Setup directories
#
export SPACK_HOME=${spack_home}
echo "SPACK_HOME=${SPACK_HOME}"
if [[ "${spack_reinstall}" -eq 1 ]]; then
\rm -Rf ${SPACK_HOME}
fi
if test -d _spack_tpls; then
cd _spack_tpls
git pull
cd ..
else
if [[ "$spack_dev" -eq 0 ]]; then
\rm -Rf _spack_tpls
git clone --depth 1 https://github.com/or-fusion/or-fusion-spack-repo.git _spack_tpls
else
git clone git@github.com:or-fusion/or-fusion-spack-repo.git _spack_tpls
cd _spack_tpls
git checkout dev
git pull
cd ..
fi
fi
#
# Configure gurobi
#
if [[ -z "${GUROBI_HOME}" ]]; then
with_gurobi="OFF"
else
with_gurobi="ON"
fi
#
# Configure clang
#
if [[ $clang -eq 1 ]]; then
export CXX=clang++
export CC=clang
fi
#
# Install spack
#
if test -d ${SPACK_HOME}; then
echo ""
echo "WARNING: Spack directory exists."
echo ""
else
echo ""
echo "Installing Coek dependencies using Spack"
echo ""
git clone --depth 1 https://github.com/spack/spack.git ${SPACK_HOME}
. ${SPACK_HOME}/share/spack/setup-env.sh
echo ""
echo "Removing _spack_tpls"
echo ""
spack repo remove `pwd`/_spack_tpls/repo | true
echo ""
echo "Adding _spack_tpls"
echo ""
spack repo add `pwd`/_spack_tpls/repo
spack repo list
spack external find
spack compiler find
spack env create $spack_env
spack env activate $spack_env
spack add asl fmt@8.0.1 rapidjson catch2 highs $with_valgrind $with_scip
spack install
spack env deactivate
spack repo remove `pwd`/_spack_tpls/repo
fi
if test -d ${SPACK_HOME}; then
export SPACK_HOME=$(cd ${SPACK_HOME}; pwd)
echo ""
echo "SPACK_HOME=${SPACK_HOME}"
echo ""
fi
spack_cmake_options="-DCMAKE_PREFIX_PATH=${SPACK_HOME}/var/spack/environments/${spack_env}/.spack-env/view"
else
spack_cmake_options=""
with_python="OFF"
python_exe=""
with_gurobi="OFF"
with_highs="OFF"
with_fmtlib="OFF"
with_rapidjson="OFF"
with_catch="OFF"
with_asl="OFF"
fi
#
# Install coek
#
echo "Building Coek"
echo ""
\rm -Rf _build
mkdir _build
cd _build
cmake $spack_cmake_options -Dwith_debug=${debug} -Dwith_python=${with_python} -Dwith_pybind11=${with_python} $python_exe -Dwith_gurobi=$with_gurobi -Dwith_highs=$with_highs -Dwith_cppad=OFF -Dwith_fmtlib=$with_fmtlib -Dwith_rapidjson=$with_rapidjson -Dwith_catch2=$with_catch -Dwith_tests=$with_catch -Dwith_asl=$with_asl -Dwith_openmp=OFF -Dwith_compact=${compact} ..
make -j20
make install