diff --git a/src/script/lib-build.sh b/src/script/lib-build.sh index a6ff447c99ee4..17c2fe72148c7 100644 --- a/src/script/lib-build.sh +++ b/src/script/lib-build.sh @@ -31,3 +31,20 @@ function ci_debug() { echo "CI_DEBUG: $*" fi } + +# get_processors returns 1/2 the value of the value returned by +# the nproc program OR the value of the environment variable NPROC +# allowing the user to tune the number of cores visible to the +# build scripts. +function get_processors() { + # get_processors() depends on coreutils nproc. + if [ -n "$NPROC" ]; then + echo "$NPROC" + else + if [ "$(nproc)" -ge 2 ]; then + echo "$(($(nproc) / 2))" + else + echo 1 + fi + fi +} diff --git a/src/script/run-make.sh b/src/script/run-make.sh index 3ab00861519d9..4331e581aa584 100755 --- a/src/script/run-make.sh +++ b/src/script/run-make.sh @@ -27,19 +27,6 @@ function clean_up_after_myself() { restore_ccache_conf } -function get_processors() { - # get_processors() depends on coreutils nproc. - if test -n "$NPROC" ; then - echo $NPROC - else - if test $(nproc) -ge 2 ; then - expr $(nproc) / 2 - else - echo 1 - fi - fi -} - function detect_ceph_dev_pkgs() { local cmake_opts="-DWITH_FMT_VERSION=9.0.0" local boost_root=/opt/ceph