From: Lott, Christopher (cl778h) Date: Tue, 31 Mar 2020 00:06:30 +0000 (-0400) Subject: Build RMR libraries with CMake templates X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=ci-management.git;a=commitdiff_plain;h=7751aa0ff279900cc6cb369eaefb2a91b0e09e78 Build RMR libraries with CMake templates Use new shell script cmake-package.sh to build packages, stop using the global-jjb cmake-build.sh with its hardcoded invocation of "make install". Signed-off-by: Lott, Christopher (cl778h) Change-Id: Ia4ec99414e1f47ac35ba844d2f0efc5c37a8e60e --- diff --git a/jjb/oran-templates/oran-c-cpp-jobs.yaml b/jjb/oran-templates/oran-c-cpp-jobs.yaml index c43e7358..2291c424 100644 --- a/jjb/oran-templates/oran-c-cpp-jobs.yaml +++ b/jjb/oran-templates/oran-c-cpp-jobs.yaml @@ -97,7 +97,7 @@ - file-id: ".packagecloud" target: "$HOME/.packagecloud" - shell: "{pre-build}" - - shell: !include-raw-escape: ../../global-jjb/shell/cmake-build.sh + - shell: !include-raw-escape: ../shell/cmake-package.sh - oran-packagecloud-push: build-dir: "{build-dir}" packagecloud-account: "{packagecloud-account}" diff --git a/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml b/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml index 60c2f2b9..ff3fae16 100644 --- a/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml +++ b/jjb/ric-plt-lib-rmr/ric-plt-lib-rmr.yaml @@ -30,43 +30,58 @@ # jenkins job name prefix project-name: ric-plt-lib-rmr-c # test scripts depend on this name - build-dir: $WORKSPACE/build - # use an ubuntu for its modern compiler - build-node: ubuntu1804-builder-2c-2g - # verify and sonar use cmake - cmake-opts: -DDEV_PKG=1 - make-opts: install test ARGS=-V + build-dir: $WORKSPACE/.build + # Use ubuntu base for cmake v3 + # Use docker variant for packagecloud ruby gem + build-node: ubuntu1804-docker-4c-4g + # install alien package to build RPMS on ubuntu + pre-build: !include-raw-escape: + - ../shell/install-deb-alien.sh # exclude irrelevant changes gerrit_trigger_file_paths: - compare-type: REG_EXP pattern: '^((?!src/bindings|\/COMMIT_MSG).)*$' -# verify c changes on every branch +# verify every commit - project: - name: ric-plt-lib-rmr-c-verify <<: *rmr_common <<: *rmr_c_common + name: ric-plt-lib-rmr-c-verify + project-name: ric-plt-lib-rmr-c + cmake-opts: -DDEV_PKG=1 + make-opts: package test ARGS=-V jobs: - gerrit-cmake-verify stream: - - all: - branch: '*' + - master: + branch: master -# build deb/rpm using Docker and publish to PackageCloud.io -# on merge to master branch +# development library - package and publish - project: <<: *rmr_common <<: *rmr_c_common - name: ric-plt-lib-rmr-c-package - # need docker - build-node: ubuntu1804-docker-4c-4g - # image is not pushed, use simple name and tag - docker-name: '{name}' - container-tag-method: latest - # use host network for network resources - docker-build-args: '--network=host -f ci/Dockerfile' + name: ric-plt-lib-rmr-c-dev + project-name: ric-plt-lib-rmr-c-dev + cmake-opts: -DDEV_PKG=1 + make-opts: package ARGS=-V + install-prefix: /usr/local + jobs: + - oran-gerrit-cmake-pc-stage + stream: + - master: + branch: master + +# runtime library - package and publish +- project: + <<: *rmr_common + <<: *rmr_c_common + name: ric-plt-lib-rmr-c-rt + project-name: ric-plt-lib-rmr-c-rt + cmake-opts: -DDEV_PKG=0 + make-opts: package ARGS=-V + install-prefix: /usr/local jobs: - - oran-gerrit-docker-ci-pc-merge + - oran-gerrit-cmake-pc-stage stream: - master: branch: master @@ -84,9 +99,10 @@ # analyze C code and test coverage - project: - name: ric-plt-lib-rmr-c-sonar + name: ric-plt-lib-rmr-c-sonarqube <<: *rmr_common <<: *rmr_c_common + make-opts: test ARGS=-V sonar-project-file: "" sonar-properties: | sonar.login={sonarcloud_api_token} 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"