aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-09-30 01:14:05 +0200
committerThomas Deutschmann <whissi@gentoo.org>2019-09-30 01:14:05 +0200
commit096ff8a27b1b70e1306a9522b020753ab057fb56 (patch)
treef7f390e3aee23d9c5b3b1b0d3d69c80c69bde746 /gen_funcs.sh
parentAdd --utils-cxx option (diff)
downloadgenkernel-096ff8a27b1b70e1306a9522b020753ab057fb56.tar.gz
genkernel-096ff8a27b1b70e1306a9522b020753ab057fb56.tar.bz2
genkernel-096ff8a27b1b70e1306a9522b020753ab057fb56.zip
gkbuild.sh: Add possibility to disable distcc usage per gkbuild
This commit will add support for custom variable DISABLE_DISTCC which can be used in gkbuilds to disable distcc usage when set to "yes". This is needed because we don't have package.env mechanism to disable features per package. Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-xgen_funcs.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh
index 1d4a91d2..cfe53b91 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -1871,6 +1871,33 @@ make_bootdir_writable() {
fi
}
+# @FUNCTION: get_nproc
+# @USAGE: [${fallback:-1}]
+# @DESCRIPTION:
+# Attempt to figure out the number of processing units available.
+# If the value can not be determined, prints the provided fallback
+# instead. If no fallback is provided, defaults to 1.
+get_nproc() {
+ local nproc
+
+ # GNU
+ if type -P nproc &>/dev/null; then
+ nproc=$(nproc)
+ fi
+
+ # fallback to python2.6+
+ # note: this may fail (raise NotImplementedError)
+ if [[ -z ${nproc} ]] && type -P python &>/dev/null; then
+ nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null)
+ fi
+
+ if [[ -n ${nproc} ]]; then
+ echo "${nproc}"
+ else
+ echo "${1:-1}"
+ fi
+}
+
# @FUNCTION: makeopts_jobs
# @USAGE: [${MAKEOPTS}] [${inf:-999}]
# @DESCRIPTION: