Skip to content

Commit

Permalink
SCons: incorrect compiler detection on msystem based environments
Browse files Browse the repository at this point in the history
As described in issue godotengine#1672 msys2 environments don't use a mingw prefix for their compiler binaries.

this patch detects MSYSTEM environment variable detects compilers directly
  • Loading branch information
enetheru committed Jan 30, 2025
1 parent 3c55ca7 commit 8b776d3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tools/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import common_compiler_flags
import my_spawn
from SCons.Tool import mingw, msvc
from SCons.Tool import clang, clangxx, mingw, msvc
from SCons.Variables import BoolVariable


Expand Down Expand Up @@ -73,14 +73,17 @@ def spawn_capture(sh, escape, cmd, args, env):


def options(opts):
mingw = os.getenv("MINGW_PREFIX", "")
msystem = os.getenv("MSYSTEM", "")
mingw_prefix = ""
if not msystem:
mingw_prefix = os.getenv("MINGW_PREFIX", "")

opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False))
opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True))
opts.Add(BoolVariable("silence_msvc", "Silence MSVC's cl/link stdout bloat, redirecting errors to stderr.", True))
opts.Add(BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False))
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler (MVSC or MinGW depending on the use_mingw flag)", False))
opts.Add("mingw_prefix", "MinGW prefix", mingw)
opts.Add("mingw_prefix", "MinGW prefix", mingw_prefix)


def exists(env):
Expand Down Expand Up @@ -132,7 +135,12 @@ def generate(env):

elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]:
env["use_mingw"] = True
mingw.generate(env)
if env["use_llvm"]:
clang.generate(env)
clangxx.generate(env)
else:
mingw.generate(env)

# Don't want lib prefixes
env["IMPLIBPREFIX"] = ""
env["SHLIBPREFIX"] = ""
Expand Down

0 comments on commit 8b776d3

Please sign in to comment.