diff options
author | V3n3RiX <venerix@koprulu.sector> | 2022-05-12 16:42:50 +0300 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2022-05-12 16:42:50 +0300 |
commit | 752d6256e5204b958b0ef7905675a940b5e9172f (patch) | |
tree | 330d16e6362a49cbed8875a777fe641a43376cd3 /eclass/multiprocessing.eclass | |
parent | 0c100b7dd2b30e75b799d806df4ef899fd98e1ea (diff) |
gentoo resync : 12.05.2022
Diffstat (limited to 'eclass/multiprocessing.eclass')
-rw-r--r-- | eclass/multiprocessing.eclass | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass index c32bfaac2e6b..e55be636a02c 100644 --- a/eclass/multiprocessing.eclass +++ b/eclass/multiprocessing.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: multiprocessing.eclass @@ -65,22 +65,21 @@ get_nproc() { } # @FUNCTION: makeopts_jobs -# @USAGE: [${MAKEOPTS}] [${inf:-999}] +# @USAGE: [${MAKEOPTS}] [${inf:-$(( $(get_nproc) + 1 ))}] # @DESCRIPTION: # Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number # specified therein. Useful for running non-make tools in parallel too. # i.e. if the user has MAKEOPTS=-j9, this will echo "9" -- we can't return the # number as bash normalizes it to [0, 255]. If the flags haven't specified a -# -j flag, then "1" is shown as that is the default `make` uses. Since there's -# no way to represent infinity, we return ${inf} (defaults to 999) if the user -# has -j without a number. +# -j flag, then "1" is shown as that is the default `make` uses. If the flags +# specify -j without a number, ${inf} is returned (defaults to nproc). makeopts_jobs() { [[ $# -eq 0 ]] && set -- "${MAKEOPTS}" # This assumes the first .* will be more greedy than the second .* # since POSIX doesn't specify a non-greedy match (i.e. ".*?"). local jobs=$(echo " $* " | sed -r -n \ -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \ - -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p") + -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( $(get_nproc) + 1 ))}:p") echo ${jobs:-1} } |