From 0876586f6220580cd83739aeb3a037c62ea8a4f5 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 6 Jun 2024 18:31:57 -0700 Subject: [PATCH 1/5] Have it do something --- src/rtl_manifest/rtl_manifest.py | 39 +++++++++++++++++++++-- test/sources.list | 2 ++ test/src/example.sv | 0 test/src/sub/submodule/other_submodule.sv | 0 test/src/sub/submodule/sources.list | 2 ++ test/src/sub/submodule/submodule.sv | 0 test/src/sub/submodule/submodule_regs.rdl | 0 7 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/sources.list create mode 100644 test/src/example.sv create mode 100644 test/src/sub/submodule/other_submodule.sv create mode 100644 test/src/sub/submodule/sources.list create mode 100644 test/src/sub/submodule/submodule.sv create mode 100644 test/src/sub/submodule/submodule_regs.rdl diff --git a/src/rtl_manifest/rtl_manifest.py b/src/rtl_manifest/rtl_manifest.py index 7a0aa44..beb5faf 100644 --- a/src/rtl_manifest/rtl_manifest.py +++ b/src/rtl_manifest/rtl_manifest.py @@ -1,4 +1,39 @@ +import argparse +from typing import List +import pathlib + + def rtl_manifest_main(): - print("Hello, world!") - pass \ No newline at end of file + 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]: + files = [] + base_dir = pathlib.Path(source_file).parent + + + with open(source_file, "r") as file: + for line in file: + path = line.strip() + 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)) + + return files \ No newline at end of file diff --git a/test/sources.list b/test/sources.list new file mode 100644 index 0000000..5b512af --- /dev/null +++ b/test/sources.list @@ -0,0 +1,2 @@ +src/sub/submodule/sources.list +src/example.sv diff --git a/test/src/example.sv b/test/src/example.sv new file mode 100644 index 0000000..e69de29 diff --git a/test/src/sub/submodule/other_submodule.sv b/test/src/sub/submodule/other_submodule.sv new file mode 100644 index 0000000..e69de29 diff --git a/test/src/sub/submodule/sources.list b/test/src/sub/submodule/sources.list new file mode 100644 index 0000000..ae7c5df --- /dev/null +++ b/test/src/sub/submodule/sources.list @@ -0,0 +1,2 @@ +other_submodule.sv +submodule_regs.rdl \ No newline at end of file diff --git a/test/src/sub/submodule/submodule.sv b/test/src/sub/submodule/submodule.sv new file mode 100644 index 0000000..e69de29 diff --git a/test/src/sub/submodule/submodule_regs.rdl b/test/src/sub/submodule/submodule_regs.rdl new file mode 100644 index 0000000..e69de29 From 19e95f3e209578203904aeae6569adef34e04661 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 6 Jun 2024 18:39:04 -0700 Subject: [PATCH 2/5] update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3d29fa5..7470434 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ name = "rtl-manifest" # REQUIRED, is the only field that cannot be marked as dy # # For a discussion on single-sourcing the version, see # https://packaging.python.org/guides/single-sourcing-package-version/ -version = "0.0.1" # REQUIRED, although can be dynamic +version = "0.0.2" # 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: From dd1a2487636e4dfe31963ab6e43b800b7fbe641e Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 6 Jun 2024 18:45:09 -0700 Subject: [PATCH 3/5] Only deploy on merges to master --- .gitlab-ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee84466..0c9bdd0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,28 @@ image: python:latest -run: +stages: + - build + - test + - deploy + +build: + stage: build + artifacts: + paths: + - ./dist script: - source init_env.sh - python -m build + +test: + stage: test + script: + - echo "Haha no tests yet" + +deploy: + stage: deploy + only: + - master + - merge_requests + script: - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${PACKAGE_PROJECT_ID}/packages/pypi dist/* From 310c760dafb146479de786492983dea2f5c651cf Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 6 Jun 2024 18:47:12 -0700 Subject: [PATCH 4/5] Only deploy on merges to master --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c9bdd0..e0cba76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,9 @@ image: python:latest stages: - - build - - test - - deploy + - build + - test + - deploy build: stage: build From 4d0e47b909f6e3cd6b0271b9cf53fadb85b563d9 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Thu, 6 Jun 2024 18:53:14 -0700 Subject: [PATCH 5/5] Only deploy on merges to master --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0cba76..ce4666f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,8 @@ stages: build: stage: build + rules: + - when: always artifacts: paths: - ./dist @@ -16,13 +18,17 @@ build: test: stage: test + rules: + - when: always script: - echo "Haha no tests yet" deploy: stage: deploy - only: - - master - - merge_requests + rules: + # only run on MRs to main + - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" + # run on commits to main + - if: $CI_COMMIT_BRANCH == "main" script: - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${PACKAGE_PROJECT_ID}/packages/pypi dist/*