2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2020 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 # Invokes configure and make with the specified options,
13 # using a wrapper for the SonarQube Jenkins plug-in
14 # https://docs.sonarqube.org/latest/analysis/languages/cfamily/
16 # The build minion has make, gcc etc.
17 # The project repo has an executable shell script "configure"
18 # Environment variables:
19 # WORKSPACE is a non-empty path (required)
20 # INSTALL_PREFIX is a non-empty path (required)
21 # CONFIGURE_OPTS has options for configure (optional, empty default)
22 # MAKE_OPTS has options for make (optional, empty default)
23 # BUILD_WRAP_DIR is a path (optional, this provides a usable default)
25 echo "---> autotools-sonarqube.sh"
27 # be careful and verbose
30 c="$WORKSPACE/configure"
31 if [[ ! -f $c || ! -x $c ]]; then
32 echo "ERROR: failed to find executable file $c"
36 configure_opts="${CONFIGURE_OPTS:-}"
37 make_opts="${MAKE_OPTS:-}"
38 build_wrap_dir="${BUILD_WRAP_DIR:-$WORKSPACE/bw-output}"
40 # download and install the Sonar build wrapper
42 wget -q -O "$bw" https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
44 sudo mv build-wrapper-* /opt/build-wrapper
47 # use eval to disable bash quoting behavior;
48 # e.g., if configure-opts=CXXFLAGS="-O0 --coverage"
49 # configure needs to wordsplit to pass options
50 # shellcheck disable=SC2086
51 eval $c --prefix="$INSTALL_PREFIX" $configure_opts
53 # to analyze coverage, make must run tests and run gcov
54 # to process .gcno/.gcda files into .gcov files.
55 # use eval to disable bash quoting behavior
56 # $make_opts may be empty
57 # make needs to wordsplit to pass options
58 # shellcheck disable=SC2086
59 eval /opt/build-wrapper/build-wrapper-linux-x86-64 --out-dir "$build_wrap_dir" make $make_opts
61 echo "---> autotools-sonarqube.sh ends"