summaryrefslogtreecommitdiffstats
path: root/modules/text_server_fb/gdextension_build/SConstruct
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-04-26 12:35:07 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-04-28 16:24:48 -0500
commite0e8ce1fc00dad7cbbcd4a1f4fcedea4b760e6be (patch)
treec6bd29831b3b146f4c67f36c101b9f150331a485 /modules/text_server_fb/gdextension_build/SConstruct
parent6118592c6d88350d01f74faff6fd49754f84a7d0 (diff)
downloadredot-engine-e0e8ce1fc00dad7cbbcd4a1f4fcedea4b760e6be.tar.gz
SCons: Colorize warnings/errors during generation
Diffstat (limited to 'modules/text_server_fb/gdextension_build/SConstruct')
-rw-r--r--modules/text_server_fb/gdextension_build/SConstruct27
1 files changed, 22 insertions, 5 deletions
diff --git a/modules/text_server_fb/gdextension_build/SConstruct b/modules/text_server_fb/gdextension_build/SConstruct
index 29801ede8e..07940719eb 100644
--- a/modules/text_server_fb/gdextension_build/SConstruct
+++ b/modules/text_server_fb/gdextension_build/SConstruct
@@ -1,10 +1,20 @@
#!/usr/bin/env python
import atexit
-import os
import sys
import methods
import time
+# Enable ANSI escape code support on Windows 10 and later (for colored console output).
+# <https://github.com/python/cpython/issues/73245>
+if sys.platform == "win32":
+ from ctypes import windll, c_int, byref
+
+ stdout_handle = windll.kernel32.GetStdHandle(c_int(-11))
+ mode = c_int(0)
+ windll.kernel32.GetConsoleMode(c_int(stdout_handle), byref(mode))
+ mode = c_int(mode.value | 4)
+ windll.kernel32.SetConsoleMode(c_int(stdout_handle), mode)
+
# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
@@ -28,7 +38,7 @@ opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", Fa
opts.Update(env)
if not env["verbose"]:
- methods.no_verbose(sys, env)
+ methods.no_verbose(env)
# ThorVG
if env["thorvg_enabled"] and env["freetype_enabled"]:
@@ -311,9 +321,16 @@ Default(library)
def print_elapsed_time():
- elapsed_time_sec = round(time.time() - time_at_start, 3)
- time_ms = round((elapsed_time_sec % 1) * 1000)
- print("[Time elapsed: {}.{:03}]".format(time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)), time_ms))
+ elapsed_time_sec = round(time.time() - time_at_start, 2)
+ time_centiseconds = round((elapsed_time_sec % 1) * 100)
+ print(
+ "{}[Time elapsed: {}.{:02}]{}".format(
+ methods.ANSI.GRAY,
+ time.strftime("%H:%M:%S", time.gmtime(elapsed_time_sec)),
+ time_centiseconds,
+ methods.ANSI.RESET,
+ )
+ )
atexit.register(print_elapsed_time)