commit:     1b5df51e2e9f98aa237b539ca44d7b25c96b6525
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Fri May  3 08:19:45 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri May  3 08:19:45 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=1b5df51e

dlang-utils.eclass: add dlang_get_debug_flag

Signed-off-by: Andrei Horodniceanu <a.horodniceanu <AT> proton.me>

 eclass/dlang-utils.eclass   | 19 +++++++++++++++++++
 eclass/tests/dlang-utils.sh |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/eclass/dlang-utils.eclass b/eclass/dlang-utils.eclass
index 60eee53..3c634d6 100644
--- a/eclass/dlang-utils.eclass
+++ b/eclass/dlang-utils.eclass
@@ -277,6 +277,19 @@ dlang_get_be_version() {
        echo "${DLANG_BE_VERSION}"
 }
 
+# @FUNCTION: dlang_get_debug_flag
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the compiler debug flag for the given
+# implementation. If no implementation is provided, ${EDC} will be
+# used.
+dlang_get_debug_flag() {
+       debug-print-function ${FUNCNAME} "${@}"
+
+       _dlang_export "${@}" DLANG_DEBUG_FLAG
+       echo "${DLANG_DEBUG_FLAG}"
+}
+
 # @FUNCTION: dlang_get_linker_flag
 # @USAGE: [<impl>]
 # @DESCRIPTION:
@@ -984,6 +997,12 @@ _dlang_export() {
                                export DLANG_DMDW_LDFLAGS=${DLANG_LDFLAGS}
                                debug-print "${FUNCNAME}: DLANG_DMDW_LDFLAGS = 
${DLANG_DMDW_LDFLAGS}"
                                ;;
+                       DLANG_DEBUG_FLAG)
+                               export DLANG_DEBUG_FLAG=$(
+                                       _dlang_echo_implementation_string \
+                                               "${impl}" "-debug" "-fdebug" 
"-d-debug")
+                               debug-print "${FUNCNAME}: DLANG_DEBUG_FLAG = 
${DLANG_DEBUG_FLAG}"
+                               ;;
                        DLANG_LINKER_FLAG)
                                export DLANG_LINKER_FLAG=$(
                                        _dlang_echo_implementation_string \

diff --git a/eclass/tests/dlang-utils.sh b/eclass/tests/dlang-utils.sh
index 0f4b6da..28d10d9 100755
--- a/eclass/tests/dlang-utils.sh
+++ b/eclass/tests/dlang-utils.sh
@@ -95,6 +95,10 @@ test_var DLANG_DMDW_LDFLAGS dmd-2.106 "-L-O1 -L--as-needed 
-garbage"
 test_var DLANG_DMDW_LDFLAGS gdc-13 "-L-O1 -L--as-needed -garbage 
-q,-shared-libphobos"
 test_var DLANG_DMDW_LDFLAGS ldc2-1_35 "-L-O1 -L--as-needed -garbage"
 
+test_var DLANG_DEBUG_FLAG dmd-2.102 "-debug"
+test_var DLANG_DEBUG_FLAG gdc-13 "-fdebug"
+test_var DLANG_DEBUG_FLAG ldc2-1_36  "-d-debug"
+
 test_var DLANG_LINKER_FLAG dmd-2.102 "-L"
 test_var DLANG_LINKER_FLAG gdc-13 "-Wl,"
 test_var DLANG_LINKER_FLAG ldc2-1_36  "-L"

Reply via email to