forked from Exawind/exawind-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·200 lines (167 loc) · 5.1 KB
/
bootstrap.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
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
exw_show_help ()
{
cat <<EOF
$(basename ${BASH_SOURCE[0]}) [options]
Options:
-h - Show help message and exit
-s <system> - Select system profile (spack, cori, summitdev, etc.)
-c <compiler> - Select compiler type (gcc, clang, intel, etc.)
-p <path> - Root path for exawind project (default: ${HOME}/exawind)
EOF
}
exw_check_system ()
{
local envdir=${EXAWIND_PROJECT_DIR}/exawind-builder/envs
local sys_file=${envdir}/${EXAWIND_SYSTEM}.bash
if [ ! -f ${sys_file} ] ; then
echo "ERROR! Unknown system provided. Valid options are"
for fname in $(ls $envdir) ; do
echo " - $(basename -s .bash $fname)"
done
return 1
fi
return 0
}
exw_init ()
{
export EXAWIND_PROJECT_DIR=${EXAWIND_PROJECT_DIR:-${HOME}/exawind}
local basedir=${EXAWIND_PROJECT_DIR}
if [ ! -d ${basedir} ] ; then
echo "==> Creating project structure in ${EXAWIND_PROJECT_DIR}"
mkdir -p ${basedir}
mkdir -p ${basedir}/{install,scripts,source}
fi
cd ${basedir}
if [ ! -d exawind-builder ] ; then
git clone [email protected]:sayerhs/exawind-builder.git
fi
}
exw_init_spack ()
{
local basedir=${EXAWIND_PROJECT_DIR:-$(pwd)}
local ewblddir=${basedir}/exawind-builder
local exwsys=${EXAWIND_SYSTEM:-spack}
if [ "$(uname)" = "Darwin" ] ; then
exwsys=osx
fi
cd ${basedir}
# Bail out if this is not our known directory structure
if [ ! -d ${ewblddir} ] ; then
echo "!!ERROR!! Please execute command from exawind project directory"
exit 1
fi
local need_setup=no
if [ ! -d spack ] ; then
git clone [email protected]:LLNL/spack.git
need_setup=yes
fi
if [ "${need_setup}" = "yes" ] ; then
echo "==> Setting up spack compiler and package settings"
local have_packages_yaml=no
local have_compiler_yaml=no
if [ -d ${ewblddir}/etc/spack/${exwsys} ] ; then
local cfgdir=${ewblddir}/etc/spack/${exwsys}
if [ -f ${cfgdir}/packages.yaml ] ; then
ln -s ${cfgdir}/packages.yaml spack/etc/spack/
have_packages_yaml=yes
fi
if [ -f ${cfgdir}/compilers.yaml ] ; then
ln -s ${cfgdir}/compilers.yaml spack/etc/spack/
have_compiler_yaml=yes
fi
fi
if [ "${have_packages_yaml}" = "no" ] ; then
ln -s ${ewblddir}/etc/spack/spack/packages.yaml spack/etc/spack
fi
fi
source spack/share/spack/setup-env.sh
if [ "${need_setup}" = "yes" -a "${have_compiler_yaml}" = "no" ] ; then
spack compiler find
fi
}
exw_install_deps ()
{
local basedir=${EXAWIND_PROJECT_DIR}
cd ${basedir}
spack install cmake %${EXAWIND_COMPILER}
spack install mpi %${EXAWIND_COMPILER}
spack install m4 %${EXAWIND_COMPILER}
spack install zlib %${EXAWIND_COMPILER}
spack install libxml2 %${EXAWIND_COMPILER}
spack install boost %${EXAWIND_COMPILER}
spack install superlu %${EXAWIND_COMPILER}
spack install hdf5 %${EXAWIND_COMPILER}
spack install netcdf %${EXAWIND_COMPILER}
spack install yaml-cpp %${EXAWIND_COMPILER}
spack install hypre %${EXAWIND_COMPILER}
}
exw_create_scripts ()
{
local exwbld=${EXAWIND_PROJECT_DIR}/exawind-builder
cd ${EXAWIND_PROJECT_DIR}/scripts
echo "==> Creating build scripts for known projects"
for fname in $(ls ${exwbld}/codes) ; do
local prj=$(basename -s .bash $fname)
${exwbld}/new-script.sh -s ${EXAWIND_SYSTEM} -c ${EXAWIND_COMPILER} -p ${prj}
done
}
exw_create_config ()
{
if [ -f ${EXAWIND_PROJECT_DIR}/exawind-config.sh ] ; then
return
fi
echo "==> Creating default config file: ${EXAWIND_PROJECT_DIR}/exawind-config.sh"
cat <<EOF > ${EXAWIND_PROJECT_DIR}/exawind-config.sh
export SPACK_ROOT=${EXAWIND_PROJECT_DIR}/spack
export TRILINOS_ROOT_DIR=${EXAWIND_INSTALL_DIR}/trilinos
export TIOGA_ROOT_DIR=${EXAWIND_INSTALL_DIR}/tioga
BUILD_TYPE=RELEASE
ENABLE_OPENMP=OFF
ENABLE_OPENFAST=OFF
ENABLE_TIOGA=OFF
ENABLE_HYPRE=ON
EOF
}
exw_main ()
{
export EXAWIND_PROJECT_DIR=${EXAWIND_PROJECT_DIR:-${HOME}/exawind}
export EXAWIND_SYSTEM=${EXAWIND_SYSTEM:-spack}
local exwcomp=gcc
if [ "$(uname)" = "Darwin" ] ; then
exwcomp=clang
elif [ "${EXAWIND_SYSTEM}" = "cori" ] ; then
exwcomp=intel
fi
export EXAWIND_COMPILER=${EXAWIND_COMPILER:-$exwcomp}
OPTIND=1
while getopts ":s:c:p:h" opt; do
case "$opt" in
h)
exw_show_help
exit 0
;;
s)
EXAWIND_SYSTEM=$OPTARG
;;
c)
EXAWIND_COMPILER=$OPTARG
;;
p)
EXAWIND_PROJECT_DIR=$OPTARG
;;
\?)
echo "ERROR: Invalid argument provided"
exw_show_help
exit 1
;;
esac
done
exw_init
exw_check_system || exit 1
exw_init_spack
exw_install_deps
exw_create_scripts
exw_create_config
}
exw_main "$@"