|
3 | 3 | from SCons.Variables import EnumVariable, PathVariable, BoolVariable
|
4 | 4 | from SCons.Variables.BoolVariable import _text2bool
|
5 | 5 | from SCons.Tool import Tool
|
| 6 | +from SCons.Action import Action |
6 | 7 | from SCons.Builder import Builder
|
7 | 8 | from SCons.Errors import UserError
|
8 | 9 | from SCons.Script import ARGUMENTS
|
@@ -66,6 +67,67 @@ def get_custom_platforms(env):
|
66 | 67 | return platforms
|
67 | 68 |
|
68 | 69 |
|
| 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 | + |
69 | 131 | platforms = ["linux", "macos", "windows", "android", "ios", "web"]
|
70 | 132 |
|
71 | 133 | # CPU architecture options.
|
@@ -254,6 +316,7 @@ def options(opts, env):
|
254 | 316 | )
|
255 | 317 | opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", True))
|
256 | 318 | 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)) |
257 | 320 |
|
258 | 321 | # Add platform options (custom tools can override platforms)
|
259 | 322 | for pl in sorted(set(platforms + custom_platforms)):
|
@@ -381,8 +444,16 @@ def generate(env):
|
381 | 444 | env.Tool("compilation_db")
|
382 | 445 | env.Alias("compiledb", env.CompilationDatabase(normalize_path(env["compiledb_file"], env)))
|
383 | 446 |
|
| 447 | + # Formatting |
| 448 | + if not env["verbose"]: |
| 449 | + no_verbose(env) |
| 450 | + |
384 | 451 | # 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 | + ) |
386 | 457 | env.AddMethod(_godot_cpp, "GodotCPP")
|
387 | 458 |
|
388 | 459 |
|
|
0 commit comments