diff --git a/src/rtl_manifest/rtl_manifest.py b/src/rtl_manifest/rtl_manifest.py index 7a0aa44..beb5faf 100644 --- a/src/rtl_manifest/rtl_manifest.py +++ b/src/rtl_manifest/rtl_manifest.py @@ -1,4 +1,39 @@ +import argparse +from typing import List +import pathlib + + def rtl_manifest_main(): - print("Hello, world!") - pass \ No newline at end of file + parser = argparse.ArgumentParser( + prog='rtl-manifest', + description='Read in sources.list files and return a string of all source files', + epilog='Made by Byron Lathi') + + parser.add_argument("source") + + args = parser.parse_args() + files = read_sources(args.source) + + for file in files: + print(file, end = " ") + + pass + +def read_sources(source_file: str) -> List[str]: + files = [] + base_dir = pathlib.Path(source_file).parent + + + with open(source_file, "r") as file: + for line in file: + path = line.strip() + if (path.endswith("sources.list")): + new_path = pathlib.Path(base_dir) / path + for recursive_path in read_sources(new_path): + files.append(recursive_path) + else: + abs_path = pathlib.Path(base_dir / path).absolute() + files.append(str(abs_path)) + + return files \ No newline at end of file diff --git a/test/sources.list b/test/sources.list new file mode 100644 index 0000000..5b512af --- /dev/null +++ b/test/sources.list @@ -0,0 +1,2 @@ +src/sub/submodule/sources.list +src/example.sv diff --git a/test/src/example.sv b/test/src/example.sv new file mode 100644 index 0000000..e69de29 diff --git a/test/src/sub/submodule/other_submodule.sv b/test/src/sub/submodule/other_submodule.sv new file mode 100644 index 0000000..e69de29 diff --git a/test/src/sub/submodule/sources.list b/test/src/sub/submodule/sources.list new file mode 100644 index 0000000..ae7c5df --- /dev/null +++ b/test/src/sub/submodule/sources.list @@ -0,0 +1,2 @@ +other_submodule.sv +submodule_regs.rdl \ No newline at end of file diff --git a/test/src/sub/submodule/submodule.sv b/test/src/sub/submodule/submodule.sv new file mode 100644 index 0000000..e69de29 diff --git a/test/src/sub/submodule/submodule_regs.rdl b/test/src/sub/submodule/submodule_regs.rdl new file mode 100644 index 0000000..e69de29