Skip to content

Commit

Permalink
ninja-utils.eclass: Support dev-util/samurai
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Mike Gilbert <[email protected]>
  • Loading branch information
orbea authored and floppym committed May 11, 2022
1 parent 06a5564 commit 1c01b84
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion eclass/ninja-utils.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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"
}
Expand Down

0 comments on commit 1c01b84

Please sign in to comment.