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 ##############################################################################
11 echo "---> cmake-sonarqube.sh"
13 # Runs cmake then make using a wrapper for the SonarQube Jenkins plug-in
14 # https://docs.sonarqube.org/latest/analysis/languages/cfamily/
18 build_dir="${BUILD_DIR:-$WORKSPACE/build}"
19 build_wrap_dir="${BUILD_WRAP_DIR:-$WORKSPACE/bw-output}"
20 cmake_opts="${CMAKE_OPTS:-}"
21 make_opts="${MAKE_OPTS:-}"
24 wget -q -O bw.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
26 sudo mv build-wrapper-* /opt/build-wrapper
29 export SET_JDK_VERSION="${SET_JDK_VERSION:-openjdk11}"
30 echo "$SET_JDK_VERSION"
31 bash <(curl -s https://raw.githubusercontent.com/lfit/releng-global-jjb/master/shell/update-java-alternatives.sh)
32 # shellcheck disable=SC1091
36 cd "$build_dir" || exit 1
38 # $cmake_opts needs to wordsplit to pass options.
39 # shellcheck disable=SC2086
40 eval cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $cmake_opts ..
42 # $make_opts may be empty.
43 # shellcheck disable=SC2086
44 /opt/build-wrapper/build-wrapper-linux-x86-64 --out-dir "$build_wrap_dir" make $make_opts
46 echo "---> cmake-sonarqube.sh ends"