[m-rev.] for review: let host / target env types be overridden

Julien Fischer jfischer at opturion.com
Tue Dec 30 04:08:12 AEDT 2025


For review by anyone.

---------------------

Let host / target env types be overridden.

Let the host and target env types be overridden in the environment.
If not set in the environment, then they default to the values
determined by the configure script.

Use this capability to let Mercury compilers built in one of the MSYS2
environments be usable from both the MSYS2 shell (via the mmc script) and
also from cmd.exe (via the mercury.bat batch file), _without_ requiring any
modifications to Mercury.config.

scripts/Mercury.config.in:
    Add two new variables that hold the host and target env type.

scripts/mercury.bat.in:
    Set the host and target env types to "windows" when we are
    invoked via this batch file.

Julien.

diff --git a/scripts/Mercury.config.in b/scripts/Mercury.config.in
index a8b4cb271..98f5c7081 100644
--- a/scripts/Mercury.config.in
+++ b/scripts/Mercury.config.in
@@ -55,6 +55,8 @@ MERCURY_CSHARP_COMPILER=@CSC@
 MERCURY_CSHARP_COMPILER_TYPE=@CSHARP_COMPILER_TYPE@
 MERCURY_CLI_INTERPRETER=@CLI_INTERPRETER@
 MERCURY_TARGET_ARCH=@FULLARCH@
+MERCURY_HOST_ENV_TYPE=@HOST_ENV_TYPE@
+MERCURY_TARGET_ENV_TYPE=@TARGET_ENV_TYPE@
 # $(MATH_LIB) needs to be defined because it may
 # be used by the substitution for SHARED_LIBS.
 MATH_LIB=$(MERCURY_MATH_LIB)
@@ -148,9 +150,9 @@ DEFAULT_MCFLAGS=\
         --linker-error-undefined-flag "@ERROR_UNDEFINED@" \
     --install-prefix "@PREFIX@" \
     --default-opt-level "$(MERCURY_DEFAULT_OPT_LEVEL)" \
-    --host-env-type "@HOST_ENV_TYPE@" \
+    --host-env-type "$(MERCURY_HOST_ENV_TYPE)" \
         --target-arch "$(MERCURY_TARGET_ARCH)" \
-        --target-env-type "@TARGET_ENV_TYPE@" \
+        --target-env-type "$(MERCURY_TARGET_ENV_TYPE)" \
         --num-real-r-regs "@NUM_REAL_R_REGS@" \
         --num-real-r-temps "@NUM_REAL_R_TEMPS@" \
         --conf-low-tag-bits "@LOW_TAG_BITS@" \
diff --git a/scripts/mercury.bat.in b/scripts/mercury.bat.in
index 07cf14ea9..bfa51373a 100644
--- a/scripts/mercury.bat.in
+++ b/scripts/mercury.bat.in
@@ -2,7 +2,7 @@
 rem @configure_input@
 rem ---------------------------------------------------------------------------
 rem Copyright (C) 2001, 2003, 2005, 2011 The University of Melbourne.
-rem Copyright (C) 2020, 2024 The Mercury team.
+rem Copyright (C) 2020, 2024-2025 The Mercury team.
 rem This file may only be copied under the terms of the GNU General
 rem Public License - see the file COPYING in the Mercury distribution.
 rem ---------------------------------------------------------------------------
@@ -23,5 +23,7 @@ setlocal enableextensions

 set "MERCURY_CONFIG_DIR=@CONFIG_LIBDIR@"
 set "MERCURY_COMPILER=@PREFIX@\bin\mercury_compile"
+set "MERCURY_HOST_ENV_TYPE=windows"
+set "MERCURY_TARGET_ENV_TYPE=windows"

 %MERCURY_COMPILER% %*


More information about the reviews mailing list