summaryrefslogtreecommitdiffstats
path: root/platform/windows/detect.py
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows/detect.py')
-rw-r--r--platform/windows/detect.py46
1 files changed, 44 insertions, 2 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 4585884859..f34d479345 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -202,6 +202,7 @@ def get_opts():
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False),
BoolVariable("incremental_link", "Use MSVC incremental linking. May increase or decrease build times.", False),
+ BoolVariable("silence_msvc", "Silence MSVC's cl/link stdout bloat, redirecting any errors to stderr.", True),
("angle_libs", "Path to the ANGLE static libraries", ""),
# Direct3D 12 support.
(
@@ -392,6 +393,39 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
## Compile/link flags
+ env["MAXLINELENGTH"] = 8192 # Windows Vista and beyond, so always applicable.
+
+ if env["silence_msvc"]:
+ from tempfile import mkstemp
+
+ old_spawn = env["SPAWN"]
+
+ def spawn_capture(sh, escape, cmd, args, env):
+ # We only care about cl/link, process everything else as normal.
+ if args[0] not in ["cl", "link"]:
+ return old_spawn(sh, escape, cmd, args, env)
+
+ tmp_stdout, tmp_stdout_name = mkstemp()
+ os.close(tmp_stdout)
+ args.append(f">{tmp_stdout_name}")
+ ret = old_spawn(sh, escape, cmd, args, env)
+
+ try:
+ with open(tmp_stdout_name, "rb") as tmp_stdout:
+ # First line is always bloat, subsequent lines are always errors. If content
+ # exists after discarding the first line, safely decode & send to stderr.
+ tmp_stdout.readline()
+ content = tmp_stdout.read()
+ if content:
+ sys.stderr.write(content.decode(sys.stdout.encoding, "replace"))
+ os.remove(tmp_stdout_name)
+ except OSError:
+ pass
+
+ return ret
+
+ env["SPAWN"] = spawn_capture
+
if env["debug_crt"]:
# Always use dynamic runtime, static debug CRT breaks thread_local.
env.AppendUnique(CCFLAGS=["/MDd"])
@@ -422,6 +456,10 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
else:
print("Missing environment variable: WindowsSdkDir")
+ if int(env["target_win_version"], 16) < 0x0601:
+ print("`target_win_version` should be 0x0601 or higher (Windows 7).")
+ sys.exit(255)
+
env.AppendUnique(
CPPDEFINES=[
"WINDOWS_ENABLED",
@@ -486,7 +524,7 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
sys.exit(255)
env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"])
- LIBS += ["d3d12", "dxgi", "dxguid"]
+ LIBS += ["dxgi", "dxguid"]
LIBS += ["version"] # Mesa dependency.
# Needed for avoiding C1128.
@@ -651,6 +689,10 @@ def configure_mingw(env: "SConsEnvironment"):
## Compile flags
+ if int(env["target_win_version"], 16) < 0x0601:
+ print("`target_win_version` should be 0x0601 or higher (Windows 7).")
+ sys.exit(255)
+
if not env["use_llvm"]:
env.Append(CCFLAGS=["-mwindows"])
@@ -711,7 +753,7 @@ def configure_mingw(env: "SConsEnvironment"):
sys.exit(255)
env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"])
- env.Append(LIBS=["d3d12", "dxgi", "dxguid"])
+ env.Append(LIBS=["dxgi", "dxguid"])
# PIX
if not env["arch"] in ["x86_64", "arm64"] or env["pix_path"] == "" or not os.path.exists(env["pix_path"]):