summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-04-17 10:42:40 -0500
committerGitHub <noreply@github.com>2024-04-17 10:42:40 -0500
commit9ff49b7b1b084eb8baced50bd4aa0d2b8993f8ef (patch)
tree75952e74aea2e8cab890b7f3e1e146d76d2831ea /tools
parent048f49af39f6062bfbb3f1f7a875ad7d19003377 (diff)
parentb05c21bb1d41cfc1f94140884059da93a80ce43e (diff)
downloadredot-cpp-9ff49b7b1b084eb8baced50bd4aa0d2b8993f8ef.tar.gz
Merge pull request #1364 from Repiteo/non-verbose
Implement `verbose` toggle from godot repo
Diffstat (limited to 'tools')
-rw-r--r--tools/godotcpp.py73
1 files changed, 72 insertions, 1 deletions
diff --git a/tools/godotcpp.py b/tools/godotcpp.py
index 5ba2742..13a57e9 100644
--- a/tools/godotcpp.py
+++ b/tools/godotcpp.py
@@ -3,6 +3,7 @@ import os, sys, platform
from SCons.Variables import EnumVariable, PathVariable, BoolVariable
from SCons.Variables.BoolVariable import _text2bool
from SCons.Tool import Tool
+from SCons.Action import Action
from SCons.Builder import Builder
from SCons.Errors import UserError
from SCons.Script import ARGUMENTS
@@ -66,6 +67,67 @@ def get_custom_platforms(env):
return platforms
+def no_verbose(env):
+ colors = {}
+
+ # Colors are disabled in non-TTY environments such as pipes. This means
+ # that if output is redirected to a file, it will not contain color codes
+ if sys.stdout.isatty():
+ colors["blue"] = "\033[0;94m"
+ colors["bold_blue"] = "\033[1;94m"
+ colors["reset"] = "\033[0m"
+ else:
+ colors["blue"] = ""
+ colors["bold_blue"] = ""
+ colors["reset"] = ""
+
+ # There is a space before "..." to ensure that source file names can be
+ # Ctrl + clicked in the VS Code terminal.
+ compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ link_program_message = "{}Linking Program {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ compiled_resource_message = "{}Creating Compiled Resource {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+ generated_file_message = "{}Generating {}$TARGET{} ...{}".format(
+ colors["blue"], colors["bold_blue"], colors["blue"], colors["reset"]
+ )
+
+ env.Append(CXXCOMSTR=[compile_source_message])
+ env.Append(CCCOMSTR=[compile_source_message])
+ env.Append(SHCCCOMSTR=[compile_shared_source_message])
+ env.Append(SHCXXCOMSTR=[compile_shared_source_message])
+ env.Append(ARCOMSTR=[link_library_message])
+ env.Append(RANLIBCOMSTR=[ranlib_library_message])
+ env.Append(SHLINKCOMSTR=[link_shared_library_message])
+ env.Append(LINKCOMSTR=[link_program_message])
+ env.Append(JARCOMSTR=[java_library_message])
+ env.Append(JAVACCOMSTR=[java_compile_source_message])
+ env.Append(RCCOMSTR=[compiled_resource_message])
+ env.Append(GENCOMSTR=[generated_file_message])
+
+
platforms = ["linux", "macos", "windows", "android", "ios", "web"]
# CPU architecture options.
@@ -254,6 +316,7 @@ def options(opts, env):
)
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", True))
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
+ opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))
# Add platform options (custom tools can override platforms)
for pl in sorted(set(platforms + custom_platforms)):
@@ -381,8 +444,16 @@ def generate(env):
env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
+ # Formatting
+ if not env["verbose"]:
+ no_verbose(env)
+
# Builders
- env.Append(BUILDERS={"GodotCPPBindings": Builder(action=scons_generate_bindings, emitter=scons_emit_files)})
+ env.Append(
+ BUILDERS={
+ "GodotCPPBindings": Builder(action=Action(scons_generate_bindings, "$GENCOMSTR"), emitter=scons_emit_files)
+ }
+ )
env.AddMethod(_godot_cpp, "GodotCPP")