jjb: add lttng-tools jgalar dev jobs
[lttng-ci.git] / scripts / lttng-tools / build.sh
1 #!/bin/bash -exu
2 #
3 # Copyright (C) 2016 - 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
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
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/"
48 UST_JAVA="$WORKSPACE/deps/lttng-ust/build/share/java/"
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
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)
112 export CPPFLAGS="-I$URCU_INCS"
113 export LDFLAGS="-L$URCU_LIBS"
114 export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
115 ;;
116
117 *)
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:-}"
121 ;;
122 esac
123
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
130
131 # Set configure options for each build configuration
132 CONF_OPTS=""
133 case "$conf" in
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 ;;
174 esac
175
176
177 # Build type
178 # oot : out-of-tree build
179 # dist: build via make dist
180 # * : normal tree build
181 #
182 # Make sure to move to the build_path and run configure
183 # before continuing
184 BUILD_PATH=$WORKSPACE
185 case "$build" in
186 oot)
187 echo "Out of tree build"
188 BUILD_PATH=$WORKSPACE/oot
189 mkdir -p $BUILD_PATH
190 cd $BUILD_PATH
191 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
192 ;;
193
194 dist)
195 echo "Distribution out of tree build"
196 BUILD_PATH=`mktemp -d`
197
198 # Initial configure and generate tarball
199 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" ./configure $CONF_OPTS --enable-build-man-pages
200 $MAKE dist
201
202 mkdir -p $BUILD_PATH
203 cp *.tar.* $BUILD_PATH/
204 cd $BUILD_PATH
205
206 # Ignore level 1 of tar
207 $TAR xvf *.tar.* --strip 1
208
209 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
210 ;;
211
212 *)
213 BUILD_PATH=$WORKSPACE
214 echo "Standard tree build"
215 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
216 ;;
217 esac
218
219 # BUILD!
220 $MAKE -j `$NPROC` V=1
221 $MAKE install
222
223 # Run tests
224 if [ "$RUN_TESTS" = "yes" ]; then
225 cd tests
226
227 # Allow core dumps
228 ulimit -c unlimited
229
230 # Add 'babeltrace' binary to PATH
231 chmod +x "$BABEL_BINS/babeltrace"
232 export PATH="$PATH:$BABEL_BINS"
233
234 # Prepare tap output dirs
235 rm -rf "$WORKSPACE/tap"
236 mkdir -p "$WORKSPACE/tap"
237 mkdir -p "$WORKSPACE/tap/unit"
238 mkdir -p "$WORKSPACE/tap/fast_regression"
239 mkdir -p "$WORKSPACE/tap/with_bindings_regression"
240
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
245 # Run 'unit_tests' and 'fast_regression' test suites for all configs except 'no-ust'
246 if [ "$conf" != "no-ust" ]; then
247 # Run 'unit_tests', 2.8 and up has a new test suite
248 if vergte "$PACKAGE_VERSION" "2.8"; then
249 make check
250 rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*'" $BUILD_PATH/tests/" "$WORKSPACE/tap"
251 else
252 prove --merge -v --exec '' - < "$BUILD_PATH/tests/unit_tests" --archive "$WORKSPACE/tap/unit/" || true
253 prove --merge -v --exec '' - < "$BUILD_PATH/tests/fast_regression" --archive "$WORKSPACE/tap/fast_regression/" || true
254 fi
255 else
256 # Regression is disabled for now, we need to adjust the testsuite for no ust builds.
257 echo "Tests disabled for 'no-ust'."
258 fi
259
260 # Run 'with_bindings_regression' test suite for 'python-bindings' config
261 if [ "$conf" = "python-bindings" ]; then
262 prove --merge -v --exec '' - < "$WORKSPACE/tests/with_bindings_regression" --archive "$WORKSPACE/tap/with_bindings_regression/" || true
263 fi
264
265 # TAP plugin is having a hard time with .yml files.
266 find "$WORKSPACE/tap" -name "meta.yml" -exec rm -f {} \;
267
268 # And also with files without extension, so rename all result to *.tap
269 find "$WORKSPACE/tap/" -type f -exec mv {} {}.tap \;
270
271 cd -
272 fi
273
274 # Cleanup
275 $MAKE clean
276
277 # Cleanup rpath in executables and shared libraries
278 find "$WORKSPACE/build/bin" -type f -perm -0500 -exec chrpath --delete {} \;
279 find "$WORKSPACE/build/lib" -name "*.so" -exec chrpath --delete {} \;
280
281 # Remove libtool .la files
282 find "$WORKSPACE/build/lib" -name "*.la" -exec rm -f {} \;
283
284 # Clean temp dir for dist build
285 if [ "$build" = "dist" ]; then
286 cd "$WORKSPACE"
287 rm -rf "$BUILD_PATH"
288 fi
289
290 # EOF
This page took 0.036501 seconds and 5 git commands to generate.