Commit | Line | Data |
---|---|---|
3c85b52d | 1 | #!/bin/bash -exu |
b4005bbf | 2 | # |
3c85b52d | 3 | # Copyright (C) 2016 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
b4005bbf MJ |
4 | # Michael Jeanson <mjeanson@efficios.com> |
5 | # | |
6 | # This program is free software: you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation, either version 3 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
0cdaa21c | 19 | # Version compare functions |
b6e62a6a MJ |
20 | vercomp () { |
21 | set +u | |
22 | if [[ "$1" == "$2" ]]; then | |
23 | return 0 | |
24 | fi | |
25 | local IFS=. | |
26 | local i ver1=($1) ver2=($2) | |
27 | # fill empty fields in ver1 with zeros | |
28 | for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do | |
29 | ver1[i]=0 | |
30 | done | |
31 | for ((i=0; i<${#ver1[@]}; i++)); do | |
32 | if [[ -z ${ver2[i]} ]]; then | |
33 | # fill empty fields in ver2 with zeros | |
34 | ver2[i]=0 | |
35 | fi | |
36 | if ((10#${ver1[i]} > 10#${ver2[i]})); then | |
37 | return 1 | |
38 | fi | |
39 | if ((10#${ver1[i]} < 10#${ver2[i]})); then | |
40 | return 2 | |
41 | fi | |
42 | done | |
43 | set -u | |
44 | return 0 | |
45 | } | |
46 | ||
0cdaa21c | 47 | verlte() { |
b6e62a6a MJ |
48 | vercomp "$1" "$2"; local res="$?" |
49 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
0cdaa21c MJ |
50 | } |
51 | ||
52 | verlt() { | |
b6e62a6a MJ |
53 | vercomp "$1" "$2"; local res="$?" |
54 | [ "$res" -eq "2" ] | |
0cdaa21c MJ |
55 | } |
56 | ||
57 | vergte() { | |
b6e62a6a MJ |
58 | vercomp "$1" "$2"; local res="$?" |
59 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
0cdaa21c MJ |
60 | } |
61 | ||
62 | vergt() { | |
b6e62a6a MJ |
63 | vercomp "$1" "$2"; local res="$?" |
64 | [ "$res" -eq "1" ] | |
65 | } | |
66 | ||
67 | verne() { | |
68 | vercomp "$1" "$2"; local res="$?" | |
69 | [ "$res" -ne "0" ] | |
0cdaa21c MJ |
70 | } |
71 | ||
b4005bbf MJ |
72 | |
73 | # Create build directory | |
b6e62a6a MJ |
74 | rm -rf "$WORKSPACE/build" |
75 | mkdir -p "$WORKSPACE/build" | |
b4005bbf MJ |
76 | |
77 | # liburcu | |
78 | URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" | |
79 | URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" | |
80 | ||
81 | # lttng-ust | |
82 | UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/" | |
83 | UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/" | |
95654431 | 84 | UST_JAVA="$WORKSPACE/deps/lttng-ust/build/share/java/" |
b4005bbf MJ |
85 | |
86 | # babeltrace | |
87 | BABEL_INCS="$WORKSPACE/deps/babeltrace/build/include/" | |
88 | BABEL_LIBS="$WORKSPACE/deps/babeltrace/build/lib/" | |
89 | BABEL_BINS="$WORKSPACE/deps/babeltrace/build/bin/" | |
90 | ||
91 | PREFIX="$WORKSPACE/build" | |
92 | ||
0cdaa21c MJ |
93 | # Set platform variables |
94 | case "$arch" in | |
95 | solaris10) | |
96 | MAKE=gmake | |
97 | TAR=gtar | |
98 | NPROC=gnproc | |
99 | BISON="bison" | |
100 | YACC="$BISON -y" | |
101 | CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" | |
102 | RUN_TESTS="no" | |
103 | ;; | |
104 | ||
105 | solaris11) | |
106 | MAKE=gmake | |
107 | TAR=gtar | |
108 | NPROC=nproc | |
109 | BISON="/opt/csw/bin/bison" | |
110 | YACC="$BISON -y" | |
111 | CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" | |
112 | RUN_TESTS="no" | |
113 | ||
114 | export PATH="$PATH:/usr/perl5/bin" | |
115 | ;; | |
116 | ||
b6e62a6a MJ |
117 | macosx) |
118 | MAKE=make | |
119 | TAR=tar | |
120 | NPROC="getconf _NPROCESSORS_ONLN" | |
121 | BISON="bison" | |
122 | YACC="$BISON -y" | |
123 | RUN_TESTS="no" | |
124 | ||
125 | export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
126 | export CFLAGS="-I/opt/local/include" | |
127 | export LDFLAGS="-L/opt/local/lib" | |
128 | ;; | |
129 | ||
0cdaa21c MJ |
130 | *) |
131 | MAKE=make | |
132 | TAR=tar | |
133 | NPROC=nproc | |
134 | BISON="bison" | |
135 | YACC="$BISON -y" | |
136 | CFLAGS="" | |
137 | RUN_TESTS="yes" | |
138 | ||
139 | PYTHON2=python2 | |
140 | PYTHON3=python3 | |
141 | ||
142 | P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])") | |
143 | P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])") | |
144 | ||
145 | UST_PYTHON2="$WORKSPACE/deps/lttng-ust/build/lib/python$P2_VERSION/site-packages" | |
146 | UST_PYTHON3="$WORKSPACE/deps/lttng-ust/build/lib/python$P3_VERSION/site-packages" | |
147 | ;; | |
148 | esac | |
149 | ||
150 | ||
151 | # Run bootstrap prior to configure | |
152 | ./bootstrap | |
153 | ||
154 | # Get source version from configure script | |
155 | eval `grep '^PACKAGE_VERSION=' ./configure` | |
b6e62a6a | 156 | PACKAGE_VERSION=`echo "$PACKAGE_VERSION"| sed 's/\-pre$//'` |
0cdaa21c MJ |
157 | |
158 | ||
159 | # Export build flags | |
160 | case "$conf" in | |
161 | no-ust) | |
b4005bbf MJ |
162 | export CPPFLAGS="-I$URCU_INCS" |
163 | export LDFLAGS="-L$URCU_LIBS" | |
164 | export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}" | |
0cdaa21c MJ |
165 | ;; |
166 | ||
167 | *) | |
b4005bbf MJ |
168 | export CPPFLAGS="-I$URCU_INCS -I$UST_INCS" |
169 | export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS" | |
170 | export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}" | |
0cdaa21c MJ |
171 | ;; |
172 | esac | |
b4005bbf | 173 | |
0cdaa21c MJ |
174 | # The switch to build without UST changed in 2.8 |
175 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
176 | NO_UST="--without-lttng-ust" | |
177 | else | |
178 | NO_UST="--disable-lttng-ust" | |
179 | fi | |
b4005bbf | 180 | |
0cdaa21c | 181 | # Set configure options for each build configuration |
b4005bbf MJ |
182 | CONF_OPTS="" |
183 | case "$conf" in | |
0cdaa21c MJ |
184 | static) |
185 | echo "Static build" | |
186 | CONF_OPTS="--enable-static --disable-shared" | |
187 | ;; | |
188 | ||
189 | python-bindings) | |
190 | echo "Build with python bindings" | |
191 | # We only support bindings built with Python 3 | |
192 | export PYTHON="python3" | |
193 | export PYTHON_CONFIG="/usr/bin/python3-config" | |
194 | CONF_OPTS="--enable-python-bindings" | |
195 | ;; | |
196 | ||
197 | no-ust) | |
198 | echo "Build without UST support" | |
199 | CONF_OPTS="$NO_UST" | |
200 | ;; | |
201 | ||
202 | java-agent) | |
203 | echo "Build with Java Agents" | |
204 | export JAVA_HOME="/usr/lib/jvm/default-java" | |
205 | export CLASSPATH="$UST_JAVA/*:/usr/share/java/*" | |
206 | CONF_OPTS="--enable-test-java-agent-all" | |
207 | ;; | |
208 | ||
209 | python-agent) | |
210 | echo "Build with python agents" | |
211 | export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3" | |
212 | CONF_OPTS="--enable-test-python-agent-all" | |
213 | ;; | |
214 | ||
215 | relayd-only) | |
216 | echo "Build relayd only" | |
b6e62a6a | 217 | CONF_OPTS="--disable-bin-lttng --disable-bin-lttng-consumerd --disable-bin-lttng-crash --disable-bin-lttng-sessiond --disable-extras --disable-man-pages $NO_UST" |
0cdaa21c MJ |
218 | ;; |
219 | ||
220 | *) | |
221 | echo "Standard build" | |
222 | CONF_OPTS="" | |
223 | ;; | |
b4005bbf MJ |
224 | esac |
225 | ||
0cdaa21c | 226 | |
b4005bbf MJ |
227 | # Build type |
228 | # oot : out-of-tree build | |
229 | # dist: build via make dist | |
230 | # * : normal tree build | |
231 | # | |
0cdaa21c | 232 | # Make sure to move to the build_path and run configure |
b4005bbf | 233 | # before continuing |
b4005bbf MJ |
234 | BUILD_PATH=$WORKSPACE |
235 | case "$build" in | |
95654431 MJ |
236 | oot) |
237 | echo "Out of tree build" | |
238 | BUILD_PATH=$WORKSPACE/oot | |
b6e62a6a MJ |
239 | mkdir -p "$BUILD_PATH" |
240 | cd "$BUILD_PATH" | |
241 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" "$WORKSPACE/configure" --prefix="$PREFIX" $CONF_OPTS | |
95654431 MJ |
242 | ;; |
243 | ||
244 | dist) | |
245 | echo "Distribution out of tree build" | |
b6e62a6a | 246 | BUILD_PATH="`mktemp -d`" |
95654431 MJ |
247 | |
248 | # Initial configure and generate tarball | |
69a19833 | 249 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" ./configure $CONF_OPTS --enable-build-man-pages |
0cdaa21c | 250 | $MAKE dist |
95654431 | 251 | |
b6e62a6a MJ |
252 | mkdir -p "$BUILD_PATH" |
253 | cp ./*.tar.* "$BUILD_PATH/" | |
254 | cd "$BUILD_PATH" | |
95654431 MJ |
255 | |
256 | # Ignore level 1 of tar | |
b6e62a6a | 257 | $TAR xvf ./*.tar.* --strip 1 |
95654431 | 258 | |
b6e62a6a | 259 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
95654431 MJ |
260 | ;; |
261 | ||
262 | *) | |
263 | BUILD_PATH=$WORKSPACE | |
264 | echo "Standard tree build" | |
b6e62a6a | 265 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" "$WORKSPACE/configure" --prefix="$PREFIX" $CONF_OPTS |
95654431 | 266 | ;; |
b4005bbf MJ |
267 | esac |
268 | ||
0cdaa21c | 269 | # BUILD! |
b6e62a6a | 270 | $MAKE -j "`$NPROC`" V=1 |
0cdaa21c | 271 | $MAKE install |
b4005bbf MJ |
272 | |
273 | # Run tests | |
0cdaa21c | 274 | if [ "$RUN_TESTS" = "yes" ]; then |
7671741c MJ |
275 | cd tests |
276 | ||
0cdaa21c MJ |
277 | # Allow core dumps |
278 | ulimit -c unlimited | |
279 | ||
280 | # Add 'babeltrace' binary to PATH | |
7671741c | 281 | chmod +x "$BABEL_BINS/babeltrace" |
0cdaa21c MJ |
282 | export PATH="$PATH:$BABEL_BINS" |
283 | ||
284 | # Prepare tap output dirs | |
7671741c MJ |
285 | rm -rf "$WORKSPACE/tap" |
286 | mkdir -p "$WORKSPACE/tap" | |
287 | mkdir -p "$WORKSPACE/tap/unit" | |
288 | mkdir -p "$WORKSPACE/tap/fast_regression" | |
289 | mkdir -p "$WORKSPACE/tap/with_bindings_regression" | |
0cdaa21c | 290 | |
a4e98cc0 JR |
291 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a |
292 | # lttng-sessiond --daemonize on "lttng create" | |
293 | export LTTNG_SESSIOND_PATH="/bin/true" | |
294 | ||
0cdaa21c MJ |
295 | # Run 'unit_tests' and 'fast_regression' test suites for all configs except 'no-ust' |
296 | if [ "$conf" != "no-ust" ]; then | |
3c85b52d MJ |
297 | # Run 'unit_tests', 2.8 and up has a new test suite |
298 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
299 | make check | |
7671741c | 300 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*'" $BUILD_PATH/tests/" "$WORKSPACE/tap" |
3c85b52d | 301 | else |
7671741c MJ |
302 | prove --merge -v --exec '' - < "$BUILD_PATH/tests/unit_tests" --archive "$WORKSPACE/tap/unit/" || true |
303 | prove --merge -v --exec '' - < "$BUILD_PATH/tests/fast_regression" --archive "$WORKSPACE/tap/fast_regression/" || true | |
3c85b52d | 304 | fi |
0cdaa21c MJ |
305 | else |
306 | # Regression is disabled for now, we need to adjust the testsuite for no ust builds. | |
3c85b52d | 307 | echo "Tests disabled for 'no-ust'." |
0cdaa21c MJ |
308 | fi |
309 | ||
310 | # Run 'with_bindings_regression' test suite for 'python-bindings' config | |
311 | if [ "$conf" = "python-bindings" ]; then | |
7671741c | 312 | prove --merge -v --exec '' - < "$WORKSPACE/tests/with_bindings_regression" --archive "$WORKSPACE/tap/with_bindings_regression/" || true |
0cdaa21c MJ |
313 | fi |
314 | ||
315 | # TAP plugin is having a hard time with .yml files. | |
7671741c | 316 | find "$WORKSPACE/tap" -name "meta.yml" -exec rm -f {} \; |
0cdaa21c MJ |
317 | |
318 | # And also with files without extension, so rename all result to *.tap | |
7671741c MJ |
319 | find "$WORKSPACE/tap/" -type f -exec mv {} {}.tap \; |
320 | ||
321 | cd - | |
b4005bbf MJ |
322 | fi |
323 | ||
b4005bbf | 324 | # Cleanup |
0cdaa21c | 325 | $MAKE clean |
b4005bbf | 326 | |
0cdaa21c | 327 | # Cleanup rpath in executables and shared libraries |
7671741c MJ |
328 | find "$WORKSPACE/build/bin" -type f -perm -0500 -exec chrpath --delete {} \; |
329 | find "$WORKSPACE/build/lib" -name "*.so" -exec chrpath --delete {} \; | |
0cdaa21c MJ |
330 | |
331 | # Remove libtool .la files | |
7671741c | 332 | find "$WORKSPACE/build/lib" -name "*.la" -exec rm -f {} \; |
b4005bbf MJ |
333 | |
334 | # Clean temp dir for dist build | |
0cdaa21c | 335 | if [ "$build" = "dist" ]; then |
7671741c MJ |
336 | cd "$WORKSPACE" |
337 | rm -rf "$BUILD_PATH" | |
b4005bbf | 338 | fi |
95654431 MJ |
339 | |
340 | # EOF |