forked from nest/nest-extension-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·101 lines (87 loc) · 3.04 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
#!/bin/bash
# build.sh
#
# This file is part of the NEST example module.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
# This shell script is part of the NEST example module Github Actions build
# and test environment. It is invoked by the top-level script '.github/workflows/build.yml'.
#
# Exit shell if any subcommand or pipline returns a non-zero status.
set -e
# We need to do this, because update-alternatives is not available on MacOS
if [ "$xNEST_BUILD_COMPILER" = "CLANG" ]; then
export CC=clang-11
export CXX=clang++-11
fi
if [ "$(uname -s)" = 'Linux' ]; then
CONFIGURE_MPI="-Dwith-mpi=ON"
CONFIGURE_OPENMP="-Dwith-openmp=ON"
else
CONFIGURE_MPI="-Dwith-mpi=OFF"
CONFIGURE_OPENMP="-Dwith-openmp=OFF"
fi
SOURCEDIR=$PWD
echo "SOURCEDIR = $SOURCEDIR"
cd ..
# Install current NEST version.
git clone https://github.com/nest/nest-simulator.git
cd nest-simulator
PYTHON_INCLUDE_DIR=`python3 -c "import sysconfig; print(sysconfig.get_path('include'))"`
PYLIB_BASE=lib`basename $PYTHON_INCLUDE_DIR`
PYLIB_DIR=$(dirname `sed 's/include/lib/' <<< $PYTHON_INCLUDE_DIR`)
PYTHON_LIBRARY=`find $PYLIB_DIR \( -name $PYLIB_BASE.so -o -name $PYLIB_BASE.dylib \) -print -quit`
echo "--> Detected PYTHON_LIBRARY=$PYTHON_LIBRARY"
echo "--> Detected PYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR"
# Explicitly allow MPI oversubscription. This is required by Open MPI versions > 3.0.
# Not having this in place leads to a "not enough slots available" error.
cp extras/nestrc.sli ~/.nestrc
sed -i -e 's/mpirun -np/mpirun --oversubscribe -np/g' ~/.nestrc
NEST_RESULT=result
if [ "$(uname -s)" = 'Linux' ]; then
NEST_RESULT=$(readlink -f $NEST_RESULT)
else
NEST_RESULT=$(greadlink -f $NEST_RESULT)
fi
mkdir "$NEST_RESULT"
echo "NEST_RESULT = $NEST_RESULT"
mkdir build && cd build
cmake \
-Dwith-optimize=ON -Dwith-warning=ON \
$CONFIGURE_MPI \
$CONFIGURE_OPENMP \
-DPYTHON_LIBRARY=$PYTHON_LIBRARY \
-DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DCMAKE_INSTALL_PREFIX=$NEST_RESULT\
..
VERBOSE=1 make -j 2
make install
cd $SOURCEDIR
mkdir build && cd build
cmake \
-Dwith-optimize=ON -Dwith-warning=ON \
-Dwith-nest=$NEST_RESULT/bin/nest-config \
$CONFIGURE_MPI \
$CONFIGURE_OPENMP \
-DPYTHON_LIBRARY=$PYTHON_LIBRARY \
-DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DCMAKE_INSTALL_PREFIX=$NEST_RESULT \
..
VERBOSE=1 make -j 2
make install
. $NEST_RESULT/bin/nest_vars.sh
python -c 'import nest; nest.Install("mymodule")'
exit $?