From b8cd278cf15894066493f8f6af0208ada6dcb0fb Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 20 Mar 2025 22:38:04 -0700 Subject: [PATCH] Updates for incdirs --- pyproject.toml | 2 +- src/rtl_manifest/rtl_manifest.py | 40 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a570986..dd7e62e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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/ # dynamic = ["version"] -version = "0.3.0" # REQUIRED, although can be dynamic +version = "0.3.1" # REQUIRED, although can be dynamic # This is a one-line description or tagline of what your project does. This # corresponds to the "Summary" metadata field: diff --git a/src/rtl_manifest/rtl_manifest.py b/src/rtl_manifest/rtl_manifest.py index 0598893..42fa26e 100644 --- a/src/rtl_manifest/rtl_manifest.py +++ b/src/rtl_manifest/rtl_manifest.py @@ -34,26 +34,26 @@ def parse(source_file: str) -> Tuple[List[str], List[str]]: files = [] incdirs = [] - base_dir = pathlib.Path(source_file).parent + def _recursive_parse(source_file: str): + base_dir = pathlib.Path(source_file).parent + with open(source_file, "r") as file: + for line in file: + path = line.strip() + if path.startswith("#"): + continue + if path == "": + continue + if path.startswith("`include "): + abs_path = pathlib.Path(base_dir / path.split()[1]).absolute() + incdirs.append(str(abs_path)) + continue + if (path.endswith("sources.list")): + new_path = pathlib.Path(base_dir) / path + _recursive_parse(new_path) + else: + abs_path = pathlib.Path(base_dir / path).absolute() + files.append(str(abs_path)) - - with open(source_file, "r") as file: - for line in file: - path = line.strip() - if path.startswith("#"): - 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")): - new_path = pathlib.Path(base_dir) / path - for recursive_path in parse(new_path): - files.append(recursive_path) - else: - abs_path = pathlib.Path(base_dir / path).absolute() - files.append(str(abs_path)) + _recursive_parse(source_file) return files, incdirs