SCons: Reduce and cleanup verbose output for SCU builds

Verbose output is meant for debugging the SCU mode itself and can be
triggered by changing the `_verbose` bool manually.

Prefix all prints with "SCU:" for context, and print the processed
folders all at once instead of when adding the sources.
This commit is contained in:
Rémi Verschelde 2023-10-26 13:17:27 +02:00
parent 46cb7f94f7
commit 495245ed89
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 16 additions and 19 deletions

View File

@ -565,7 +565,7 @@ if selected_platform in platform_list:
if read_scu_limit != 0:
max_includes_per_scu = read_scu_limit
methods.set_scu_folders(scu_builders.generate_scu_files(env["verbose"], max_includes_per_scu))
methods.set_scu_folders(scu_builders.generate_scu_files(max_includes_per_scu))
# Must happen after the flags' definition, as configure is when most flags
# are actually handled to change compile options, etc.

View File

@ -96,9 +96,6 @@ def add_source_files_scu(self, sources, files, allow_gen=False):
if section_name not in (_scu_folders):
return False
if self["verbose"]:
print("SCU building " + section_name)
# Add all the gen.cpp files in the SCU directory
add_source_files_orig(self, sources, subdir + "scu/scu_*.gen.cpp", True)
return True

View File

@ -7,7 +7,7 @@ from os.path import normpath, basename
base_folder_path = str(Path(__file__).parent) + "/"
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
_verbose = False
_verbose = True # Set manually for debug prints
_scu_folders = set()
_max_includes_per_scu = 1024
@ -35,7 +35,7 @@ def find_files_in_folder(folder, sub_folder, include_list, extension, sought_exc
abs_folder = base_folder_path + folder + "/" + sub_folder
if not os.path.isdir(abs_folder):
print("ERROR " + abs_folder + " not found.")
print("SCU: ERROR: %s not found." % abs_folder)
return include_list, found_exceptions
os.chdir(abs_folder)
@ -67,9 +67,10 @@ def write_output_file(file_count, include_list, start_line, end_line, output_fol
# create
os.mkdir(output_folder)
if not os.path.isdir(output_folder):
print("ERROR " + output_folder + " could not be created.")
print("SCU: ERROR: %s could not be created." % output_folder)
return
print("CREATING folder " + output_folder)
if _verbose:
print("SCU: Creating folder: %s" % output_folder)
file_text = ""
@ -79,8 +80,6 @@ def write_output_file(file_count, include_list, start_line, end_line, output_fol
li = line + "\n"
file_text += li
# print(file_text)
num_string = ""
if file_count > 0:
num_string = "_" + str(file_count)
@ -88,7 +87,7 @@ def write_output_file(file_count, include_list, start_line, end_line, output_fol
short_filename = output_filename_prefix + num_string + ".gen." + extension
output_filename = output_folder + "/" + short_filename
if _verbose:
print("generating: " + short_filename)
print("SCU: Generating: %s" % short_filename)
output_path = Path(output_filename)
output_path.write_text(file_text, encoding="utf8")
@ -97,7 +96,7 @@ def write_output_file(file_count, include_list, start_line, end_line, output_fol
def write_exception_output_file(file_count, exception_string, output_folder, output_filename_prefix, extension):
output_folder = os.path.abspath(output_folder)
if not os.path.isdir(output_folder):
print("ERROR " + output_folder + " does not exist.")
print("SCU: ERROR: %s does not exist." % output_folder)
return
file_text = exception_string + "\n"
@ -110,10 +109,8 @@ def write_exception_output_file(file_count, exception_string, output_folder, out
output_filename = output_folder + "/" + short_filename
if _verbose:
print("generating: " + short_filename)
print("SCU: Generating: " + short_filename)
# print("text: " + file_text)
# return
output_path = Path(output_filename)
output_path.write_text(file_text, encoding="utf8")
@ -242,15 +239,15 @@ def process_folder(folders, sought_exceptions=[], includes_per_scu=0, extension=
)
def generate_scu_files(verbose, max_includes_per_scu):
def generate_scu_files(max_includes_per_scu):
print("=============================")
print("Single Compilation Unit Build")
print("=============================")
global _verbose
_verbose = verbose
global _max_includes_per_scu
_max_includes_per_scu = max_includes_per_scu
print("Generating SCU build files... (max includes per scu " + str(_max_includes_per_scu) + ")")
print("SCU: Generating build files... (max includes per SCU: %d)" % _max_includes_per_scu)
curr_folder = os.path.abspath("./")
@ -334,4 +331,7 @@ def generate_scu_files(verbose, max_includes_per_scu):
# Finally change back the path to the calling folder
os.chdir(curr_folder)
if _verbose:
print("SCU: Processed folders: %s" % sorted(_scu_folders))
return _scu_folders