From 4c835c49219361b08f03b71d1f944e2e74f23545 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 26 Feb 2023 08:52:04 -0700 Subject: Fix Configure tests on win32/msys2 If selecting tool 'mingw', and using an msys2 Python, paths constructed to run a compiled check ended up with forward slashes, which gave an error when executed through cmd.exe. Cygwin does not have the same problem, as it uses "sh" as the shell when executing the command. Signed-off-by: Mats Wichmann --- CHANGES.txt | 3 +++ RELEASE.txt | 3 +++ SCons/SConf.py | 6 ++++++ SCons/Tool/mingw.py | 3 ++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6052a21..b2962d3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -145,6 +145,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER We take advantage that their order is now stable based on insertion order in Python 3.5+ - Added/modifed unit and system tests to verify these changes. + - Fixed: when using the mingw tool, if an msys2 Python is used (os.sep + is '/' rather than the Windows default '\'), certain Configure checks + could fail due to the construction of the path to run the compiled check. RELEASE 4.4.0 - Sat, 30 Jul 2022 14:08:29 -0700 diff --git a/RELEASE.txt b/RELEASE.txt index 91dbb86..04590ab 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -113,6 +113,9 @@ FIXES of duplicate macros now works for both valued and unvalued forms. - Handling of CPPDEFINES macros via Prepend and PrependUnique now works (previously this was special-cased only for Append and AppendUnique). +- Fixed: when using the mingw tool, if an msys2 Python is used (os.sep + is '/' rather than the Windows default '\'), certain Configure checks + could fail due to the construction of the path to run the compiled check. IMPROVEMENTS ------------ diff --git a/SCons/SConf.py b/SCons/SConf.py index 136be27..7dc950a 100644 --- a/SCons/SConf.py +++ b/SCons/SConf.py @@ -714,6 +714,12 @@ class SConfBase: if ok: prog = self.lastTarget pname = prog.get_internal_path() + if sys.platform == "win32" and os.sep == "/": + # msys might have a Python where os.sep='/' on Windows. + # That builds a path in the env.Command below which breaks + # if the SHELL used is cmd because 'pname' will always have + # an os.sep in it. + pname = pname.replace(os.sep, os.altsep) output = self.confdir.File(os.path.basename(pname)+'.out') node = self.env.Command(output, prog, [ [ pname, ">", "${TARGET}"] ]) ok = self.BuildNodes(node) diff --git a/SCons/Tool/mingw.py b/SCons/Tool/mingw.py index 8e7ac2d..78b5a8d 100644 --- a/SCons/Tool/mingw.py +++ b/SCons/Tool/mingw.py @@ -48,7 +48,8 @@ mingw_base_paths = [ r'C:\msys64\mingw64\bin', r'C:\cygwin\bin', r'C:\msys', - r'C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin' + r'C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin', + os.path.expandvars(r'%LocalAppData%\Programs\msys64\usr\bin'), ] -- cgit v0.12