From 7801876c8582cc3db55947471b7ee56877cefbeb Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 20 Mar 2025 22:24:23 -0700 Subject: [PATCH] Add sources, fix blank line issue --- pyproject.toml | 2 +- src/rtl_manifest/rtl_manifest.py | 24 +++++++++++++++++++++--- test/sources.list | 3 +++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 664eb50..a570986 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.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 # corresponds to the "Summary" metadata field: diff --git a/src/rtl_manifest/rtl_manifest.py b/src/rtl_manifest/rtl_manifest.py index 6aac7f9..0598893 100644 --- a/src/rtl_manifest/rtl_manifest.py +++ b/src/rtl_manifest/rtl_manifest.py @@ -1,6 +1,6 @@ import argparse -from typing import List +from typing import List, Tuple import pathlib @@ -21,7 +21,19 @@ def rtl_manifest_main(): pass 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 = [] + incdirs = [] + base_dir = pathlib.Path(source_file).parent @@ -30,12 +42,18 @@ def read_sources(source_file: str) -> List[str]: 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 read_sources(new_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)) - return files + return files, incdirs diff --git a/test/sources.list b/test/sources.list index 04de8da..01537e2 100644 --- a/test/sources.list +++ b/test/sources.list @@ -1,3 +1,6 @@ src/sub/submodule/sources.list src/example.sv # This is a comment! + +# ^ above was a blank line +`include .