Add sources, fix blank line issue

This commit is contained in:
Byron Lathi
2025-03-20 22:24:23 -07:00
parent 654cd49303
commit 7801876c85
3 changed files with 25 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ name = "rtl-manifest" # REQUIRED, is the only field that cannot be marked as dy
# https://packaging.python.org/guides/single-sourcing-package-version/ # https://packaging.python.org/guides/single-sourcing-package-version/
# dynamic = ["version"] # dynamic = ["version"]
version = "0.2.0" # REQUIRED, although can be dynamic version = "0.3.0" # REQUIRED, although can be dynamic
# This is a one-line description or tagline of what your project does. This # This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field: # corresponds to the "Summary" metadata field:

View File

@@ -1,6 +1,6 @@
import argparse import argparse
from typing import List from typing import List, Tuple
import pathlib import pathlib
@@ -21,7 +21,19 @@ def rtl_manifest_main():
pass pass
def read_sources(source_file: str) -> List[str]: def read_sources(source_file: str) -> List[str]:
sources, incdirs = parse(source_file)
return sources
def read_incdirs(source_file: str) -> List[str]:
sources, incdirs = parse(source_file)
return incdirs
def parse(source_file: str) -> Tuple[List[str], List[str]]:
files = [] files = []
incdirs = []
base_dir = pathlib.Path(source_file).parent base_dir = pathlib.Path(source_file).parent
@@ -30,12 +42,18 @@ def read_sources(source_file: str) -> List[str]:
path = line.strip() path = line.strip()
if path.startswith("#"): if path.startswith("#"):
continue continue
if path == "":
continue
if path.startswith("`include "):
abs_path = pathlib.Path(base_dir / path.split()[1]).absolute()
incdirs.append(abs_path)
continue
if (path.endswith("sources.list")): if (path.endswith("sources.list")):
new_path = pathlib.Path(base_dir) / path new_path = pathlib.Path(base_dir) / path
for recursive_path in read_sources(new_path): for recursive_path in parse(new_path):
files.append(recursive_path) files.append(recursive_path)
else: else:
abs_path = pathlib.Path(base_dir / path).absolute() abs_path = pathlib.Path(base_dir / path).absolute()
files.append(str(abs_path)) files.append(str(abs_path))
return files return files, incdirs

View File

@@ -1,3 +1,6 @@
src/sub/submodule/sources.list src/sub/submodule/sources.list
src/example.sv src/example.sv
# This is a comment! # This is a comment!
# ^ above was a blank line
`include .