modbuild: compute default number of parallel make jobs from number of cores

This commit is contained in:
2019-09-12 17:44:42 +02:00
parent 298829c6d9
commit 46bfc351dd
2 changed files with 33 additions and 16 deletions
+32 -15
View File
@@ -41,7 +41,32 @@ trap "error_handler" ERR
declare configure_with='undef'
#..............................................................................
# global variables
#
# The following variables are available in build-blocks and set read-only
# :FIXME: do we have to export them?
# install prefix of module.
declare -x PREFIX=''
declare -r OS=$(uname -s)
pbuild::get_num_cores() {
case "${OS}" in
Linux )
echo $(grep -c ^processor /proc/cpuinfo)
;;
Darwin )
echo $(sysctl -n hw.ncpu)
;;
* )
std::die 1 "OS ${OS} is not supported\n"
;;
esac
}
#..............................................................................
# global variables which can be set/overwritten by command line args
declare force_rebuild=''
pbuild.force_rebuild() {
force_rebuild="$1"
@@ -73,9 +98,13 @@ pbuild.update_modulefiles() {
}
# number of parallel make jobs
declare -i JOBS=3
declare -i JOBS=$(pbuild::get_num_cores)
pbuild.jobs() {
JOBS="$1"
if (( $1 == 0 )); then
JOBS=$(pbuild::get_num_cores)
else
JOBS="$1"
fi
}
declare system=''
@@ -114,18 +143,6 @@ declare -x module_release=''
# abs. path is "${PREFIX}/${_docdir}/${module_name}"
declare -r _DOCDIR='share/doc'
#..............................................................................
#
# The following variables are available in build-blocks and set read-only
# :FIXME: do we have to export them?
#
# install prefix of module.
declare -x PREFIX=''
declare -r OS=$(uname -s)
##############################################################################
#
# Set flag to build module in source tree.
+1 -1
View File
@@ -140,7 +140,7 @@ declare opt_dry_run='no'
declare opt_enable_cleanup_build='yes'
declare opt_enable_cleanup_src='yes'
declare opt_force_rebuild='no'
declare -i opt_jobs=3
declare -i opt_jobs=0
declare opt_update_modulefiles='no'
declare opt_system=''
declare opt_temp_dir="${PMODULES_TMPDIR:-/var/tmp/${USER}}"