b8f6576a9baa1e642726c870837b488f26d06851
[lttng-ci.git] / scripts / lttng-tools / build.sh
1 #!/bin/sh -xue
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
19
20 # Create build directory
21 rm -rf $WORKSPACE/build
22 mkdir -p $WORKSPACE/build
23
24 # liburcu
25 URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
26 URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
27
28 # lttng-ust
29 UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/"
30 UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/"
31
32 # babeltrace
33 BABEL_INCS="$WORKSPACE/deps/babeltrace/build/include/"
34 BABEL_LIBS="$WORKSPACE/deps/babeltrace/build/lib/"
35 BABEL_BINS="$WORKSPACE/deps/babeltrace/build/bin/"
36
37 PREFIX="$WORKSPACE/build"
38
39 if [ "$conf" = "no_ust" ]
40 then
41 export CPPFLAGS="-I$URCU_INCS"
42 export LDFLAGS="-L$URCU_LIBS"
43 export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
44 else
45 export CPPFLAGS="-I$URCU_INCS -I$UST_INCS"
46 export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS"
47 export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
48 fi
49
50 ./bootstrap
51
52 CONF_OPTS=""
53 case "$conf" in
54 static)
55 echo "Static build"
56 CONF_OPTS="--enable-static --disable-shared"
57 ;;
58 python_bindings)
59 echo "Build with python bindings"
60 # We only support bindings built with Python 3
61 export PYTHON="python3"
62 export PYTHON_CONFIG="/usr/bin/python3-config"
63 CONF_OPTS="--enable-python-bindings"
64 ;;
65 no_ust)
66 echo "Build without UST support"
67 CONF_OPTS="--disable-lttng-ust"
68 ;;
69 *)
70 echo "Standard build"
71 CONF_OPTS=""
72 ;;
73 esac
74
75 # Build type
76 # oot : out-of-tree build
77 # dist: build via make dist
78 # * : normal tree build
79 #
80 # Make sure to move to the build_path and configure
81 # before continuing
82
83 BUILD_PATH=$WORKSPACE
84 case "$build" in
85 oot)
86 echo "Out of tree build"
87 BUILD_PATH=$WORKSPACE/oot
88 mkdir -p $BUILD_PATH
89 cd $BUILD_PATH
90 $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
91 ;;
92 dist)
93 echo "Distribution out of tree build"
94 BUILD_PATH=`mktemp -d`
95
96 # Initial configure and generate tarball
97 ./configure
98 make dist
99
100 mkdir -p $BUILD_PATH
101 cp *.tar.* $BUILD_PATH/
102 cd $BUILD_PATH
103
104 # Ignore level 1 of tar
105 tar xvf *.tar.* --strip 1
106
107 $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
108 ;;
109 *)
110 BUILD_PATH=$WORKSPACE
111 echo "Standard tree build"
112 $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
113 ;;
114 esac
115
116
117 make
118 make install
119
120 # Run tests
121 # Allow core dumps
122 ulimit -c unlimited
123
124 chmod +x $BABEL_BINS/babeltrace
125 export PATH="$PATH:$BABEL_BINS"
126
127 rm -rf $WORKSPACE/tap
128 mkdir -p $WORKSPACE/tap
129 mkdir -p $WORKSPACE/tap/unit
130 mkdir -p $WORKSPACE/tap/fast_regression
131 mkdir -p $WORKSPACE/tap/with_bindings_regression
132
133 cd $BUILD_PATH/tests
134
135 if [ "$conf" = "std" ]
136 then
137 prove --merge --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true
138 prove --merge --exec '' - < $BUILD_PATH/tests/fast_regression --archive $WORKSPACE/tap/fast_regression/ || true
139 fi
140
141 if [ "$conf" = "no_ust" ]
142 then
143 # Regression is disabled for now, we need to adjust the testsuite for no ust builds.
144 echo "Testsuite disabled. See job configuration for more info."
145 fi
146
147 if [ "$conf" = "python_bindings" ]
148 then
149 # Disabled due to race conditions in tests
150 echo "Testsuite disabled. See job configuration for more info."
151 prove --merge --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true
152 prove --merge --exec '' - < $BUILD_PATH/tests/fast_regression --archive $WORKSPACE/tap/fast_regression/ || true
153 prove --merge --exec '' - < $BUILD_PATH/tests/with_bindings_regression --archive $WORKSPACE/tap/with_bindings_regression/ || true
154 fi
155
156 # TAP plugin is having a hard time with .yml files.
157 rm -f $WORKSPACE/tap/unit/meta.yml
158 rm -f $WORKSPACE/tap/fast_regression/meta.yml
159 rm -f $WORKSPACE/tap/with_bindings_regression/meta.yml
160
161 # And also with files without extension, so rename all result to *.tap
162 find $WORKSPACE/tap/unit/ -type f -exec mv {} {}.tap \;
163 find $WORKSPACE/tap/fast_regression/ -type f -exec mv {} {}.tap \;
164 find $WORKSPACE/tap/with_bindings_regression/ -type f -exec mv {} {}.tap \;
165
166 # Cleanup
167 make clean
168
169 # Cleanup rpath and libtool .la files
170 find $WORKSPACE/build/bin -executable -type f -exec chrpath --delete {} \;
171 find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \;
172 find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \;
173
174 # Clean temp dir for dist build
175 if [ $build = "dist" ]; then
176 rm -rf $BUILD_PATH
177 fi
This page took 0.078792 seconds and 4 git commands to generate.