Have it do something
This commit is contained in:
@@ -1,4 +1,39 @@
|
||||
|
||||
import argparse
|
||||
from typing import List
|
||||
import pathlib
|
||||
|
||||
|
||||
def rtl_manifest_main():
|
||||
print("Hello, world!")
|
||||
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
2
test/sources.list
Normal file
@@ -0,0 +1,2 @@
|
||||
src/sub/submodule/sources.list
|
||||
src/example.sv
|
||||
0
test/src/example.sv
Normal file
0
test/src/example.sv
Normal file
0
test/src/sub/submodule/other_submodule.sv
Normal file
0
test/src/sub/submodule/other_submodule.sv
Normal file
2
test/src/sub/submodule/sources.list
Normal file
2
test/src/sub/submodule/sources.list
Normal file
@@ -0,0 +1,2 @@
|
||||
other_submodule.sv
|
||||
submodule_regs.rdl
|
||||
0
test/src/sub/submodule/submodule.sv
Normal file
0
test/src/sub/submodule/submodule.sv
Normal file
0
test/src/sub/submodule/submodule_regs.rdl
Normal file
0
test/src/sub/submodule/submodule_regs.rdl
Normal file
Reference in New Issue
Block a user