Signed-off-by: Michał Górny <mgo...@gentoo.org>
---
 eclass/ninja-utils.eclass | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
index 0dffd2eb86ff..9be502fa8ad9 100644
--- a/eclass/ninja-utils.eclass
+++ b/eclass/ninja-utils.eclass
@@ -62,6 +62,16 @@ case "${NINJA}" in
        ;;
 esac
 
+# @FUNCTION: get_NINJAOPTS
+# @DESCRIPTION:
+# Get the value of NINJAOPTS, inferring them from MAKEOPTS if unset.
+get_NINJAOPTS() {
+       if [[ -z ${NINJAOPTS+set} ]]; then
+               NINJAOPTS="-j$(makeopts_jobs "${MAKEOPTS}" 999) 
-l$(makeopts_loadavg "${MAKEOPTS}" 0)"
+       fi
+       echo "${NINJAOPTS}"
+}
+
 # @FUNCTION: eninja
 # @USAGE: [<args>...]
 # @DESCRIPTION:
@@ -72,11 +82,8 @@ eninja() {
        local nonfatal_args=()
        [[ ${EAPI} != 5 ]] && nonfatal_args+=( -n )
 
-       if [[ -z ${NINJAOPTS+set} ]]; then
-               NINJAOPTS="-j$(makeopts_jobs "${MAKEOPTS}" 999) 
-l$(makeopts_loadavg "${MAKEOPTS}" 0)"
-       fi
        [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for 
\${NINJA}"
-       set -- "${NINJA}" -v ${NINJAOPTS} "$@"
+       set -- "${NINJA}" -v $(get_NINJAOPTS) "$@"
        echo "$@" >&2
        "$@" || die "${nonfatal_args[@]}" "${*} failed"
 }
-- 
2.38.1


Reply via email to