[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH 3/5] distutils-r1.eclass: Support IUSE=debug for DISTUTILS_EXT
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2023-04-20 14:29:53
Message-ID: 20230420142955.1092937-4-mgorny () gentoo ! org
[Download RAW message or body]

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 <mgorny@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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic