forked from nest/nest-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
183 lines (154 loc) · 4.3 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
#!/bin/sh
set -e
set -x
mkdir -p $HOME/.matplotlib
cat > $HOME/.matplotlib/matplotlibrc <<EOF
# ZYV
backend : svg
EOF
if [ "$xMPI" = "1" ] ; then
cat > $HOME/.nestrc <<EOF
% ZYV: NEST MPI configuration
/mpirun
[/integertype /stringtype]
[/numproc /slifile]
{
() [
(mpirun -np ) numproc cvs ( ) statusdict/prefix :: (/bin/nest ) slifile
] {join} Fold
} Function def
EOF
CONFIGURE_MPI="--with-mpi"
else
CONFIGURE_MPI="--without-mpi"
fi
if [ "$xPYTHON" = "1" ] ; then
CONFIGURE_PYTHON="--with-python"
else
CONFIGURE_PYTHON="--without-python"
fi
if [ "$xGSL" = "1" ] ; then
CONFIGURE_GSL="--with-gsl"
else
CONFIGURE_GSL="--without-gsl"
fi
./bootstrap.sh
NEST_VPATH=build
NEST_RESULT=result
mkdir "$NEST_VPATH" "$NEST_RESULT"
mkdir "$NEST_VPATH/reports"
NEST_RESULT=$(readlink -f $NEST_RESULT)
# static code analysis
# initialize vera++
mkdir -p vera_home
# on ubuntu vera++ is installed to /usr/
# copy all scripts/rules/ ... into ./vera_home
cp -r /usr/lib/vera++/* ./vera_home
# create the nest-profile for vera++
cat > ./vera_home/profiles/nest <<EOF
#!/usr/bin/tclsh
# This profile includes all the rules for checking NEST
set rules {
F001
F002
L001
L002
L003
L005
L006
T001
T002
T004
T005
T006
T007
T010
T011
T012
T013
T017
T018
T019
}
EOF
# initialize and build cppcheck 1.69
git clone https://github.com/danmar/cppcheck.git
# go into source directory of cppcheck
cd cppcheck
# set git to 1.69 version
git checkout tags/1.69
# build cppcheck => now there is an executable ./cppcheck
mkdir -p install
make PREFIX=$PWD/install CFGDIR=$PWD/install/cfg HAVE_RULES=yes install
# make cppcheck available
export PATH=$PATH:$PWD/install/bin
# check everything is alright
cppcheck --version
# go back to NEST sources
cd ..
# Extracting changed files in PR / push
echo "Extract changed files..."
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
file_names=`curl "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/files" | jq '.[] | .filename' | tr '\n' ' ' | tr '"' ' '`
else
# extract filenames via git => has some problems with history rewrites
# see https://github.com/travis-ci/travis-ci/issues/2668
file_names=`(git diff --name-only $TRAVIS_COMMIT_RANGE || echo "") | tr '\n' ' '`
fi
format_error_files=""
for f in $file_names; do
if [ ! -f "$f" ]; then
echo "$f : Is not a file or does not exist anymore."
continue
fi
# filter files
case $f in
*.h | *.c | *.cc | *.hpp | *.cpp )
echo "Static analysis on file $f:"
f_base=$NEST_VPATH/reports/`basename $f`
# Vera++ checks the specified list of rules given in the profile
# nest which is placed in the <vera++ root>/lib/vera++/profile
vera++ --root ./vera_home --profile nest $f > ${f_base}_vera.txt 2>&1
echo "\n - vera++ for $f:"
cat ${f_base}_vera.txt
cppcheck --enable=all --inconclusive --std=c++03 $f > ${f_base}_cppcheck.txt 2>&1
echo "\n - cppcheck for $f:"
cat ${f_base}_cppcheck.txt
# clang format creates tempory formatted file
clang-format-3.6 $f > ${f_base}_formatted_$TRAVIS_COMMIT.txt
# compare the committed file and formatted file and
# writes the differences to a temp file
echo "\n - clang-format for $f:"
diff $f ${f_base}_formatted_$TRAVIS_COMMIT.txt | tee ${f_base}_clang_format.txt
cat ${f_base}_clang_format.txt
# remove temporary files
rm ${f_base}_formatted_$TRAVIS_COMMIT.txt
if [ -s ${f_base}_clang_format.txt ]; then
# file exists and has size greater than zero
format_error_files="$format_error_files $f"
fi
;;
*)
echo "$f : not a C/CPP file. Do not do static analysis / formatting checking."
continue
esac
done
# Remove cppcheck files, otherwise 'regressiontests/ticket-659-copyright.py' will complain
rm -rf ./cppcheck
cd "$NEST_VPATH"
../configure \
--prefix="$NEST_RESULT" CC=mpicc CXX=mpic++ \
$CONFIGURE_MPI \
$CONFIGURE_PYTHON \
$CONFIGURE_GSL \
make
make install
make installcheck
if [ "$format_error_files" != "" ]; then
echo "There are files with a formatting error: $format_error_files ."
exit 42
fi
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "WARNING: Not uploading results as this is a pull request" >&2
exit 0
fi