jjb: babeltrace: disable Werror on release build
[lttng-ci.git] / scripts / babeltrace / release.sh
CommitLineData
51c9c62d 1#!/bin/bash
8abe9f8a
MJ
2#
3# Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
7eb6ad4f 4# Copyright (C) 2023 Michael Jeanson <mjeanson@efficios.com>
8abe9f8a
MJ
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
51c9c62d
MJ
19set -exu
20
8abe9f8a
MJ
21# Version compare functions
22vercomp () {
23 set +u
24 if [[ "$1" == "$2" ]]; then
25 return 0
26 fi
27 local IFS=.
7eb6ad4f
MJ
28 # Ignore the shellcheck warning, we want splitting to happen based on IFS.
29 # shellcheck disable=SC2206
8abe9f8a
MJ
30 local i ver1=($1) ver2=($2)
31 # fill empty fields in ver1 with zeros
32 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
33 ver1[i]=0
34 done
35 for ((i=0; i<${#ver1[@]}; i++)); do
36 if [[ -z ${ver2[i]} ]]; then
37 # fill empty fields in ver2 with zeros
38 ver2[i]=0
39 fi
40 if ((10#${ver1[i]} > 10#${ver2[i]})); then
41 return 1
42 fi
43 if ((10#${ver1[i]} < 10#${ver2[i]})); then
44 return 2
45 fi
46 done
47 set -u
48 return 0
49}
50
51verlte() {
52 vercomp "$1" "$2"; local res="$?"
53 [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
54}
55
56verlt() {
57 vercomp "$1" "$2"; local res="$?"
58 [ "$res" -eq "2" ]
59}
60
61vergte() {
62 vercomp "$1" "$2"; local res="$?"
63 [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
64}
65
66vergt() {
67 vercomp "$1" "$2"; local res="$?"
68 [ "$res" -eq "1" ]
69}
70
71verne() {
72 vercomp "$1" "$2"; local res="$?"
73 [ "$res" -ne "0" ]
74}
75
76# Required variables
77WORKSPACE=${WORKSPACE:-}
78
79
80SRCDIR="$WORKSPACE/src/babeltrace"
81TMPDIR="$WORKSPACE/tmp"
82OUTDIR="$WORKSPACE/out"
83TAPDIR="$WORKSPACE/tap"
84
85failed_tests=0
86
87# Create build and tmp directories
88rm -rf "$OUTDIR" "$TMPDIR" "$TAPDIR"
89mkdir -p "$OUTDIR" "$TMPDIR" "$TAPDIR"
90
91export TMPDIR
92
93
94# Enter the source directory
95cd "$SRCDIR"
96
97# Run bootstrap in the source directory prior to configure
98./bootstrap
99
100# Get source version from configure script
101eval "$(grep '^PACKAGE_VERSION=' ./configure)"
102PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/}
103
104# Version specific configurations
105if vergte "$PACKAGE_VERSION" "2.0"; then
106 BASENAME="babeltrace2"
7eb6ad4f 107 CONF_OPTS=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins" "--disable-Werror")
8abe9f8a
MJ
108
109 # Enable dev mode by default for BT 2.0 builds
110 #export BABELTRACE_DEBUG_MODE=1
111 #export BABELTRACE_DEV_MODE=1
112 #export BABELTRACE_MINIMAL_LOG_LEVEL=TRACE
113else
114 BASENAME="babeltrace"
115 CONF_OPTS=("--enable-python-bindings")
116fi
117
118
119TARBALL_FILE="$BASENAME-$PACKAGE_VERSION.tar.bz2"
120
121
122# Make sure the reported version matches the current git tag
63ffe145 123GIT_TAG="$(git describe --exact-match --tags "$(git log -n1 --pretty='%h')" || echo 'undefined')"
8abe9f8a
MJ
124
125if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then
126 echo "Git checkout is not tagged or doesn't match the reported version."
127 exit 1
128fi
129
130# Generate release tarball
63ffe145 131./configure
8abe9f8a
MJ
132make dist
133cp "./$TARBALL_FILE" "$OUTDIR/"
134
135## Do an in-tree test build
136mkdir "$WORKSPACE/intree"
137cd "$WORKSPACE/intree" || exit 1
138
139tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1
140./configure --prefix="$(mktemp -d)" "${CONF_OPTS[@]}"
141
142# BUILD!
143make -j "$(nproc)" V=1
144
145make install
146
147# Run tests, don't fail now, we want to run the archiving steps
148make --keep-going check || failed_tests=1
149
150# Copy tap logs for the jenkins tap parser before cleaning the build dir
151rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/intree"
152
153# Clean the build directory
154make clean
155
156
157## Do an out-of-tree test build
158mkdir "$WORKSPACE/oot"
159mkdir "$WORKSPACE/oot/src"
160mkdir "$WORKSPACE/oot/build"
161cd "$WORKSPACE/oot/src" || exit 1
162
163tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1
164cd "$WORKSPACE/oot/build" || exit 1
165"$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" "${CONF_OPTS[@]}"
166
167# BUILD!
168make -j "$(nproc)" V=1
169
170make install
171
172# Run tests, don't fail now, we want to run the archiving steps
173make --keep-going check || failed_tests=1
174
175# Copy tap logs for the jenkins tap parser before cleaning the build dir
176rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/oot"
177
178# Clean the build directory
179make clean
180
181
182# Exit with failure if any of the tests failed
183exit $failed_tests
184
185# EOF
This page took 0.030767 seconds and 4 git commands to generate.