commit:     1c01b84199785b35fa0b79f6ec990964bd09ceae
Author:     orbea <orbea <AT> riseup <DOT> net>
AuthorDate: Fri Apr  9 18:38:55 2021 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed May 11 02:13:17 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c01b841

ninja-utils.eclass: Support dev-util/samurai

samurai is a ninja-compatible build tool written in C which
works with cmake, meson and other users of ninja.

It is feature-complete and supports most of the same options
as ninja.

Signed-off-by: orbea <orbea <AT> riseup.net>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 eclass/ninja-utils.eclass | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass
index c5f34934192f..cf98e866d152 100644
--- a/eclass/ninja-utils.eclass
+++ b/eclass/ninja-utils.eclass
@@ -26,6 +26,16 @@ esac
 if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
 _NINJA_UTILS_ECLASS=1
 
+# @ECLASS_VARIABLE: NINJA
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Specify a compatible ninja implementation to be used by eninja().
+# At this point only "ninja" and "samu" are explicitly supported,
+# but other values can be set where NINJA_DEPEND will then be set
+# to a blank variable.
+# The default is set to "ninja".
+: ${NINJA:=ninja}
+
 # @ECLASS_VARIABLE: NINJAOPTS
 # @DEFAULT_UNSET
 # @DESCRIPTION:
@@ -35,6 +45,18 @@ _NINJA_UTILS_ECLASS=1
 
 inherit multiprocessing
 
+case "${NINJA}" in
+       ninja)
+               NINJA_DEPEND=">=dev-util/ninja-1.8.2"
+       ;;
+       samu)
+               NINJA_DEPEND="dev-util/samurai"
+       ;;
+       *)
+               NINJA_DEPEND=""
+       ;;
+esac
+
 # @FUNCTION: eninja
 # @USAGE: [<args>...]
 # @DESCRIPTION:
@@ -48,7 +70,8 @@ eninja() {
        if [[ -z ${NINJAOPTS+set} ]]; then
                NINJAOPTS="-j$(makeopts_jobs "${MAKEOPTS}" 999) 
-l$(makeopts_loadavg "${MAKEOPTS}" 0)"
        fi
-       set -- ninja -v ${NINJAOPTS} "$@"
+       [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for 
\${NINJA}"
+       set -- "${NINJA}" -v ${NINJAOPTS} "$@"
        echo "$@" >&2
        "$@" || die "${nonfatal_args[@]}" "${*} failed"
 }

Reply via email to