Have it do something

This commit is contained in:
Byron Lathi
2024-06-06 18:31:57 -07:00
parent 7ad5c86112
commit 0876586f62
7 changed files with 41 additions and 2 deletions

View File

@@ -1,4 +1,39 @@
import argparse
from typing import List
import pathlib
def rtl_manifest_main():
print("Hello, world!")
pass
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

2
test/sources.list Normal file
View File

@@ -0,0 +1,2 @@
src/sub/submodule/sources.list
src/example.sv

0
test/src/example.sv Normal file
View File

View File

@@ -0,0 +1,2 @@
other_submodule.sv
submodule_regs.rdl

View File