|
@@ -7,7 +7,7 @@ from os.path import normpath, basename
|
|
|
|
|
|
base_folder_path = str(Path(__file__).parent) + "/"
|
|
base_folder_path = str(Path(__file__).parent) + "/"
|
|
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
|
|
base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
|
|
-_verbose = False
|
|
|
|
|
|
+_verbose = True # Set manually for debug prints
|
|
_scu_folders = set()
|
|
_scu_folders = set()
|
|
_max_includes_per_scu = 1024
|
|
_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
|
|
abs_folder = base_folder_path + folder + "/" + sub_folder
|
|
|
|
|
|
if not os.path.isdir(abs_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
|
|
return include_list, found_exceptions
|
|
|
|
|
|
os.chdir(abs_folder)
|
|
os.chdir(abs_folder)
|
|
@@ -67,9 +67,10 @@ def write_output_file(file_count, include_list, start_line, end_line, output_fol
|
|
# create
|
|
# create
|
|
os.mkdir(output_folder)
|
|
os.mkdir(output_folder)
|
|
if not os.path.isdir(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
|
|
return
|
|
- print("CREATING folder " + output_folder)
|
|
|
|
|
|
+ if _verbose:
|
|
|
|
+ print("SCU: Creating folder: %s" % output_folder)
|
|
|
|
|
|
file_text = ""
|
|
file_text = ""
|
|
|
|
|
|
@@ -79,8 +80,6 @@ def write_output_file(file_count, include_list, start_line, end_line, output_fol
|
|
li = line + "\n"
|
|
li = line + "\n"
|
|
file_text += li
|
|
file_text += li
|
|
|
|
|
|
- # print(file_text)
|
|
|
|
-
|
|
|
|
num_string = ""
|
|
num_string = ""
|
|
if file_count > 0:
|
|
if file_count > 0:
|
|
num_string = "_" + str(file_count)
|
|
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
|
|
short_filename = output_filename_prefix + num_string + ".gen." + extension
|
|
output_filename = output_folder + "/" + short_filename
|
|
output_filename = output_folder + "/" + short_filename
|
|
if _verbose:
|
|
if _verbose:
|
|
- print("generating: " + short_filename)
|
|
|
|
|
|
+ print("SCU: Generating: %s" % short_filename)
|
|
|
|
|
|
output_path = Path(output_filename)
|
|
output_path = Path(output_filename)
|
|
output_path.write_text(file_text, encoding="utf8")
|
|
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):
|
|
def write_exception_output_file(file_count, exception_string, output_folder, output_filename_prefix, extension):
|
|
output_folder = os.path.abspath(output_folder)
|
|
output_folder = os.path.abspath(output_folder)
|
|
if not os.path.isdir(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
|
|
return
|
|
|
|
|
|
file_text = exception_string + "\n"
|
|
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
|
|
output_filename = output_folder + "/" + short_filename
|
|
|
|
|
|
if _verbose:
|
|
if _verbose:
|
|
- print("generating: " + short_filename)
|
|
|
|
|
|
+ print("SCU: Generating: " + short_filename)
|
|
|
|
|
|
- # print("text: " + file_text)
|
|
|
|
- # return
|
|
|
|
output_path = Path(output_filename)
|
|
output_path = Path(output_filename)
|
|
output_path.write_text(file_text, encoding="utf8")
|
|
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("=============================")
|
|
print("Single Compilation Unit Build")
|
|
print("Single Compilation Unit Build")
|
|
print("=============================")
|
|
print("=============================")
|
|
- global _verbose
|
|
|
|
- _verbose = verbose
|
|
|
|
|
|
+
|
|
global _max_includes_per_scu
|
|
global _max_includes_per_scu
|
|
_max_includes_per_scu = 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("./")
|
|
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
|
|
# Finally change back the path to the calling folder
|
|
os.chdir(curr_folder)
|
|
os.chdir(curr_folder)
|
|
|
|
|
|
|
|
+ if _verbose:
|
|
|
|
+ print("SCU: Processed folders: %s" % sorted(_scu_folders))
|
|
|
|
+
|
|
return _scu_folders
|
|
return _scu_folders
|