From 97b2e3580cb85b4d6b6293a2a1e55522fe20106a Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:20:50 +0300 Subject: [PATCH] Fix LLVM/MinGW build on Windows. --- godot-tools/windows.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/godot-tools/windows.py b/godot-tools/windows.py index 39f00bc..5ccec45 100644 --- a/godot-tools/windows.py +++ b/godot-tools/windows.py @@ -7,11 +7,14 @@ def options(opts): + mingw = 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_clang_cl", "Use the clang driver 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("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False)) opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler", False)) + opts.Add("mingw_prefix", "MinGW prefix", mingw) def exists(env): @@ -53,7 +56,7 @@ def generate(env): env["CC"] = "clang-cl" env["CXX"] = "clang-cl" - elif sys.platform == "win32" or sys.platform == "msys": + elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]: env["use_mingw"] = True mingw.generate(env) env.Append(CPPDEFINES=["MINGW_ENABLED"]) @@ -68,14 +71,18 @@ def generate(env): else: env["use_mingw"] = True # Cross-compilation using MinGW + prefix = "" + if env["mingw_prefix"]: + prefix = env["mingw_prefix"] + "/bin/" + if env["arch"] == "x86_64": - prefix = "x86_64" + prefix += "x86_64" elif env["arch"] == "arm64": - prefix = "aarch64" + prefix += "aarch64" elif env["arch"] == "arm32": - prefix = "armv7" + prefix += "armv7" elif env["arch"] == "x86_32": - prefix = "i686" + prefix += "i686" if env["use_llvm"]: env["CXX"] = prefix + "-w64-mingw32-clang++" @@ -105,3 +112,6 @@ def generate(env): "-Wl,--no-undefined", ] ) + + if (sys.platform == "win32" or sys.platform == "msys"): + my_spawn.configure(env)