Commit | Line | Data |
---|---|---|
0cdaa21c | 1 | #!/bin/bash -xue |
b4005bbf MJ |
2 | # |
3 | # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
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 MJ |
19 | # Version compare functions |
20 | verlte() { | |
21 | [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ] | |
22 | } | |
23 | ||
24 | verlt() { | |
25 | [ "$1" = "$2" ] && return 1 || verlte $1 $2 | |
26 | } | |
27 | ||
28 | vergte() { | |
29 | [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ] | |
30 | } | |
31 | ||
32 | vergt() { | |
33 | [ "$1" = "$2" ] && return 1 || vergte $1 $2 | |
34 | } | |
35 | ||
b4005bbf MJ |
36 | |
37 | # Create build directory | |
38 | rm -rf $WORKSPACE/build | |
39 | mkdir -p $WORKSPACE/build | |
40 | ||
41 | # liburcu | |
42 | URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" | |
43 | URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" | |
44 | ||
45 | # lttng-ust | |
46 | UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/" | |
47 | UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/" | |
95654431 | 48 | UST_JAVA="$WORKSPACE/deps/lttng-ust/build/share/java/" |
b4005bbf MJ |
49 | |
50 | # babeltrace | |
51 | BABEL_INCS="$WORKSPACE/deps/babeltrace/build/include/" | |
52 | BABEL_LIBS="$WORKSPACE/deps/babeltrace/build/lib/" | |
53 | BABEL_BINS="$WORKSPACE/deps/babeltrace/build/bin/" | |
54 | ||
55 | PREFIX="$WORKSPACE/build" | |
56 | ||
0cdaa21c MJ |
57 | # Set platform variables |
58 | case "$arch" in | |
59 | solaris10) | |
60 | MAKE=gmake | |
61 | TAR=gtar | |
62 | NPROC=gnproc | |
63 | BISON="bison" | |
64 | YACC="$BISON -y" | |
65 | CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" | |
66 | RUN_TESTS="no" | |
67 | ;; | |
68 | ||
69 | solaris11) | |
70 | MAKE=gmake | |
71 | TAR=gtar | |
72 | NPROC=nproc | |
73 | BISON="/opt/csw/bin/bison" | |
74 | YACC="$BISON -y" | |
75 | CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" | |
76 | RUN_TESTS="no" | |
77 | ||
78 | export PATH="$PATH:/usr/perl5/bin" | |
79 | ;; | |
80 | ||
81 | *) | |
82 | MAKE=make | |
83 | TAR=tar | |
84 | NPROC=nproc | |
85 | BISON="bison" | |
86 | YACC="$BISON -y" | |
87 | CFLAGS="" | |
88 | RUN_TESTS="yes" | |
89 | ||
90 | PYTHON2=python2 | |
91 | PYTHON3=python3 | |
92 | ||
93 | P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])") | |
94 | P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])") | |
95 | ||
96 | UST_PYTHON2="$WORKSPACE/deps/lttng-ust/build/lib/python$P2_VERSION/site-packages" | |
97 | UST_PYTHON3="$WORKSPACE/deps/lttng-ust/build/lib/python$P3_VERSION/site-packages" | |
98 | ;; | |
99 | esac | |
100 | ||
101 | ||
102 | # Run bootstrap prior to configure | |
103 | ./bootstrap | |
104 | ||
105 | # Get source version from configure script | |
106 | eval `grep '^PACKAGE_VERSION=' ./configure` | |
107 | ||
108 | ||
109 | # Export build flags | |
110 | case "$conf" in | |
111 | no-ust) | |
b4005bbf MJ |
112 | export CPPFLAGS="-I$URCU_INCS" |
113 | export LDFLAGS="-L$URCU_LIBS" | |
114 | export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}" | |
0cdaa21c MJ |
115 | ;; |
116 | ||
117 | *) | |
b4005bbf MJ |
118 | export CPPFLAGS="-I$URCU_INCS -I$UST_INCS" |
119 | export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS" | |
120 | export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}" | |
0cdaa21c MJ |
121 | ;; |
122 | esac | |
b4005bbf | 123 | |
0cdaa21c MJ |
124 | # The switch to build without UST changed in 2.8 |
125 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
126 | NO_UST="--without-lttng-ust" | |
127 | else | |
128 | NO_UST="--disable-lttng-ust" | |
129 | fi | |
b4005bbf | 130 | |
0cdaa21c | 131 | # Set configure options for each build configuration |
b4005bbf MJ |
132 | CONF_OPTS="" |
133 | case "$conf" in | |
0cdaa21c MJ |
134 | static) |
135 | echo "Static build" | |
136 | CONF_OPTS="--enable-static --disable-shared" | |
137 | ;; | |
138 | ||
139 | python-bindings) | |
140 | echo "Build with python bindings" | |
141 | # We only support bindings built with Python 3 | |
142 | export PYTHON="python3" | |
143 | export PYTHON_CONFIG="/usr/bin/python3-config" | |
144 | CONF_OPTS="--enable-python-bindings" | |
145 | ;; | |
146 | ||
147 | no-ust) | |
148 | echo "Build without UST support" | |
149 | CONF_OPTS="$NO_UST" | |
150 | ;; | |
151 | ||
152 | java-agent) | |
153 | echo "Build with Java Agents" | |
154 | export JAVA_HOME="/usr/lib/jvm/default-java" | |
155 | export CLASSPATH="$UST_JAVA/*:/usr/share/java/*" | |
156 | CONF_OPTS="--enable-test-java-agent-all" | |
157 | ;; | |
158 | ||
159 | python-agent) | |
160 | echo "Build with python agents" | |
161 | export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3" | |
162 | CONF_OPTS="--enable-test-python-agent-all" | |
163 | ;; | |
164 | ||
165 | relayd-only) | |
166 | echo "Build relayd only" | |
167 | CONF_OPTS="--disable-bin-lttng --disable-bin-lttng-consumerd --disable-bin-lttng-crash --disable-bin-lttng-sessiond --disable-extras $NO_UST" | |
168 | ;; | |
169 | ||
170 | *) | |
171 | echo "Standard build" | |
172 | CONF_OPTS="" | |
173 | ;; | |
b4005bbf MJ |
174 | esac |
175 | ||
0cdaa21c | 176 | |
b4005bbf MJ |
177 | # Build type |
178 | # oot : out-of-tree build | |
179 | # dist: build via make dist | |
180 | # * : normal tree build | |
181 | # | |
0cdaa21c | 182 | # Make sure to move to the build_path and run configure |
b4005bbf | 183 | # before continuing |
b4005bbf MJ |
184 | BUILD_PATH=$WORKSPACE |
185 | case "$build" in | |
95654431 MJ |
186 | oot) |
187 | echo "Out of tree build" | |
188 | BUILD_PATH=$WORKSPACE/oot | |
189 | mkdir -p $BUILD_PATH | |
190 | cd $BUILD_PATH | |
0cdaa21c | 191 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS |
95654431 MJ |
192 | ;; |
193 | ||
194 | dist) | |
195 | echo "Distribution out of tree build" | |
196 | BUILD_PATH=`mktemp -d` | |
197 | ||
198 | # Initial configure and generate tarball | |
69a19833 | 199 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" ./configure $CONF_OPTS --enable-build-man-pages |
0cdaa21c | 200 | $MAKE dist |
95654431 MJ |
201 | |
202 | mkdir -p $BUILD_PATH | |
203 | cp *.tar.* $BUILD_PATH/ | |
204 | cd $BUILD_PATH | |
205 | ||
206 | # Ignore level 1 of tar | |
0cdaa21c | 207 | $TAR xvf *.tar.* --strip 1 |
95654431 | 208 | |
0cdaa21c | 209 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS |
95654431 MJ |
210 | ;; |
211 | ||
212 | *) | |
213 | BUILD_PATH=$WORKSPACE | |
214 | echo "Standard tree build" | |
0cdaa21c | 215 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS |
95654431 | 216 | ;; |
b4005bbf MJ |
217 | esac |
218 | ||
0cdaa21c | 219 | # BUILD! |
fe584a39 | 220 | $MAKE -j `$NPROC` V=1 |
0cdaa21c | 221 | $MAKE install |
b4005bbf MJ |
222 | |
223 | # Run tests | |
0cdaa21c MJ |
224 | if [ "$RUN_TESTS" = "yes" ]; then |
225 | # Allow core dumps | |
226 | ulimit -c unlimited | |
227 | ||
228 | # Add 'babeltrace' binary to PATH | |
229 | chmod +x $BABEL_BINS/babeltrace | |
230 | export PATH="$PATH:$BABEL_BINS" | |
231 | ||
232 | # Prepare tap output dirs | |
233 | rm -rf $WORKSPACE/tap | |
234 | mkdir -p $WORKSPACE/tap | |
235 | mkdir -p $WORKSPACE/tap/unit | |
236 | mkdir -p $WORKSPACE/tap/fast_regression | |
237 | mkdir -p $WORKSPACE/tap/with_bindings_regression | |
238 | ||
239 | cd $BUILD_PATH/tests | |
240 | ||
a4e98cc0 JR |
241 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a |
242 | # lttng-sessiond --daemonize on "lttng create" | |
243 | export LTTNG_SESSIOND_PATH="/bin/true" | |
244 | ||
0cdaa21c MJ |
245 | # Run 'unit_tests' and 'fast_regression' test suites for all configs except 'no-ust' |
246 | if [ "$conf" != "no-ust" ]; then | |
247 | prove --merge -v --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true | |
248 | prove --merge -v --exec '' - < $BUILD_PATH/tests/fast_regression --archive $WORKSPACE/tap/fast_regression/ || true | |
249 | else | |
250 | # Regression is disabled for now, we need to adjust the testsuite for no ust builds. | |
251 | echo "Testsuite disabled for 'no-ust'. See job configuration for more info." | |
252 | fi | |
253 | ||
254 | # Run 'with_bindings_regression' test suite for 'python-bindings' config | |
255 | if [ "$conf" = "python-bindings" ]; then | |
256 | prove --merge -v --exec '' - < $WORKSPACE/tests/with_bindings_regression --archive $WORKSPACE/tap/with_bindings_regression/ || true | |
257 | fi | |
258 | ||
259 | # TAP plugin is having a hard time with .yml files. | |
260 | rm -f $WORKSPACE/tap/unit/meta.yml | |
261 | rm -f $WORKSPACE/tap/fast_regression/meta.yml | |
262 | rm -f $WORKSPACE/tap/with_bindings_regression/meta.yml | |
263 | ||
264 | # And also with files without extension, so rename all result to *.tap | |
265 | find $WORKSPACE/tap/unit/ -type f -exec mv {} {}.tap \; | |
266 | find $WORKSPACE/tap/fast_regression/ -type f -exec mv {} {}.tap \; | |
267 | find $WORKSPACE/tap/with_bindings_regression/ -type f -exec mv {} {}.tap \; | |
b4005bbf MJ |
268 | fi |
269 | ||
b4005bbf | 270 | # Cleanup |
0cdaa21c | 271 | $MAKE clean |
b4005bbf | 272 | |
0cdaa21c MJ |
273 | # Cleanup rpath in executables and shared libraries |
274 | find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \; | |
b4005bbf | 275 | find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \; |
0cdaa21c MJ |
276 | |
277 | # Remove libtool .la files | |
b4005bbf MJ |
278 | find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \; |
279 | ||
280 | # Clean temp dir for dist build | |
0cdaa21c MJ |
281 | if [ "$build" = "dist" ]; then |
282 | cd $WORKSPACE | |
283 | rm -rf $BUILD_PATH | |
b4005bbf | 284 | fi |
95654431 MJ |
285 | |
286 | # EOF |