Add IUSE=debug when DISTUTILS_EXT is set, and use it to control assertions via appending -DNDEBUG or -UNDEBUG to CPPFLAGS.
Signed-off-by: Michał Górny <mgo...@gentoo.org> --- eclass/distutils-r1.eclass | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index f56fa5a51efa..257e032a6c83 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -60,6 +60,8 @@ esac # # - adds PYTHON_DEPS to DEPEND (for cross-compilation support), unless # DISTUTILS_OPTIONAL is used +# +# - adds debug flag to IUSE that controls assertions (i.e. -DNDEBUG) # @ECLASS_VARIABLE: DISTUTILS_OPTIONAL # @DEFAULT_UNSET @@ -325,6 +327,7 @@ _distutils_set_globals() { if [[ ${DISTUTILS_EXT} ]]; then DEPEND="${PYTHON_DEPS}" + IUSE="debug" fi fi } @@ -1766,6 +1769,10 @@ distutils-r1_run_phase() { local -x AR=${AR} CC=${CC} CPP=${CPP} CXX=${CXX} tc-export AR CC CPP CXX + if [[ ${DISTUTILS_EXT} ]]; then + local -x CPPFLAGS="${CPPFLAGS} $(usex debug '-UNDEBUG' '-DNDEBUG')" + fi + # How to build Python modules in different worlds... local ldopts case "${CHOST}" in -- 2.40.0