diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee84466..ce4666f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,34 @@ image: python:latest -run: +stages: + - build + - test + - deploy + +build: + stage: build + rules: + - when: always + artifacts: + paths: + - ./dist script: - source init_env.sh - python -m build + +test: + stage: test + rules: + - when: always + script: + - echo "Haha no tests yet" + +deploy: + stage: deploy + 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/* 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: 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