You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
SCons: Silence msvc output without hiding errors
This commit is contained in:
@@ -202,9 +202,7 @@ def get_opts():
|
|||||||
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
|
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
|
||||||
BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", 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("incremental_link", "Use MSVC incremental linking. May increase or decrease build times.", False),
|
||||||
BoolVariable(
|
BoolVariable("silence_msvc", "Silence MSVC's cl/link stdout bloat, redirecting any errors to stderr.", True),
|
||||||
"silence_msvc", "Silence MSVC's stdout to decrease output log bloat. May hide error messages.", False
|
|
||||||
),
|
|
||||||
("angle_libs", "Path to the ANGLE static libraries", ""),
|
("angle_libs", "Path to the ANGLE static libraries", ""),
|
||||||
# Direct3D 12 support.
|
# Direct3D 12 support.
|
||||||
(
|
(
|
||||||
@@ -398,16 +396,32 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
|
|||||||
env["MAXLINELENGTH"] = 8192 # Windows Vista and beyond, so always applicable.
|
env["MAXLINELENGTH"] = 8192 # Windows Vista and beyond, so always applicable.
|
||||||
|
|
||||||
if env["silence_msvc"]:
|
if env["silence_msvc"]:
|
||||||
env.Prepend(CCFLAGS=[">", "NUL"])
|
from tempfile import mkstemp
|
||||||
env.Prepend(LINKFLAGS=[">", "NUL"])
|
|
||||||
|
|
||||||
# "> NUL" fails if using a tempfile, circumvent by removing the argument altogether.
|
old_spawn = env["SPAWN"]
|
||||||
old_esc_func = env["TEMPFILEARGESCFUNC"]
|
|
||||||
|
|
||||||
def trim_nul(arg):
|
def spawn_capture(sh, escape, cmd, args, env):
|
||||||
return "" if arg in [">", "NUL"] else old_esc_func(arg)
|
# 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)
|
||||||
|
|
||||||
env["TEMPFILEARGESCFUNC"] = trim_nul
|
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, "rt", encoding=sys.stdout.encoding) as tmp_stdout:
|
||||||
|
# First line is always bloat, subsequent lines are always errors. This filter sends
|
||||||
|
# either just the errors to stderr, or an empty string to effectively do nothing.
|
||||||
|
sys.stderr.write("".join(tmp_stdout.readlines()[1:]))
|
||||||
|
os.remove(tmp_stdout_name)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
env["SPAWN"] = spawn_capture
|
||||||
|
|
||||||
if env["debug_crt"]:
|
if env["debug_crt"]:
|
||||||
# Always use dynamic runtime, static debug CRT breaks thread_local.
|
# Always use dynamic runtime, static debug CRT breaks thread_local.
|
||||||
|
|||||||
Reference in New Issue
Block a user