eclass/flag-o-matic: Sync with Gentoo

It's from Gentoo commit 0391884e82912c23dda0c74ecdb16752f5e2d1cd.

Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
Flatcar Buildbot 2026-03-23 07:34:06 +00:00
parent 0b61fae9e9
commit 10fd92b3c9

View File

@ -4,7 +4,7 @@
# @ECLASS: flag-o-matic.eclass
# @MAINTAINER:
# toolchain@gentoo.org
# @SUPPORTED_EAPIS: 7 8
# @SUPPORTED_EAPIS: 7 8 9
# @BLURB: common functions to manipulate and query toolchain flags
# @DESCRIPTION:
# This eclass contains a suite of functions to help developers sanely
@ -14,7 +14,7 @@ if [[ -z ${_FLAG_O_MATIC_ECLASS} ]]; then
_FLAG_O_MATIC_ECLASS=1
case ${EAPI} in
7|8) ;;
7|8|9) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
@ -853,9 +853,24 @@ get-flag() {
# `get-flag march` == "i686"
for var in $(all-flag-vars) ; do
for f in ${!var} ; do
if [ "${f/${findflag}}" != "${f}" ] ; then
printf "%s\n" "${f/-${findflag}=}"
return 0
if [[ ${EAPI} = [78] && -z "${_FLAG_O_MATIC_TESTS_FAKE_EAPI_NINE}" ]]; then
if [[ "${f/${findflag}}" != "${f}" ]] ; then
printf "%s\n" "${f/-${findflag}=}"
return 0
fi
else
# Print RHS for "flag" (no leading "-")
if [[ "${f#-${findflag}=}" != "${f}" ]] ; then
printf "%s\n" "${f#-${findflag}=}"
return 0
fi
# Print full match for any of:
# "-flag" with leading "-"
# "flag" without leading "-" that has no unmatched succeeding =value
if [[ ${f} = -${findflag#-} || ${f%=*} = ${findflag} ]] ; then
printf "%s\n" "${f}"
return 0
fi
fi
done
done