Fix lttng-ust java tests
[lttng-ci.git] / scripts / lttng-ust / build.sh
CommitLineData
3b3282a6 1#!/bin/bash -exu
2b68721a
MJ
2#
3# Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
c3bc676b
JRJ
19# Create build directory
20rm -rf $WORKSPACE/build
21mkdir -p $WORKSPACE/build
22
23# liburcu
2b68721a
MJ
24URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
25URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
c3bc676b 26
3b3282a6
MJ
27
28PREFIX="$WORKSPACE/build"
29
30# Set platform variables
31case "$arch" in
32*)
33 MAKE=make
34 TAR=tar
35 NPROC=nproc
36 BISON="bison"
37 YACC="$BISON -y"
38 CFLAGS=""
39 ;;
40esac
41
42# Export build flags
c3bc676b
JRJ
43export CPPFLAGS="-I$URCU_INCS"
44export LDFLAGS="-L$URCU_LIBS"
2b68721a 45export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}"
c3bc676b 46
c3bc676b 47
3b3282a6 48# Set configure options for each build configuration
c3bc676b 49CONF_OPTS=""
c3bc676b 50case "$conf" in
3b3282a6
MJ
51static)
52 # Unsupported! liblttng-ust can't pull in it's static (.a) dependencies.
53 echo "Static build"
54 CONF_OPTS="--enable-static --disable-shared"
55 ;;
56
c3bc676b
JRJ
57java-agent)
58 echo "Java agent build"
59 export CLASSPATH="/usr/share/java/log4j-1.2.jar"
60 CONF_OPTS="--enable-java-agent-all"
61 ;;
3b3282a6 62
2b68721a 63python-agent)
3b3282a6
MJ
64 echo "Python agent build"
65 CONF_OPTS="--enable-python-agent"
66 ;;
67
c3bc676b
JRJ
68*)
69 echo "Standard build"
70 CONF_OPTS=""
71 ;;
72esac
73
3b3282a6
MJ
74
75# Run bootstrap prior to configure
76./bootstrap
77
78
2b68721a
MJ
79# Build type
80# oot : out-of-tree build
81# dist: build via make dist
82# * : normal tree build
83#
84# Make sure to move to the build_path and configure
85# before continuing
2b68721a
MJ
86BUILD_PATH=$WORKSPACE
87case "$build" in
3b3282a6
MJ
88oot)
89 echo "Out of tree build"
90 BUILD_PATH=$WORKSPACE/oot
91 mkdir -p $BUILD_PATH
92 cd $BUILD_PATH
93 $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
94 ;;
95
96dist)
97 echo "Distribution out of tree build"
98 BUILD_PATH=`mktemp -d`
99
100 # Initial configure and generate tarball
101 ./configure
102 $MAKE dist
103
104 mkdir -p $BUILD_PATH
105 cp *.tar.* $BUILD_PATH/
106 cd $BUILD_PATH
107
108 # Ignore level 1 of tar
109 $TAR xvf *.tar.* --strip 1
110
111 $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
112 ;;
113
114*)
115 BUILD_PATH=$WORKSPACE
116 echo "Standard tree build"
117 $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
118 ;;
2b68721a
MJ
119esac
120
3b3282a6 121# BUILD!
fe584a39 122$MAKE -j `$NPROC` V=1
3b3282a6 123$MAKE install
c3bc676b
JRJ
124
125# Run tests
126rm -rf $WORKSPACE/tap
127mkdir -p $WORKSPACE/tap/unit
128
2b68721a 129cd $BUILD_PATH/tests
c3bc676b 130
2b68721a 131prove --merge --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true
c3bc676b
JRJ
132
133# TAP plugin is having a hard time with .yml files.
134rm -f $WORKSPACE/tap/unit/meta.yml
135
136# And also with files without extension, so rename all result to *.tap
137find $WORKSPACE/tap/unit/ -type f -exec mv {} {}.tap \;
138
139# Cleanup
3b3282a6 140$MAKE clean
c3bc676b 141
3b3282a6 142# Cleanup rpath in executables and shared libraries
c3bc676b 143find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \;
3b3282a6
MJ
144
145# Remove libtool .la files
c3bc676b 146find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \;
2b68721a
MJ
147
148# Clean temp dir for dist build
3b3282a6
MJ
149if [ "$build" = "dist" ]; then
150 cd $WORKSPACE
151 rm -rf $BUILD_PATH
2b68721a 152fi
3b3282a6
MJ
153
154# EOF
This page took 0.029143 seconds and 4 git commands to generate.