X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fcmake-build.sh;h=41c96b9675d899022ab3b75b982502025837a28d;hb=c8b9acd166fcbd88139a65f7721e522980a0e013;hp=2466c1739a5b88443f3bcfe3f691479f533c1590;hpb=4a56aac71ab83cf0848ed254d0e9d955f5835a17;p=releng%2Fglobal-jjb.git diff --git a/shell/cmake-build.sh b/shell/cmake-build.sh index 2466c173..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 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"