X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=jjb%2Fshell%2Fcmake-package.sh;fp=jjb%2Fshell%2Fcmake-package.sh;h=021f6601e9d7c27199542b14f978738950285ad2;hb=7751aa0ff279900cc6cb369eaefb2a91b0e09e78;hp=0000000000000000000000000000000000000000;hpb=490938d90594521a131596be5861853071efe9d3;p=ci-management.git diff --git a/jjb/shell/cmake-package.sh b/jjb/shell/cmake-package.sh new file mode 100644 index 00000000..021f6601 --- /dev/null +++ b/jjb/shell/cmake-package.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2020 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +# Creates a build directory then invokes cmake and make +# from that dir with only the specified options/targets. +# Supports projects that create DEB/RPM package files for +# upload to PackageCloud or other repository, which must +# use a system install prefix like /usr/local. Calling +# the "install" goal with a system prefix requires sudo, +# but building a package doesn't require the install step. +# Prereqs: +# The build minion has cmake, make, gcc etc. +# Environment variables: +# WORKSPACE is a non-empty path (required) +# CMAKE_INSTALL_PREFIX is a non-empty path (required) +# BUILD_DIR is a path (optional; has usable default) +# CMAKE_OPTS has options for cmake (optional, empty default) +# MAKE_OPTS has options for make (optional, empty default) + +echo "---> cmake-package.sh" + +build_dir="${BUILD_DIR:-$WORKSPACE/build}" +cmake_opts="${CMAKE_OPTS:-}" +make_opts="${MAKE_OPTS:-}" +echo "build_dir: $build_dir" +echo "cmake_opts: $cmake_opts" +echo "make_opts: $make_opts" + +# be careful and verbose +set -eux -o pipefail + +mkdir -p "$build_dir" +cd "$build_dir" || exit +cmake -version +# $cmake_opts needs to wordsplit to pass options. +# shellcheck disable=SC2086 +eval cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $cmake_opts .. +make -version +# $make_opts needs to wordsplit to pass options. +# shellcheck disable=SC2086 +make $make_opts + +echo "---> cmake-package.sh ends"