Document requirement on patched JJB
[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 PYTHON2=python2
25 PYTHON3=python3
26
27 P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])")
28 P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])")
29
30 # liburcu
31 URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
32 URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
33
34 # lttng-ust
35 UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/"
36 UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/"
37 UST_JAVA="$WORKSPACE/deps/lttng-ust/build/share/java/"
38 UST_PYTHON2="$WORKSPACE/deps/lttng-ust/build/lib/python$P2_VERSION/site-packages"
39 UST_PYTHON3="$WORKSPACE/deps/lttng-ust/build/lib/python$P3_VERSION/site-packages"
40
41 # babeltrace
42 BABEL_INCS="$WORKSPACE/deps/babeltrace/build/include/"
43 BABEL_LIBS="$WORKSPACE/deps/babeltrace/build/lib/"
44 BABEL_BINS="$WORKSPACE/deps/babeltrace/build/bin/"
45
46 PREFIX="$WORKSPACE/build"
47
48 if [ "$conf" = "no-ust" ]
49 then
50 export CPPFLAGS="-I$URCU_INCS"
51 export LDFLAGS="-L$URCU_LIBS"
52 export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
53 else
54 export CPPFLAGS="-I$URCU_INCS -I$UST_INCS"
55 export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS"
56 export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
57 fi
58
59 ./bootstrap
60
61 CONF_OPTS=""
62 case "$conf" in
63 static)
64 echo "Static build"
65 CONF_OPTS="--enable-static --disable-shared"
66 ;;
67
68 python-bindings)
69 echo "Build with python bindings"
70 # We only support bindings built with Python 3
71 export PYTHON="python3"
72 export PYTHON_CONFIG="/usr/bin/python3-config"
73 CONF_OPTS="--enable-python-bindings"
74 ;;
75
76 no-ust)
77 echo "Build without UST support"
78 CONF_OPTS="--disable-lttng-ust"
79 ;;
80
81 java-agent)
82 echo "Build with Java Agents"
83 export JAVA_HOME="/usr/lib/jvm/default-java"
84 export CLASSPATH="$UST_JAVA/*:/usr/share/java/*"
85 CONF_OPTS="--enable-test-java-agent-all"
86 ;;
87
88 python-agent)
89 echo "Build with python agents"
90 export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3"
91 CONF_OPTS="--enable-test-python-agent-all"
92 ;;
93
94 *)
95 echo "Standard build"
96 CONF_OPTS=""
97 ;;
98 esac
99
100 # Build type
101 # oot : out-of-tree build
102 # dist: build via make dist
103 # * : normal tree build
104 #
105 # Make sure to move to the build_path and configure
106 # before continuing
107
108 BUILD_PATH=$WORKSPACE
109 case "$build" in
110 oot)
111 echo "Out of tree build"
112 BUILD_PATH=$WORKSPACE/oot
113 mkdir -p $BUILD_PATH
114 cd $BUILD_PATH
115 $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
116 ;;
117
118 dist)
119 echo "Distribution out of tree build"
120 BUILD_PATH=`mktemp -d`
121
122 # Initial configure and generate tarball
123 ./configure $CONF_OPTS
124 make dist
125
126 mkdir -p $BUILD_PATH
127 cp *.tar.* $BUILD_PATH/
128 cd $BUILD_PATH
129
130 # Ignore level 1 of tar
131 tar xvf *.tar.* --strip 1
132
133 $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
134 ;;
135
136 *)
137 BUILD_PATH=$WORKSPACE
138 echo "Standard tree build"
139 $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
140 ;;
141 esac
142
143
144 make
145 make install
146
147 # Run tests
148 # Allow core dumps
149 ulimit -c unlimited
150
151 # Add 'babeltrace' binary to PATH
152 chmod +x $BABEL_BINS/babeltrace
153 export PATH="$PATH:$BABEL_BINS"
154
155 # Prepare tap output dirs
156 rm -rf $WORKSPACE/tap
157 mkdir -p $WORKSPACE/tap
158 mkdir -p $WORKSPACE/tap/unit
159 mkdir -p $WORKSPACE/tap/fast_regression
160 mkdir -p $WORKSPACE/tap/with_bindings_regression
161
162 cd $BUILD_PATH/tests
163
164 # Run 'unit_tests' and 'fast_regression' test suites for all configs except 'no-ust'
165 if [ "$conf" != "no-ust" ]; then
166 prove --merge -v --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true
167 prove --merge -v --exec '' - < $BUILD_PATH/tests/fast_regression --archive $WORKSPACE/tap/fast_regression/ || true
168 else
169 # Regression is disabled for now, we need to adjust the testsuite for no ust builds.
170 echo "Testsuite disabled for 'no-ust'. See job configuration for more info."
171 fi
172
173 # Run 'with_bindings_regression' test suite for 'python-bindings' config
174 if [ "$conf" = "python-bindings" ]
175 then
176 prove --merge -v --exec '' - < $WORKSPACE/tests/with_bindings_regression --archive $WORKSPACE/tap/with_bindings_regression/ || true
177 fi
178
179 # TAP plugin is having a hard time with .yml files.
180 rm -f $WORKSPACE/tap/unit/meta.yml
181 rm -f $WORKSPACE/tap/fast_regression/meta.yml
182 rm -f $WORKSPACE/tap/with_bindings_regression/meta.yml
183
184 # And also with files without extension, so rename all result to *.tap
185 find $WORKSPACE/tap/unit/ -type f -exec mv {} {}.tap \;
186 find $WORKSPACE/tap/fast_regression/ -type f -exec mv {} {}.tap \;
187 find $WORKSPACE/tap/with_bindings_regression/ -type f -exec mv {} {}.tap \;
188
189 # Cleanup
190 make clean
191
192 # Cleanup rpath and libtool .la files
193 find $WORKSPACE/build/bin -executable -type f -exec chrpath --delete {} \;
194 find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \;
195 find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \;
196
197 # Clean temp dir for dist build
198 if [ $build = "dist" ]; then
199 rm -rf $BUILD_PATH
200 fi
201
202 # EOF
This page took 0.034584 seconds and 4 git commands to generate.