Skip to content

Commit

Permalink
script: reorganize build scripts
Browse files Browse the repository at this point in the history
In preparation for running builds and tests in containers, make some
organizational changes to the run-make-*.sh scripts.

Original version of the patch can be found at ceph#46071

Original-version-by: Ernesto Puerta <[email protected]>
Co-authored-by: Ernesto Puerta <[email protected]>
Co-authored-by: John Mulligan <[email protected]>
Signed-off-by: Ernesto Puerta <[email protected]>
Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn and epuertat committed Feb 7, 2023
1 parent 9754caf commit 70bf755
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 55 deletions.
46 changes: 7 additions & 39 deletions run-make-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ source src/script/run-make.sh

set -e

function in_jenkins() {
test -n "$JENKINS_HOME"
}

function run() {
# to prevent OSD EMFILE death on tests, make sure ulimit >= 1024
$DRY_RUN ulimit -n $(ulimit -Hn)
Expand All @@ -40,7 +36,9 @@ function run() {
if [ $(nproc) -gt $m ]; then
m=$(nproc)
fi
$DRY_RUN sudo /sbin/sysctl -q -w fs.aio-max-nr=$((65536 * $(nproc)))
if [ "$(/sbin/sysctl -n fs.aio-max-nr )" -lt "$((65536 * $(nproc)))" ]; then
$DRY_RUN sudo /sbin/sysctl -q -w fs.aio-max-nr=$((65536 * $(nproc)))
fi

CHECK_MAKEOPTS=${CHECK_MAKEOPTS:-$DEFAULT_MAKEOPTS}
if in_jenkins; then
Expand Down Expand Up @@ -71,43 +69,13 @@ function main() {
fi
# uses run-make.sh to install-deps
FOR_MAKE_CHECK=1 prepare
local cxx_compiler=g++
local c_compiler=gcc
for i in $(seq 14 -1 10); do
if type -t clang-$i > /dev/null; then
cxx_compiler="clang++-$i"
c_compiler="clang-$i"
break
fi
done
# Init defaults after deps are installed.
local cmake_opts
cmake_opts+=" -DCMAKE_CXX_COMPILER=$cxx_compiler -DCMAKE_C_COMPILER=$c_compiler"
cmake_opts+=" -DCMAKE_CXX_FLAGS_DEBUG=-Werror"
cmake_opts+=" -DENABLE_GIT_VERSION=OFF"
cmake_opts+=" -DWITH_GTEST_PARALLEL=ON"
cmake_opts+=" -DWITH_FIO=ON"
cmake_opts+=" -DWITH_CEPHFS_SHELL=ON"
cmake_opts+=" -DWITH_GRAFANA=ON"
cmake_opts+=" -DWITH_SPDK=ON"
cmake_opts+=" -DWITH_RBD_MIRROR=ON"
if [ $WITH_SEASTAR ]; then
cmake_opts+=" -DWITH_SEASTAR=ON"
fi
if [ $WITH_ZBD ]; then
cmake_opts+=" -DWITH_ZBD=ON"
fi
if [ $WITH_RBD_RWL ]; then
cmake_opts+=" -DWITH_RBD_RWL=ON"
fi
cmake_opts+=" -DWITH_RBD_SSD_CACHE=ON"
in_jenkins && echo "CI_DEBUG: Our cmake_opts are: $cmake_opts
CI_DEBUG: Running ./configure"
configure "$cmake_opts" "$@"
configure "$@"
in_jenkins && echo "CI_DEBUG: Running 'build tests'"
build tests
echo "make check: successful build on $(git rev-parse HEAD)"
FOR_MAKE_CHECK=1 run
}

main "$@"
if [ "$0" = "$BASH_SOURCE" ]; then
main "$@"
fi
66 changes: 50 additions & 16 deletions src/script/run-make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,21 @@ function do_install() {
pkgs=$@
shift
ret=0
$DRY_RUN sudo $install_cmd $pkgs || ret=$?
SUDO=""
if [ "$EUID" -ne 0 ]; then
SUDO="sudo"
fi
$DRY_RUN $SUDO $install_cmd $pkgs || ret=$?
if test $ret -eq 0 ; then
return
fi
# try harder if apt-get, and it was interrutped
if [[ $install_cmd == *"apt-get"* ]]; then
if test $ret -eq 100 ; then
# dpkg was interrupted
$DRY_RUN sudo dpkg --configure -a
in_jenkins && echo "CI_DEBUG: Running 'sudo $install_cmd $pkgs'"
$DRY_RUN sudo $install_cmd $pkgs
$DRY_RUN $SUDO dpkg --configure -a
in_jenkins && echo "CI_DEBUG: Running '$SUDO $install_cmd $pkgs'"
$DRY_RUN $SUDO $install_cmd $pkgs
else
return $ret
fi
Expand All @@ -88,11 +92,7 @@ function prepare() {
local which_pkg="which"
source /etc/os-release
if test -f /etc/redhat-release ; then
if ! type bc > /dev/null 2>&1 ; then
echo "Please install bc and re-run."
exit 1
fi
if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
if [ "$VERSION_ID" -ge "22" ]; then
install_cmd="dnf -y install"
else
install_cmd="yum install -y"
Expand All @@ -104,14 +104,14 @@ function prepare() {
which_pkg="debianutils"
fi

if ! type sudo > /dev/null 2>&1 ; then
if [ "$EUID" -ne 0 ] && ! type sudo > /dev/null 2>&1 ; then
echo "Please install sudo and re-run. This script assumes it is running"
echo "as a normal user with the ability to run commands as root via sudo."
echo "as a normal user with the ability to run commands as root via sudo."
exit 1
fi
if [ -n "$install_cmd" ]; then
in_jenkins && echo "CI_DEBUG: Running '$install_cmd ccache $which_pkg clang'"
do_install "$install_cmd" ccache $which_pkg clang
do_install "$install_cmd" ccache git $which_pkg clang
else
echo "WARNING: Don't know how to install packages" >&2
echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2
Expand All @@ -127,7 +127,9 @@ function prepare() {
$DRY_RUN source ./install-deps.sh || return 1
trap clean_up_after_myself EXIT
fi
}

function configure() {
cat <<EOM
Note that the binaries produced by this script do not contain correct time
and git version information, which may make them unsuitable for debugging
Expand All @@ -148,12 +150,44 @@ EOM
ccache -p | grep max_size
fi
$DRY_RUN ccache -sz # Reset the ccache statistics and show the current configuration
}

function configure() {
local cmake_build_opts=$(detect_ceph_dev_pkgs)
local cxx_compiler=g++
local c_compiler=gcc
for i in $(seq 14 -1 10); do
if type -t clang-$i > /dev/null; then
cxx_compiler="clang++-$i"
c_compiler="clang-$i"
break
fi
done
local cmake_opts
cmake_opts+=" -DCMAKE_CXX_COMPILER=$cxx_compiler -DCMAKE_C_COMPILER=$c_compiler"
cmake_opts+=" -DCMAKE_CXX_FLAGS_DEBUG=-Werror"
cmake_opts+=" -DENABLE_GIT_VERSION=OFF"
cmake_opts+=" -DWITH_GTEST_PARALLEL=ON"
cmake_opts+=" -DWITH_FIO=ON"
cmake_opts+=" -DWITH_CEPHFS_SHELL=ON"
cmake_opts+=" -DWITH_GRAFANA=ON"
cmake_opts+=" -DWITH_SPDK=ON"
cmake_opts+=" -DWITH_RBD_MIRROR=ON"
if [ $WITH_SEASTAR ]; then
cmake_opts+=" -DWITH_SEASTAR=ON"
fi
if [ $WITH_ZBD ]; then
cmake_opts+=" -DWITH_ZBD=ON"
fi
if [ $WITH_RBD_RWL ]; then
cmake_opts+=" -DWITH_RBD_RWL=ON"
fi
cmake_opts+=" -DWITH_RBD_SSD_CACHE=ON"

cmake_opts+=$(detect_ceph_dev_pkgs)

in_jenkins && echo "CI_DEBUG: Our cmake_opts are: $cmake_opts
CI_DEBUG: Running ./configure"
in_jenkins && echo "CI_DEBUG: Running do_cmake.sh"
$DRY_RUN ./do_cmake.sh $cmake_build_opts $@ || return 1

$DRY_RUN ./do_cmake.sh $cmake_opts $@ || return 1
}

function build() {
Expand Down

0 comments on commit 70bf755

Please sign in to comment.