Skip to content

Commit 9ff49b7

Browse files
authored
Merge pull request godotengine#1364 from Repiteo/non-verbose
Implement `verbose` toggle from godot repo
2 parents 048f49a + b05c21b commit 9ff49b7

File tree

2 files changed

+76
-5
lines changed

2 files changed

+76
-5
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,22 @@ jobs:
134134
135135
- name: Generate godot-cpp sources only
136136
run: |
137-
scons platform=${{ matrix.platform }} build_library=no ${{ matrix.flags }}
137+
scons platform=${{ matrix.platform }} verbose=yes build_library=no ${{ matrix.flags }}
138138
scons -c
139139
140140
- name: Build godot-cpp (debug)
141141
run: |
142-
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }}
142+
scons platform=${{ matrix.platform }} verbose=yes target=template_debug ${{ matrix.flags }}
143143
144144
- name: Build test without rebuilding godot-cpp (debug)
145145
run: |
146146
cd test
147-
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} build_library=no
147+
scons platform=${{ matrix.platform }} verbose=yes target=template_debug ${{ matrix.flags }} build_library=no
148148
149149
- name: Build test and godot-cpp (release)
150150
run: |
151151
cd test
152-
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }}
152+
scons platform=${{ matrix.platform }} verbose=yes target=template_release ${{ matrix.flags }}
153153
154154
- name: Download latest Godot artifacts
155155
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9

tools/godotcpp.py

+72-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from SCons.Variables import EnumVariable, PathVariable, BoolVariable
44
from SCons.Variables.BoolVariable import _text2bool
55
from SCons.Tool import Tool
6+
from SCons.Action import Action
67
from SCons.Builder import Builder
78
from SCons.Errors import UserError
89
from SCons.Script import ARGUMENTS
@@ -66,6 +67,67 @@ def get_custom_platforms(env):
6667
return platforms
6768

6869

70+
def no_verbose(env):
71+
colors = {}
72+
73+
# Colors are disabled in non-TTY environments such as pipes. This means
74+
# that if output is redirected to a file, it will not contain color codes
75+
if sys.stdout.isatty():
76+
colors["blue"] = "\033[0;94m"
77+
colors["bold_blue"] = "\033[1;94m"
78+
colors["reset"] = "\033[0m"
79+
else:
80+
colors["blue"] = ""
81+
colors["bold_blue"] = ""
82+
colors["reset"] = ""
83+
84+
# There is a space before "..." to ensure that source file names can be
85+
# Ctrl + clicked in the VS Code terminal.
86+
compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(
87+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
88+
)
89+
java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(
90+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
91+
)
92+
compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format(
93+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
94+
)
95+
link_program_message = "{}Linking Program {}$TARGET{} ...{}".format(
96+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
97+
)
98+
link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format(
99+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
100+
)
101+
ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format(
102+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
103+
)
104+
link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format(
105+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
106+
)
107+
java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format(
108+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
109+
)
110+
compiled_resource_message = "{}Creating Compiled Resource {}$TARGET{} ...{}".format(
111+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
112+
)
113+
generated_file_message = "{}Generating {}$TARGET{} ...{}".format(
114+
colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
115+
)
116+
117+
env.Append(CXXCOMSTR=[compile_source_message])
118+
env.Append(CCCOMSTR=[compile_source_message])
119+
env.Append(SHCCCOMSTR=[compile_shared_source_message])
120+
env.Append(SHCXXCOMSTR=[compile_shared_source_message])
121+
env.Append(ARCOMSTR=[link_library_message])
122+
env.Append(RANLIBCOMSTR=[ranlib_library_message])
123+
env.Append(SHLINKCOMSTR=[link_shared_library_message])
124+
env.Append(LINKCOMSTR=[link_program_message])
125+
env.Append(JARCOMSTR=[java_library_message])
126+
env.Append(JAVACCOMSTR=[java_compile_source_message])
127+
env.Append(RCCOMSTR=[compiled_resource_message])
128+
env.Append(GENCOMSTR=[generated_file_message])
129+
130+
69131
platforms = ["linux", "macos", "windows", "android", "ios", "web"]
70132

71133
# CPU architecture options.
@@ -254,6 +316,7 @@ def options(opts, env):
254316
)
255317
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", True))
256318
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
319+
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
257320

258321
# Add platform options (custom tools can override platforms)
259322
for pl in sorted(set(platforms + custom_platforms)):
@@ -381,8 +444,16 @@ def generate(env):
381444
env.Tool("compilation_db")
382445
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
383446

447+
# Formatting
448+
if not env["verbose"]:
449+
no_verbose(env)
450+
384451
# Builders
385-
env.Append(BUILDERS={"GodotCPPBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)})
452+
env.Append(
453+
BUILDERS={
454+
"GodotCPPBindings": Builder(action=Action(scons_generate_bindings, "$GENCOMSTR"), emitter=scons_emit_files)
455+
}
456+
)
386457
env.AddMethod(_godot_cpp, "GodotCPP")
387458

388459

0 commit comments

Comments
 (0)