eclass/ninja-utils: Sync with Gentoo

It's from Gentoo commit cf7738d1259d466a912822c2ef4b067d358d332d.
This commit is contained in:
Flatcar Buildbot 2023-01-02 07:56:32 +00:00 committed by Krzesimir Nowak
parent f1e24691c7
commit 1f287b5e91

View File

@ -8,7 +8,7 @@
# @AUTHOR: # @AUTHOR:
# Michał Górny <mgorny@gentoo.org> # Michał Górny <mgorny@gentoo.org>
# Mike Gilbert <floppym@gentoo.org> # Mike Gilbert <floppym@gentoo.org>
# @SUPPORTED_EAPIS: 5 6 7 8 # @SUPPORTED_EAPIS: 7 8
# @BLURB: common bits to run dev-util/ninja builder # @BLURB: common bits to run dev-util/ninja builder
# @DESCRIPTION: # @DESCRIPTION:
# This eclass provides a single function -- eninja -- that can be used # This eclass provides a single function -- eninja -- that can be used
@ -19,7 +19,7 @@
# Meson). # Meson).
case ${EAPI} in case ${EAPI} in
5|6|7|8) ;; 7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac esac
@ -76,16 +76,13 @@ get_NINJAOPTS() {
# @USAGE: [<args>...] # @USAGE: [<args>...]
# @DESCRIPTION: # @DESCRIPTION:
# Call Ninja, passing the NINJAOPTS (or converted MAKEOPTS), followed # Call Ninja, passing the NINJAOPTS (or converted MAKEOPTS), followed
# by the supplied arguments. This function dies if ninja fails. Starting # by the supplied arguments. This function dies if ninja fails. It
# with EAPI 6, it also supports being called via 'nonfatal'. # also supports being called via 'nonfatal'.
eninja() { eninja() {
local nonfatal_args=()
[[ ${EAPI} != 5 ]] && nonfatal_args+=( -n )
[[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}" [[ -n "${NINJA_DEPEND}" ]] || ewarn "Unknown value '${NINJA}' for \${NINJA}"
set -- "${NINJA}" -v $(get_NINJAOPTS) "$@" set -- "${NINJA}" -v $(get_NINJAOPTS) "$@"
echo "$@" >&2 echo "$@" >&2
"$@" || die "${nonfatal_args[@]}" "${*} failed" "$@" || die -n "${*} failed"
} }
fi fi