Skip to content

Commit c75fd1a

Browse files
committed
Reworking build.sh options
1. Adding --spack-home option, which specifies the directory of a Spack installation and defines SPACK_HOME. 2. Reworking loop to process options.
1 parent 7112e62 commit c75fd1a

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

Diff for: build.sh

+22-8
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,36 @@ with_python="OFF"
99
spack_reinstall=0
1010
spack_dev=0
1111
clang=0
12-
for arg ; do
13-
case "$arg" in
12+
spack_home=`pwd`/_spack
13+
while [[ $# -gt 0 ]]; do
14+
case $1 in
1415
--help)
15-
echo "build.sh [--python] [--clang] [--spack-reinstall] [--spack-dev] [--help]"
16+
echo "build.sh [--python] [--clang] [--spack-reinstall] [--spack-dev] [--spack-home <dir>] [--help]"
1617
exit
1718
;;
1819
--python)
1920
with_python="ON"
21+
shift
2022
;;
2123
--clang)
2224
clang=1
25+
shift
2326
;;
2427
--spack-reinstall)
2528
spack_reinstall=1
29+
shift
2630
;;
2731
--spack-dev)
2832
spack_dev=1
33+
shift
34+
;;
35+
--spack-home)
36+
spack_home="$2"
37+
shift
38+
shift
2939
;;
3040
*)
31-
echo "unknown option: ${arg}"
41+
echo "unknown option: $1"
3242
exit
3343
;;
3444
esac
@@ -37,10 +47,10 @@ done
3747
#
3848
# Setup directories
3949
#
40-
export SPACK_HOME=`pwd`/_spack
50+
export SPACK_HOME=${spack_home}
4151
echo "SPACK_HOME=${SPACK_HOME}"
4252
if [[ "${spack_reinstall}" -eq 1 ]]; then
43-
rm -Rf ${SPACK_HOME}
53+
\rm -Rf ${SPACK_HOME}
4454
fi
4555
\rm -Rf _build
4656
#
@@ -70,9 +80,9 @@ else
7080
echo "Installing Coek dependencies using Spack"
7181
echo ""
7282
if [[ "$spack_dev" -eq 0 ]]; then
73-
git clone https://github.com/or-fusion/spack.git _spack
83+
git clone https://github.com/or-fusion/spack.git ${SPACK_HOME}
7484
else
75-
git clone [email protected]:or-fusion/spack.git _spack
85+
git clone [email protected]:or-fusion/spack.git ${SPACK_HOME}
7686
fi
7787
. ${SPACK_HOME}/share/spack/setup-env.sh
7888
spack env create coekenv
@@ -81,6 +91,10 @@ else
8191
spack install
8292
spack env deactivate
8393
fi
94+
if test -d ${SPACK_HOME}; then
95+
export SPACK_HOME=$(cd ${SPACK_HOME}; pwd)
96+
echo "SPACK_HOME=${SPACK_HOME}"
97+
fi
8498
#
8599
# Install coek
86100
#

0 commit comments

Comments
 (0)