-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·159 lines (157 loc) · 3.91 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
#!/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=""
spack_dev=0
spack_env="coekenv"
spack_home=`pwd`/_spack
spack_reinstall=0
with_python="OFF"
with_scip=""
scip_config="OFF"
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]"
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
;;
*)
echo "unknown option: $1"
exit
;;
esac
done
#
# 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 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
\rm -Rf _build
#
# 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 https://github.com/spack/spack.git ${SPACK_HOME}
. ${SPACK_HOME}/share/spack/setup-env.sh
echo "Adding _spack_tpls"
spack repo remove `pwd`/_spack_tpls/repo | true
spack repo add `pwd`/_spack_tpls/repo
spack repo list
spack env create $spack_env
spack env activate $spack_env
spack compiler find
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 "SPACK_HOME=${SPACK_HOME}"
fi
#
# Install coek
#
echo "Building Coek"
echo ""
mkdir _build
cd _build
cmake -DCMAKE_PREFIX_PATH=${SPACK_HOME}/var/spack/environments/${spack_env}/.spack-env/view -Dwith_debug=${debug} -Dwith_python=${with_python} -Dwith_pybind11=${with_python} $python_exe -Dwith_gurobi=$with_gurobi -Dwith_highs=ON -Dwith_cppad=OFF -Dwith_fmtlib=ON -Dwith_rapidjson=ON -Dwith_catch2=ON -Dwith_tests=ON -Dwith_asl=ON -Dwith_openmp=OFF -Dwith_compact=${compact} ..
make -j20
make install