Skip to content

Commit

Permalink
SCons: Reduce and cleanup verbose output for SCU builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akien-mga authored and orianbsilva committed Nov 1, 2023
1 parent 7d62763 commit 90907db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions scu_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = ""

Expand All @@ -79,16 +80,14 @@ 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)

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")
Expand All @@ -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"
Expand All @@ -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")

Expand Down Expand Up @@ -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("./")

Expand Down Expand Up @@ -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

0 comments on commit 90907db

Please sign in to comment.