From 00b9e1d90795687dcd11b8bec452f29e4e95a493 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Sat, 8 Nov 2025 14:32:56 -0800 Subject: [PATCH] Add actions --- .gitea/workflows/publish.yaml | 37 ++++++++++++++++ build/lib/rtl_manifest/__init__.py | 5 +++ build/lib/rtl_manifest/rtl_manifest.py | 61 ++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 .gitea/workflows/publish.yaml create mode 100644 build/lib/rtl_manifest/__init__.py create mode 100644 build/lib/rtl_manifest/rtl_manifest.py diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..e6b08e7 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,37 @@ +name: Publish Package +on: [push] + +jobs: + build: + name: Build Package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + - run: python3 -m pip install build --user + - run: python -m build + - uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + deploy: + name: Deploy Package + needs: + - build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + - run: python3 -m pip install twine --user + - uses: actions/download-artifact@v3 + name: python-package-distributions + path: dist/ # Does this even do anything? + - run: ls -laR python-package-distributions + - run: TWINE_PASSWORD=${{ secrets.PYPI_PAT }} TWINE_USERNAME=bslathi19 python -m twine upload --repository-url ${{ vars.CI_API_URL }} python-package-distributions/* diff --git a/build/lib/rtl_manifest/__init__.py b/build/lib/rtl_manifest/__init__.py new file mode 100644 index 0000000..8916bfc --- /dev/null +++ b/build/lib/rtl_manifest/__init__.py @@ -0,0 +1,5 @@ +from .rtl_manifest import rtl_manifest_main +from .rtl_manifest import read_sources + +def main(): + rtl_manifest_main() diff --git a/build/lib/rtl_manifest/rtl_manifest.py b/build/lib/rtl_manifest/rtl_manifest.py new file mode 100644 index 0000000..b125920 --- /dev/null +++ b/build/lib/rtl_manifest/rtl_manifest.py @@ -0,0 +1,61 @@ + +import argparse +from typing import List, Tuple +import pathlib + +import os + + +def rtl_manifest_main(): + 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]: + 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 = [] + + 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 = os.path.expandvars(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)) + + _recursive_parse(source_file) + + return files, incdirs