commit:     68c34733df78f4965695a3ff90c8ae5f54d00b94
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Mon May 12 02:58:00 2025 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Mon May 12 02:59:21 2025 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=68c34733

dlang-utils.eclass: Add dlang_get_main_flag helper

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 87b3133..f2f6515 100644
--- a/eclass/dlang-utils.eclass
+++ b/eclass/dlang-utils.eclass
@@ -303,6 +303,19 @@ dlang_get_linker_flag() {
        echo "${DLANG_LINKER_FLAG}"
 }
 
+# @FUNCTION: dlang_get_main_flag
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the compiler -main flag (include an empty main) for
+# the given implementation. If no implementation is provided, ${EDC}
+# will be used.
+dlang_get_main_flag() {
+       debug-print-function ${FUNCNAME} "${@}"
+
+       _dlang_export "${@}" DLANG_MAIN_FLAG
+       echo "${DLANG_MAIN_FLAG}"
+}
+
 # @FUNCTION: dlang_get_model_flag
 # @USAGE: [<impl>]
 # @DESCRIPTION:
@@ -1014,6 +1027,12 @@ _dlang_export() {
                                                "${impl}" "-L" "-Wl," "-L")
                                debug-print "${FUNCNAME}: DLANG_LINKER_FLAG = 
${DLANG_LINKER_FLAG}"
                                ;;
+                       DLANG_MAIN_FLAG)
+                               export DLANG_MAIN_FLAG=$(
+                                       _dlang_echo_implementation_string \
+                                               "${impl}" "-main" "-fmain" 
"-main")
+                               debug-print "${FUNCNAME}: DLANG_MAIN_FLAG = 
${DLANG_MAIN_FLAG}"
+                               ;;
                        DLANG_OUTPUT_FLAG)
                                export DLANG_OUTPUT_FLAG=$(
                                        _dlang_echo_implementation_string \

diff --git a/eclass/tests/dlang-utils.sh b/eclass/tests/dlang-utils.sh
index 0bb4d51..322266d 100755
--- a/eclass/tests/dlang-utils.sh
+++ b/eclass/tests/dlang-utils.sh
@@ -104,6 +104,10 @@ 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"
 
+test_var DLANG_MAIN_FLAG dmd-2.104 "-main"
+test_var DLANG_MAIN_FLAG gdc-15 "-fmain"
+test_var DLANG_MAIN_FLAG ldc2-1.40  "-main"
+
 test_var DLANG_OUTPUT_FLAG dmd-2.102 "-of"
 test_var DLANG_OUTPUT_FLAG gdc-13 "-o"
 test_var DLANG_OUTPUT_FLAG ldc2-1_36  "-of="

Reply via email to