X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;ds=sidebyside;f=shell%2Fcmake-build.sh;h=41c96b9675d899022ab3b75b982502025837a28d;hb=refs%2Fchanges%2F50%2F72650%2F2;hp=a6a41e4c452af2f41ea1c284f9912b8b9f792e4d;hpb=f0dae8046088b145652b9da6a15068b8c99ced6c;p=releng%2Fglobal-jjb.git diff --git a/shell/cmake-build.sh b/shell/cmake-build.sh index a6a41e4c..41c96b96 100644 --- a/shell/cmake-build.sh +++ b/shell/cmake-build.sh @@ -8,33 +8,52 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################## + +# Creates a build subdir then invokes cmake and make from that dir with the +# specified install prefix and options. Optionally runs make install and tars +# up all files from the install prefix, then uses sudo to extract those files +# to /usr/local and run ldconfig, leaving shared lib(s) ready for use. +# 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) +# PROJECT is a non-empty name (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) +# INSTALL is "true" or "false" (optional, default true) + echo "---> cmake-build.sh" +# be careful and verbose +set -eux -o pipefail + build_dir="${BUILD_DIR:-$WORKSPACE/target}" cmake_opts="${CMAKE_OPTS:-}" make_opts="${MAKE_OPTS:-}" +install="${INSTALL:-true}" # Not a misspelling as shellcheck reports. # shellcheck disable=SC2153 project="${PROJECT//\//\-}" -################ -# Script start # -################ - -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 -cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $cmake_opts .. +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 -make install -mkdir -p "$WORKSPACE/dist" -tar -cJvf "$WORKSPACE/dist/$project.tar.xz" -C "$INSTALL_PREFIX" . +if [[ $install == true ]]; then + make install + mkdir -p "$WORKSPACE/dist" + tar -cJvf "$WORKSPACE/dist/$project.tar.xz" -C "$INSTALL_PREFIX" . + sudo tar -xvf "$WORKSPACE/dist/$project.tar.xz" -C "/usr/local" + sudo ldconfig +fi -sudo tar -xvf "$WORKSPACE/dist/$project.tar.xz" -C "/usr/local" -sudo ldconfig +echo "---> cmake-build.sh ends"