Compare commits

6 Commits

Author SHA1 Message Date
Byron Lathi
00b9e1d907 Add actions
All checks were successful
Publish Package / Build Package (push) Successful in 8s
Publish Package / Deploy Package (push) Successful in 10s
2025-11-08 14:32:56 -08:00
Byron Lathi
3a72154055 Expand env vars 2025-07-14 12:45:49 -07:00
Byron Lathi
b8cd278cf1 Updates for incdirs 2025-03-20 22:38:04 -07:00
Byron Lathi
7801876c85 Add sources, fix blank line issue 2025-03-20 22:24:23 -07:00
Byron Lathi
654cd49303 Update version 2024-08-16 23:15:28 -07:00
Byron Lathi
0676e20727 Use python3 instead of python 2024-08-16 23:14:35 -07:00
8 changed files with 148 additions and 18 deletions

View File

@@ -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/*

View File

@@ -0,0 +1,5 @@
from .rtl_manifest import rtl_manifest_main
from .rtl_manifest import read_sources
def main():
rtl_manifest_main()

View File

@@ -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

View File

@@ -1,3 +1,5 @@
python -m venv .venv
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements.txt
export TOP_DIR=$(git rev-parse --show-toplevel)

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/
# dynamic = ["version"]
version = "0.1.1" # REQUIRED, although can be dynamic
version = "0.4.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:

View File

@@ -1,8 +1,10 @@
import argparse
from typing import List
from typing import List, Tuple
import pathlib
import os
def rtl_manifest_main():
parser = argparse.ArgumentParser(
@@ -21,21 +23,39 @@ 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 = []
base_dir = pathlib.Path(source_file).parent
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))
with open(source_file, "r") as file:
for line in file:
path = line.strip()
if path.startswith("#"):
continue
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))
_recursive_parse(source_file)
return files
return files, incdirs

0
test/other_file.txt Normal file
View File

View File

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