Skip to content

Commit dec2a12

Browse files
committed
SCons: Fixes for warn/error colorization
1 parent 89850d5 commit dec2a12

File tree

3 files changed

+140
-134
lines changed

3 files changed

+140
-134
lines changed

methods.py

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,41 @@ class ANSI(Enum):
3434
internal value, or an empty string in a non-colorized scope.
3535
"""
3636

37-
GRAY = "\x1b[0;30m"
38-
RED = "\x1b[0;31m"
39-
GREEN = "\x1b[0;32m"
40-
YELLOW = "\x1b[0;33m"
41-
BLUE = "\x1b[0;34m"
42-
PURPLE = "\x1b[0;35m"
43-
CYAN = "\x1b[0;36m"
44-
WHITE = "\x1b[0;37m"
45-
46-
BOLD_GRAY = "\x1b[1;90m"
47-
BOLD_RED = "\x1b[1;91m"
48-
BOLD_GREEN = "\x1b[1;92m"
49-
BOLD_YELLOW = "\x1b[1;93m"
50-
BOLD_BLUE = "\x1b[1;94m"
51-
BOLD_PURPLE = "\x1b[1;95m"
52-
BOLD_CYAN = "\x1b[1;96m"
53-
BOLD_WHITE = "\x1b[1;97m"
54-
5537
RESET = "\x1b[0m"
5638

57-
def __str__(self):
39+
BOLD = "\x1b[1m"
40+
ITALIC = "\x1b[3m"
41+
UNDERLINE = "\x1b[4m"
42+
STRIKETHROUGH = "\x1b[9m"
43+
REGULAR = "\x1b[22;23;24;29m"
44+
45+
BLACK = "\x1b[30m"
46+
RED = "\x1b[31m"
47+
GREEN = "\x1b[32m"
48+
YELLOW = "\x1b[33m"
49+
BLUE = "\x1b[34m"
50+
MAGENTA = "\x1b[35m"
51+
CYAN = "\x1b[36m"
52+
WHITE = "\x1b[37m"
53+
54+
PURPLE = "\x1b[38;5;93m"
55+
PINK = "\x1b[38;5;206m"
56+
ORANGE = "\x1b[38;5;214m"
57+
GRAY = "\x1b[38;5;244m"
58+
59+
def __str__(self) -> str:
5860
global _colorize
59-
return self.value if _colorize else ""
61+
return str(self.value) if _colorize else ""
6062

6163

6264
def print_warning(*values: object) -> None:
6365
"""Prints a warning message with formatting."""
64-
print(f"{ANSI.BOLD_YELLOW}WARNING:{ANSI.YELLOW}", *values, ANSI.RESET, file=sys.stderr)
66+
print(f"{ANSI.YELLOW}{ANSI.BOLD}WARNING:{ANSI.REGULAR}", *values, ANSI.RESET, file=sys.stderr)
6567

6668

6769
def print_error(*values: object) -> None:
6870
"""Prints an error message with formatting."""
69-
print(f"{ANSI.BOLD_RED}ERROR:{ANSI.RED}", *values, ANSI.RESET, file=sys.stderr)
71+
print(f"{ANSI.RED}{ANSI.BOLD}ERROR:{ANSI.REGULAR}", *values, ANSI.RESET, file=sys.stderr)
7072

7173

7274
def add_source_files_orig(self, sources, files, allow_gen=False):
@@ -647,33 +649,33 @@ def mySpawn(sh, escape, cmd, args, env):
647649

648650

649651
def no_verbose(env):
650-
colors = [ANSI.BLUE, ANSI.BOLD_BLUE, ANSI.RESET]
652+
colors = [ANSI.BLUE, ANSI.BOLD, ANSI.REGULAR, ANSI.RESET]
651653

652654
# There is a space before "..." to ensure that source file names can be
653655
# Ctrl + clicked in the VS Code terminal.
654-
compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
655-
java_compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
656-
compile_shared_source_message = "{0}Compiling shared {1}$SOURCE{0} ...{2}".format(*colors)
657-
link_program_message = "{0}Linking Program {1}$TARGET{0} ...{2}".format(*colors)
658-
link_library_message = "{0}Linking Static Library {1}$TARGET{0} ...{2}".format(*colors)
659-
ranlib_library_message = "{0}Ranlib Library {1}$TARGET{0} ...{2}".format(*colors)
660-
link_shared_library_message = "{0}Linking Shared Library {1}$TARGET{0} ...{2}".format(*colors)
661-
java_library_message = "{0}Creating Java Archive {1}$TARGET{0} ...{2}".format(*colors)
662-
compiled_resource_message = "{0}Creating Compiled Resource {1}$TARGET{0} ...{2}".format(*colors)
663-
generated_file_message = "{0}Generating {1}$TARGET{0} ...{2}".format(*colors)
664-
665-
env.Append(CXXCOMSTR=compile_source_message)
666-
env.Append(CCCOMSTR=compile_source_message)
667-
env.Append(SHCCCOMSTR=compile_shared_source_message)
668-
env.Append(SHCXXCOMSTR=compile_shared_source_message)
669-
env.Append(ARCOMSTR=link_library_message)
670-
env.Append(RANLIBCOMSTR=ranlib_library_message)
671-
env.Append(SHLINKCOMSTR=link_shared_library_message)
672-
env.Append(LINKCOMSTR=link_program_message)
673-
env.Append(JARCOMSTR=java_library_message)
674-
env.Append(JAVACCOMSTR=java_compile_source_message)
675-
env.Append(RCCOMSTR=compiled_resource_message)
676-
env.Append(GENCOMSTR=generated_file_message)
656+
compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
657+
java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
658+
compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format(*colors)
659+
link_program_message = "{}Linking Program {}$TARGET{} ...{}".format(*colors)
660+
link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format(*colors)
661+
ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format(*colors)
662+
link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format(*colors)
663+
java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format(*colors)
664+
compiled_resource_message = "{}Creating Compiled Resource {}$TARGET{} ...{}".format(*colors)
665+
generated_file_message = "{}Generating {}$TARGET{} ...{}".format(*colors)
666+
667+
env["CXXCOMSTR"] = compile_source_message
668+
env["CCCOMSTR"] = compile_source_message
669+
env["SHCCCOMSTR"] = compile_shared_source_message
670+
env["SHCXXCOMSTR"] = compile_shared_source_message
671+
env["ARCOMSTR"] = link_library_message
672+
env["RANLIBCOMSTR"] = ranlib_library_message
673+
env["SHLINKCOMSTR"] = link_shared_library_message
674+
env["LINKCOMSTR"] = link_program_message
675+
env["JARCOMSTR"] = java_library_message
676+
env["JAVACCOMSTR"] = java_compile_source_message
677+
env["RCCOMSTR"] = compiled_resource_message
678+
env["GENCOMSTR"] = generated_file_message
677679

678680

679681
def detect_visual_c_compiler_version(tools_env):

modules/text_server_adv/gdextension_build/methods.py

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,59 +15,61 @@ class ANSI(Enum):
1515
internal value, or an empty string in a non-colorized scope.
1616
"""
1717

18-
GRAY = "\x1b[0;30m"
19-
RED = "\x1b[0;31m"
20-
GREEN = "\x1b[0;32m"
21-
YELLOW = "\x1b[0;33m"
22-
BLUE = "\x1b[0;34m"
23-
PURPLE = "\x1b[0;35m"
24-
CYAN = "\x1b[0;36m"
25-
WHITE = "\x1b[0;37m"
26-
27-
BOLD_GRAY = "\x1b[1;90m"
28-
BOLD_RED = "\x1b[1;91m"
29-
BOLD_GREEN = "\x1b[1;92m"
30-
BOLD_YELLOW = "\x1b[1;93m"
31-
BOLD_BLUE = "\x1b[1;94m"
32-
BOLD_PURPLE = "\x1b[1;95m"
33-
BOLD_CYAN = "\x1b[1;96m"
34-
BOLD_WHITE = "\x1b[1;97m"
35-
3618
RESET = "\x1b[0m"
3719

38-
def __str__(self):
20+
BOLD = "\x1b[1m"
21+
ITALIC = "\x1b[3m"
22+
UNDERLINE = "\x1b[4m"
23+
STRIKETHROUGH = "\x1b[9m"
24+
REGULAR = "\x1b[22;23;24;29m"
25+
26+
BLACK = "\x1b[30m"
27+
RED = "\x1b[31m"
28+
GREEN = "\x1b[32m"
29+
YELLOW = "\x1b[33m"
30+
BLUE = "\x1b[34m"
31+
MAGENTA = "\x1b[35m"
32+
CYAN = "\x1b[36m"
33+
WHITE = "\x1b[37m"
34+
35+
PURPLE = "\x1b[38;5;93m"
36+
PINK = "\x1b[38;5;206m"
37+
ORANGE = "\x1b[38;5;214m"
38+
GRAY = "\x1b[38;5;244m"
39+
40+
def __str__(self) -> str:
3941
global _colorize
40-
return self.value if _colorize else ""
42+
return str(self.value) if _colorize else ""
4143

4244

4345
def no_verbose(env):
44-
colors = [ANSI.BLUE, ANSI.BOLD_BLUE, ANSI.RESET]
46+
colors = [ANSI.BLUE, ANSI.BOLD, ANSI.REGULAR, ANSI.RESET]
4547

4648
# There is a space before "..." to ensure that source file names can be
4749
# Ctrl + clicked in the VS Code terminal.
48-
compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
49-
java_compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
50-
compile_shared_source_message = "{0}Compiling shared {1}$SOURCE{0} ...{2}".format(*colors)
51-
link_program_message = "{0}Linking Program {1}$TARGET{0} ...{2}".format(*colors)
52-
link_library_message = "{0}Linking Static Library {1}$TARGET{0} ...{2}".format(*colors)
53-
ranlib_library_message = "{0}Ranlib Library {1}$TARGET{0} ...{2}".format(*colors)
54-
link_shared_library_message = "{0}Linking Shared Library {1}$TARGET{0} ...{2}".format(*colors)
55-
java_library_message = "{0}Creating Java Archive {1}$TARGET{0} ...{2}".format(*colors)
56-
compiled_resource_message = "{0}Creating Compiled Resource {1}$TARGET{0} ...{2}".format(*colors)
57-
generated_file_message = "{0}Generating {1}$TARGET{0} ...{2}".format(*colors)
58-
59-
env.Append(CXXCOMSTR=compile_source_message)
60-
env.Append(CCCOMSTR=compile_source_message)
61-
env.Append(SHCCCOMSTR=compile_shared_source_message)
62-
env.Append(SHCXXCOMSTR=compile_shared_source_message)
63-
env.Append(ARCOMSTR=link_library_message)
64-
env.Append(RANLIBCOMSTR=ranlib_library_message)
65-
env.Append(SHLINKCOMSTR=link_shared_library_message)
66-
env.Append(LINKCOMSTR=link_program_message)
67-
env.Append(JARCOMSTR=java_library_message)
68-
env.Append(JAVACCOMSTR=java_compile_source_message)
69-
env.Append(RCCOMSTR=compiled_resource_message)
70-
env.Append(GENCOMSTR=generated_file_message)
50+
compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
51+
java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
52+
compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format(*colors)
53+
link_program_message = "{}Linking Program {}$TARGET{} ...{}".format(*colors)
54+
link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format(*colors)
55+
ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format(*colors)
56+
link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format(*colors)
57+
java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format(*colors)
58+
compiled_resource_message = "{}Creating Compiled Resource {}$TARGET{} ...{}".format(*colors)
59+
generated_file_message = "{}Generating {}$TARGET{} ...{}".format(*colors)
60+
61+
env["CXXCOMSTR"] = compile_source_message
62+
env["CCCOMSTR"] = compile_source_message
63+
env["SHCCCOMSTR"] = compile_shared_source_message
64+
env["SHCXXCOMSTR"] = compile_shared_source_message
65+
env["ARCOMSTR"] = link_library_message
66+
env["RANLIBCOMSTR"] = ranlib_library_message
67+
env["SHLINKCOMSTR"] = link_shared_library_message
68+
env["LINKCOMSTR"] = link_program_message
69+
env["JARCOMSTR"] = java_library_message
70+
env["JAVACCOMSTR"] = java_compile_source_message
71+
env["RCCOMSTR"] = compiled_resource_message
72+
env["GENCOMSTR"] = generated_file_message
7173

7274

7375
def disable_warnings(self):

modules/text_server_fb/gdextension_build/methods.py

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,59 +15,61 @@ class ANSI(Enum):
1515
internal value, or an empty string in a non-colorized scope.
1616
"""
1717

18-
GRAY = "\x1b[0;30m"
19-
RED = "\x1b[0;31m"
20-
GREEN = "\x1b[0;32m"
21-
YELLOW = "\x1b[0;33m"
22-
BLUE = "\x1b[0;34m"
23-
PURPLE = "\x1b[0;35m"
24-
CYAN = "\x1b[0;36m"
25-
WHITE = "\x1b[0;37m"
26-
27-
BOLD_GRAY = "\x1b[1;90m"
28-
BOLD_RED = "\x1b[1;91m"
29-
BOLD_GREEN = "\x1b[1;92m"
30-
BOLD_YELLOW = "\x1b[1;93m"
31-
BOLD_BLUE = "\x1b[1;94m"
32-
BOLD_PURPLE = "\x1b[1;95m"
33-
BOLD_CYAN = "\x1b[1;96m"
34-
BOLD_WHITE = "\x1b[1;97m"
35-
3618
RESET = "\x1b[0m"
3719

38-
def __str__(self):
20+
BOLD = "\x1b[1m"
21+
ITALIC = "\x1b[3m"
22+
UNDERLINE = "\x1b[4m"
23+
STRIKETHROUGH = "\x1b[9m"
24+
REGULAR = "\x1b[22;23;24;29m"
25+
26+
BLACK = "\x1b[30m"
27+
RED = "\x1b[31m"
28+
GREEN = "\x1b[32m"
29+
YELLOW = "\x1b[33m"
30+
BLUE = "\x1b[34m"
31+
MAGENTA = "\x1b[35m"
32+
CYAN = "\x1b[36m"
33+
WHITE = "\x1b[37m"
34+
35+
PURPLE = "\x1b[38;5;93m"
36+
PINK = "\x1b[38;5;206m"
37+
ORANGE = "\x1b[38;5;214m"
38+
GRAY = "\x1b[38;5;244m"
39+
40+
def __str__(self) -> str:
3941
global _colorize
40-
return self.value if _colorize else ""
42+
return str(self.value) if _colorize else ""
4143

4244

4345
def no_verbose(env):
44-
colors = [ANSI.BLUE, ANSI.BOLD_BLUE, ANSI.RESET]
46+
colors = [ANSI.BLUE, ANSI.BOLD, ANSI.REGULAR, ANSI.RESET]
4547

4648
# There is a space before "..." to ensure that source file names can be
4749
# Ctrl + clicked in the VS Code terminal.
48-
compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
49-
java_compile_source_message = "{0}Compiling {1}$SOURCE{0} ...{2}".format(*colors)
50-
compile_shared_source_message = "{0}Compiling shared {1}$SOURCE{0} ...{2}".format(*colors)
51-
link_program_message = "{0}Linking Program {1}$TARGET{0} ...{2}".format(*colors)
52-
link_library_message = "{0}Linking Static Library {1}$TARGET{0} ...{2}".format(*colors)
53-
ranlib_library_message = "{0}Ranlib Library {1}$TARGET{0} ...{2}".format(*colors)
54-
link_shared_library_message = "{0}Linking Shared Library {1}$TARGET{0} ...{2}".format(*colors)
55-
java_library_message = "{0}Creating Java Archive {1}$TARGET{0} ...{2}".format(*colors)
56-
compiled_resource_message = "{0}Creating Compiled Resource {1}$TARGET{0} ...{2}".format(*colors)
57-
generated_file_message = "{0}Generating {1}$TARGET{0} ...{2}".format(*colors)
58-
59-
env.Append(CXXCOMSTR=compile_source_message)
60-
env.Append(CCCOMSTR=compile_source_message)
61-
env.Append(SHCCCOMSTR=compile_shared_source_message)
62-
env.Append(SHCXXCOMSTR=compile_shared_source_message)
63-
env.Append(ARCOMSTR=link_library_message)
64-
env.Append(RANLIBCOMSTR=ranlib_library_message)
65-
env.Append(SHLINKCOMSTR=link_shared_library_message)
66-
env.Append(LINKCOMSTR=link_program_message)
67-
env.Append(JARCOMSTR=java_library_message)
68-
env.Append(JAVACCOMSTR=java_compile_source_message)
69-
env.Append(RCCOMSTR=compiled_resource_message)
70-
env.Append(GENCOMSTR=generated_file_message)
50+
compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
51+
java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
52+
compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format(*colors)
53+
link_program_message = "{}Linking Program {}$TARGET{} ...{}".format(*colors)
54+
link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format(*colors)
55+
ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format(*colors)
56+
link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format(*colors)
57+
java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format(*colors)
58+
compiled_resource_message = "{}Creating Compiled Resource {}$TARGET{} ...{}".format(*colors)
59+
generated_file_message = "{}Generating {}$TARGET{} ...{}".format(*colors)
60+
61+
env["CXXCOMSTR"] = compile_source_message
62+
env["CCCOMSTR"] = compile_source_message
63+
env["SHCCCOMSTR"] = compile_shared_source_message
64+
env["SHCXXCOMSTR"] = compile_shared_source_message
65+
env["ARCOMSTR"] = link_library_message
66+
env["RANLIBCOMSTR"] = ranlib_library_message
67+
env["SHLINKCOMSTR"] = link_shared_library_message
68+
env["LINKCOMSTR"] = link_program_message
69+
env["JARCOMSTR"] = java_library_message
70+
env["JAVACCOMSTR"] = java_compile_source_message
71+
env["RCCOMSTR"] = compiled_resource_message
72+
env["GENCOMSTR"] = generated_file_message
7173

7274

7375
def disable_warnings(self):

0 commit comments

Comments
 (0)