From 61aa107fb108d3978117c2267b3f88eb39a5ea4a Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Thu, 3 Dec 2015 12:32:03 +0100 Subject: [PATCH] cmake: add run_cmake-check.sh currently only check to cmake build process Signed-off-by: Orit Wasserman --- run-cmake-check.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 run-cmake-check.sh diff --git a/run-cmake-check.sh b/run-cmake-check.sh new file mode 100755 index 0000000000000..894d8868ef9c1 --- /dev/null +++ b/run-cmake-check.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Ceph distributed storage system +# +# Copyright (C) 2014 Red Hat +# +# Author: Loic Dachary +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# + +# +# Return MAX(1, (number of processors / 2)) by default or NPROC +# +function get_processors() { + if test -n "$NPROC" ; then + echo $NPROC + else + if test $(nproc) -ge 2 ; then + expr $(nproc) / 2 + else + echo 1 + fi + fi +} + +DEFAULT_MAKEOPTS=${DEFAULT_MAKEOPTS:--j$(get_processors)} +BUILD_MAKEOPTS=${BUILD_MAKEOPTS:-$DEFAULT_MAKEOPTS} +CHECK_MAKEOPTS=${CHECK_MAKEOPTS:-$DEFAULT_MAKEOPTS} + +function run() { + # Same logic as install-deps.sh for finding package installer + local install_cmd + test -f /etc/redhat-release && install_cmd="yum install -y" + type apt-get > /dev/null 2>&1 && install_cmd="apt-get install -y" + type zypper > /dev/null 2>&1 && install_cmd="zypper --gpg-auto-import-keys --non-interactive install" + if [ -n "$install_cmd" ]; then + sudo $install_cmd ccache jq + else + echo "WARNING: Don't know how to install packages" >&2 + fi + sudo /sbin/modprobe rbd + + if test -f ./install-deps.sh ; then + $DRY_RUN ./install-deps.sh || return 1 + fi + $DRY_RUN ./autogen.sh || return 1 + $DRY_RUN ./configure "$@" --disable-static --with-radosgw --with-debug --without-lttng \ + CC="ccache gcc" CXX="ccache g++" CFLAGS="-Wall -g" CXXFLAGS="-Wall -g" || return 1 + $DRY_RUN mkdir build + $DRY_RUN cd build + $DRY_RUN cmake ../ + $DRY_RUN make $BUILD_MAKEOPTS -j$(get_processors) || return 1 +} + +function main() { + if run "$@" ; then + echo "cmake check: successful run on $(git rev-parse HEAD)" + return 0 + else + return 1 + fi +} + +main "$@" -- 2.39.5