diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-05 12:43:38 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-05 12:43:38 +1000 |
commit | 54354e32c6498cc7f8839ab4deb1208d37216cc5 (patch) | |
tree | 7759597b971ba59d6af841a5bed793c229dd4c2b /scripts/amalgamation/gen_amalgamation.py | |
parent | be8ab99b38c25e899008582d68e891150b328a4d (diff) |
Begin simplifying project structure and removing examples
Diffstat (limited to 'scripts/amalgamation/gen_amalgamation.py')
-rw-r--r-- | scripts/amalgamation/gen_amalgamation.py | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/scripts/amalgamation/gen_amalgamation.py b/scripts/amalgamation/gen_amalgamation.py deleted file mode 100644 index 4a4d946..0000000 --- a/scripts/amalgamation/gen_amalgamation.py +++ /dev/null @@ -1,59 +0,0 @@ -# Generates a single amalgamation C header file that includes all public types and functions. -# -# This makes including and linking Celeritas very easy. -import re -import os -from pathlib import Path - -categories = { - "RAL": "src/ral", - "Render": "src/new_render", - "Maths": "src/maths" -} - -def find_pub_functions_in_folder(folder_path): - functions = [] - for filename in os.listdir(folder_path): - filepath = os.path.join(folder_path, filename) - if os.path.isfile(filepath): - file_funcs = find_pub_functions_in_file(filepath) - functions.extend(file_funcs) - - return functions - -def find_pub_functions_in_file(file_path): - pattern = r'PUB\s+(\w+\s+)*(\w+)\s+(\w+)\s*\((.*?)\)' - - with open(file_path, 'r') as file: - content = file.read() - - matches = re.finditer(pattern, content, re.MULTILINE) - - # Collect all the functions into an array - functions = [] - for match in matches: - signature = match.group(0) - if signature.startswith("PUB "): - signature = signature[4:] - - print(signature) - functions.append(signature) - - return functions - -def generate_header(): - header_path = "celeritas.h" - - script_dir = Path(__file__).resolve().parent - grandparent_dir = script_dir.parents[1] - - with open(header_path, 'w') as export_file: - for category in categories.keys(): - folder = os.path.join(grandparent_dir, categories[category]) - category_funcs = find_pub_functions_in_folder(folder) - for func in category_funcs: - export_file.write(func) - export_file.write(';\n') - -if __name__ == "__main__": - generate_header() |