mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
SCons: Refactor color output implementation
This commit is contained in:
parent
d2ada64a03
commit
a29294fddc
11 changed files with 211 additions and 304 deletions
|
|
@ -1,14 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import atexit
|
||||
import time
|
||||
from typing import TYPE_CHECKING
|
||||
# ruff: noqa: F821
|
||||
|
||||
import methods
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
# For the reference:
|
||||
# - CCFLAGS are compilation flags shared between C and C++
|
||||
# - CFLAGS are for C-specific compilation flags
|
||||
|
|
@ -17,8 +11,6 @@ if TYPE_CHECKING:
|
|||
# - CPPDEFINES are for pre-processor defines
|
||||
# - LINKFLAGS are for linking flags
|
||||
|
||||
time_at_start = time.time()
|
||||
|
||||
env = SConscript("./godot-cpp/SConstruct")
|
||||
env.__class__.disable_warnings = methods.disable_warnings
|
||||
|
||||
|
|
@ -33,9 +25,6 @@ opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", Fa
|
|||
|
||||
opts.Update(env)
|
||||
|
||||
if not env["verbose"]:
|
||||
methods.no_verbose(env)
|
||||
|
||||
if env["platform"] == "windows" and not env["use_mingw"]:
|
||||
env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding.
|
||||
|
||||
|
|
@ -767,18 +756,4 @@ else:
|
|||
|
||||
Default(library)
|
||||
|
||||
|
||||
def print_elapsed_time():
|
||||
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)
|
||||
methods.prepare_timer()
|
||||
|
|
|
|||
|
|
@ -1,41 +1,3 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../"))
|
||||
|
||||
from methods import Ansi
|
||||
|
||||
|
||||
def no_verbose(env):
|
||||
colors = [Ansi.BLUE, Ansi.BOLD, Ansi.REGULAR, Ansi.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)
|
||||
java_compile_source_message = "{}Compiling {}$SOURCE{} ...{}".format(*colors)
|
||||
compile_shared_source_message = "{}Compiling shared {}$SOURCE{} ...{}".format(*colors)
|
||||
link_program_message = "{}Linking Program {}$TARGET{} ...{}".format(*colors)
|
||||
link_library_message = "{}Linking Static Library {}$TARGET{} ...{}".format(*colors)
|
||||
ranlib_library_message = "{}Ranlib Library {}$TARGET{} ...{}".format(*colors)
|
||||
link_shared_library_message = "{}Linking Shared Library {}$TARGET{} ...{}".format(*colors)
|
||||
java_library_message = "{}Creating Java Archive {}$TARGET{} ...{}".format(*colors)
|
||||
compiled_resource_message = "{}Creating Compiled Resource {}$TARGET{} ...{}".format(*colors)
|
||||
generated_file_message = "{}Generating {}$TARGET{} ...{}".format(*colors)
|
||||
|
||||
env["CXXCOMSTR"] = compile_source_message
|
||||
env["CCCOMSTR"] = compile_source_message
|
||||
env["SHCCCOMSTR"] = compile_shared_source_message
|
||||
env["SHCXXCOMSTR"] = compile_shared_source_message
|
||||
env["ARCOMSTR"] = link_library_message
|
||||
env["RANLIBCOMSTR"] = ranlib_library_message
|
||||
env["SHLINKCOMSTR"] = link_shared_library_message
|
||||
env["LINKCOMSTR"] = link_program_message
|
||||
env["JARCOMSTR"] = java_library_message
|
||||
env["JAVACCOMSTR"] = java_compile_source_message
|
||||
env["RCCOMSTR"] = compiled_resource_message
|
||||
env["GENCOMSTR"] = generated_file_message
|
||||
|
||||
|
||||
def disable_warnings(self):
|
||||
# 'self' is the environment
|
||||
if self["platform"] == "windows" and not self["use_mingw"]:
|
||||
|
|
@ -50,6 +12,19 @@ def disable_warnings(self):
|
|||
self.AppendUnique(CCFLAGS=["-w"])
|
||||
|
||||
|
||||
def prepare_timer():
|
||||
import atexit
|
||||
import time
|
||||
|
||||
def print_elapsed_time(time_at_start: float):
|
||||
time_elapsed = time.time() - time_at_start
|
||||
time_formatted = time.strftime("%H:%M:%S", time.gmtime(time_elapsed))
|
||||
time_centiseconds = round((time_elapsed % 1) * 100)
|
||||
print(f"[Time elapsed: {time_formatted}.{time_centiseconds}]")
|
||||
|
||||
atexit.register(print_elapsed_time, time.time())
|
||||
|
||||
|
||||
def make_icu_data(target, source, env):
|
||||
dst = target[0].srcnode().abspath
|
||||
with open(dst, "w", encoding="utf-8", newline="\n") as g:
|
||||
|
|
@ -75,6 +50,8 @@ def make_icu_data(target, source, env):
|
|||
|
||||
|
||||
def write_macos_plist(target, binary_name, identifier, name):
|
||||
import os
|
||||
|
||||
os.makedirs(f"{target}/Resource/", exist_ok=True)
|
||||
with open(f"{target}/Resource/Info.plist", "w", encoding="utf-8", newline="\n") as f:
|
||||
f.write(f"""\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue