spl-core 4.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. spl_core-4.0.0/LICENSE +22 -0
  2. spl_core-4.0.0/PKG-INFO +62 -0
  3. spl_core-4.0.0/README.md +32 -0
  4. spl_core-4.0.0/pyproject.toml +185 -0
  5. spl_core-4.0.0/src/spl_core/__init__.py +1 -0
  6. spl_core-4.0.0/src/spl_core/common/__init__.py +0 -0
  7. spl_core-4.0.0/src/spl_core/common/cmake.py +52 -0
  8. spl_core-4.0.0/src/spl_core/common/path.py +17 -0
  9. spl_core-4.0.0/src/spl_core/gcov_maid/__init__.py +0 -0
  10. spl_core-4.0.0/src/spl_core/gcov_maid/gcov_maid.py +48 -0
  11. spl_core-4.0.0/src/spl_core/kconfig/__init__.py +0 -0
  12. spl_core-4.0.0/src/spl_core/kconfig/kconfig.py +271 -0
  13. spl_core-4.0.0/src/spl_core/project_creator/__init__.py +0 -0
  14. spl_core-4.0.0/src/spl_core/project_creator/creator.py +133 -0
  15. spl_core-4.0.0/src/spl_core/project_creator/templates/project/cookiecutter.json +14 -0
  16. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.flake8 +2 -0
  17. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.gitignore +33 -0
  18. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/cmake-kits.json +11 -0
  19. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/cmake-variants.json +18 -0
  20. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/extensions.json +18 -0
  21. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/launch.json +37 -0
  22. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/settings.json +45 -0
  23. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/tasks.json +93 -0
  24. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/CMakeLists.txt +43 -0
  25. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/KConfig +23 -0
  26. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/LICENSE +21 -0
  27. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/Pipfile +33 -0
  28. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/README.md +7 -0
  29. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/build.bat +1 -0
  30. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/build.ps1 +245 -0
  31. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/conf.py +200 -0
  32. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/Doxyfile.in +2774 -0
  33. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/common/index.rst +5 -0
  34. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/components/index.rst +23 -0
  35. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/doxygen-awesome/LICENSE +21 -0
  36. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/doxygen-awesome/doxygen-awesome.css +2530 -0
  37. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/software_architecture/index.rst +2 -0
  38. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/software_requirements/index.rst +7 -0
  39. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/test_report_template.txt +46 -0
  40. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/index.rst +38 -0
  41. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/install-mandatory.bat +1 -0
  42. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/pytest.ini +9 -0
  43. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/scoopfile.json +47 -0
  44. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/test/test_build.py +39 -0
  45. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/test/test_unittests.py +28 -0
  46. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/test/utils.py +26 -0
  47. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/tools/setup/git-config.ps1 +8 -0
  48. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/CMakeLists.txt +3 -0
  49. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/doc/_images/screenshot.png +0 -0
  50. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/doc/design.rst +25 -0
  51. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/doc/index.rst +8 -0
  52. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/src/component.c +31 -0
  53. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/src/component.h +1 -0
  54. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/test/test_component.cc +60 -0
  55. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/main/CMakeLists.txt +2 -0
  56. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/main/doc/index.rst +14 -0
  57. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/main/src/main.c +17 -0
  58. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_tools -%} tools {%- endif %}/toolchains/clang/toolchain.cmake +8 -0
  59. spl_core-4.0.0/src/spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_tools -%} tools {%- endif %}/toolchains/gcc/toolchain.cmake +3 -0
  60. spl_core-4.0.0/src/spl_core/project_creator/templates/variant/cookiecutter.json +4 -0
  61. spl_core-4.0.0/src/spl_core/project_creator/templates/variant/{{cookiecutter.flavor}}/{{cookiecutter.subsystem}}/config.cmake +1 -0
  62. spl_core-4.0.0/src/spl_core/project_creator/templates/variant/{{cookiecutter.flavor}}/{{cookiecutter.subsystem}}/config.txt +1 -0
  63. spl_core-4.0.0/src/spl_core/project_creator/templates/variant/{{cookiecutter.flavor}}/{{cookiecutter.subsystem}}/parts.cmake +2 -0
  64. spl_core-4.0.0/src/spl_core/project_creator/variant.py +23 -0
  65. spl_core-4.0.0/src/spl_core/project_creator/workspace_artifacts.py +36 -0
spl_core-4.0.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2024 Marquardt GmbH and members of AVENGINEERS
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.1
2
+ Name: spl-core
3
+ Version: 4.0.0
4
+ Summary: Software Product Line Support for CMake
5
+ Home-page: https://github.com/avengineers/spl-core
6
+ License: MIT
7
+ Author: Avengineers
8
+ Author-email: karsten.guenther@kamg.de
9
+ Requires-Python: >=3.10,<3.12
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Dist: cookiecutter (==2.1.1)
20
+ Requires-Dist: gcovr
21
+ Requires-Dist: hammocking
22
+ Requires-Dist: kconfiglib
23
+ Requires-Dist: py-app-dev (>=2.1.0,<3.0.0)
24
+ Project-URL: Bug Tracker, https://github.com/avengineers/spl-core/issues
25
+ Project-URL: Changelog, https://github.com/avengineers/spl-core/blob/develop/CHANGELOG.md
26
+ Project-URL: Documentation, https://spl-core.readthedocs.io
27
+ Project-URL: Repository, https://github.com/avengineers/spl-core
28
+ Description-Content-Type: text/markdown
29
+
30
+ # SPL (Software Product Line) Core
31
+
32
+ _SPL Core_ is our CMake module to support multiple projects as variants of one SPL repository.
33
+
34
+ ## CI (Continuous Integration)
35
+
36
+ - [![selftests](https://github.com/avengineers/spl/actions/workflows/test.yml/badge.svg)](https://github.com/avengineers/spl/actions/workflows/test.yml)
37
+
38
+ ## Installation of Dependencies
39
+
40
+ ```powershell
41
+ .\build.ps1 -install
42
+ ```
43
+
44
+ ## Building
45
+
46
+ - Execution of all tests
47
+ - Building documentation
48
+
49
+ ```powershell
50
+ .\build.ps1
51
+ ```
52
+
53
+ ## Project Creator
54
+
55
+ With the integrated project creator you can create a new SPL workspace, e.g.:
56
+
57
+ ```powershell
58
+ pipenv run python src/project_creator/creator.py workspace --name MyProject --variant FLV1/SYS1 --out_dir C:\dev
59
+ ```
60
+
61
+ Note: one can use the `--variant` argument several times to create a project with multiple variants.
62
+
@@ -0,0 +1,32 @@
1
+ # SPL (Software Product Line) Core
2
+
3
+ _SPL Core_ is our CMake module to support multiple projects as variants of one SPL repository.
4
+
5
+ ## CI (Continuous Integration)
6
+
7
+ - [![selftests](https://github.com/avengineers/spl/actions/workflows/test.yml/badge.svg)](https://github.com/avengineers/spl/actions/workflows/test.yml)
8
+
9
+ ## Installation of Dependencies
10
+
11
+ ```powershell
12
+ .\build.ps1 -install
13
+ ```
14
+
15
+ ## Building
16
+
17
+ - Execution of all tests
18
+ - Building documentation
19
+
20
+ ```powershell
21
+ .\build.ps1
22
+ ```
23
+
24
+ ## Project Creator
25
+
26
+ With the integrated project creator you can create a new SPL workspace, e.g.:
27
+
28
+ ```powershell
29
+ pipenv run python src/project_creator/creator.py workspace --name MyProject --variant FLV1/SYS1 --out_dir C:\dev
30
+ ```
31
+
32
+ Note: one can use the `--variant` argument several times to create a project with multiple variants.
@@ -0,0 +1,185 @@
1
+ [tool.poetry]
2
+ name = "spl-core"
3
+ version = "4.0.0"
4
+ description = "Software Product Line Support for CMake"
5
+ authors = ["Avengineers <karsten.guenther@kamg.de>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ repository = "https://github.com/avengineers/spl-core"
9
+ documentation = "https://spl-core.readthedocs.io"
10
+ classifiers = [
11
+ "Development Status :: 2 - Pre-Alpha",
12
+ "Intended Audience :: Developers",
13
+ "Natural Language :: English",
14
+ "Operating System :: OS Independent",
15
+ "Topic :: Software Development :: Libraries",
16
+ ]
17
+ packages = [
18
+ { include = "spl_core", from = "src" },
19
+ ]
20
+
21
+ [tool.poetry.urls]
22
+ "Bug Tracker" = "https://github.com/avengineers/spl-core/issues"
23
+ "Changelog" = "https://github.com/avengineers/spl-core/blob/develop/CHANGELOG.md"
24
+
25
+ [tool.poetry.dependencies]
26
+ python = ">=3.10,<3.12"
27
+ py-app-dev = "^2.1.0"
28
+ cookiecutter = {version="==2.1.1"}
29
+ gcovr = "*"
30
+ hammocking = "*"
31
+ kconfiglib = "*"
32
+
33
+ [tool.poetry.group.dev.dependencies]
34
+ pytest = "^7.0"
35
+ pytest-cov = "^4.0"
36
+ black = "^23.1.0"
37
+ pre-commit = "^3.1.1"
38
+ ruff = "^0.3.0"
39
+ jinja2 = "*"
40
+ testfixtures = "*"
41
+ junitparser = "*"
42
+ mashumaro = "*"
43
+ loguru = "*"
44
+ m2r = "*"
45
+ flake8 = "*"
46
+ sphinx = "*"
47
+ sphinx-rtd-theme = "*"
48
+ sphinxcontrib-mermaid = "*"
49
+ sphinx-needs = "*"
50
+ sphinx-test-reports = "*"
51
+ doxysphinx = "*"
52
+ sphinx-rtd-size = "*"
53
+ sphinxcontrib-datatemplates = "*"
54
+ sphinxcontrib-plantuml = "*"
55
+ sphinx-copybutton = "*"
56
+ sphinx-new-tab-link = "*"
57
+ pipenv = "*"
58
+
59
+ [tool.poetry.group.docs]
60
+ optional = true
61
+
62
+ [tool.poetry.group.docs.dependencies]
63
+ myst-parser = ">=0.16"
64
+ sphinx = ">=4.0"
65
+ sphinxcontrib-mermaid = "^0.8.1"
66
+ mlx-traceability = "^10.0.0"
67
+ sphinx-copybutton = "^0.5.2"
68
+ sphinx-new-tab-link = "^0.2.2"
69
+ sphinx-book-theme = "^1.1.2"
70
+ sphinx-design = "^0.5.0"
71
+
72
+ [tool.semantic_release]
73
+ version_toml = ["pyproject.toml:tool.poetry.version"]
74
+ version_variables = [
75
+ "src/spl_core/__init__.py:__version__",
76
+ "docs/conf.py:release",
77
+ ]
78
+ build_command = "pip install poetry && poetry build"
79
+
80
+ [tool.semantic_release.changelog]
81
+ exclude_commit_patterns = [
82
+ "chore*",
83
+ "ci*",
84
+ ]
85
+
86
+ [tool.semantic_release.changelog.environment]
87
+ keep_trailing_newline = true
88
+
89
+ [tool.semantic_release.branches.main]
90
+ match = "develop"
91
+
92
+ [tool.semantic_release.branches.noop]
93
+ match = "(?!develop$)"
94
+ prerelease = true
95
+
96
+ [tool.pytest.ini_options]
97
+ addopts = " --verbose --capture=tee-sys --junitxml=out/test-report.xml"
98
+ pythonpath = ["src", "tests"]
99
+ testpaths = ["tests"]
100
+ junit_logging = "all"
101
+
102
+ [tool.coverage.run]
103
+ branch = true
104
+
105
+ [tool.coverage.report]
106
+ exclude_lines = [
107
+ "pragma: no cover",
108
+ "@overload",
109
+ "if TYPE_CHECKING",
110
+ "raise NotImplementedError",
111
+ 'if __name__ == "__main__":',
112
+ ]
113
+
114
+ [tool.ruff]
115
+ target-version = "py38"
116
+ line-length = 220
117
+ lint.ignore = [
118
+ "D203", # 1 blank line required before class docstring
119
+ "D212", # Multi-line docstring summary should start at the first line
120
+ "D100", # Missing docstring in public module
121
+ "D101", # Missing docstring in public class
122
+ "D102", # Missing docstring in public method
123
+ "D103", # Missing docstring in public function
124
+ "D104", # Missing docstring in public package
125
+ "D107", # Missing docstring in `__init__`
126
+ "D401", # First line of docstring should be in imperative mood
127
+ "S603", # subprocess calls with shell=True
128
+ ]
129
+ lint.select = [
130
+ "B", # flake8-bugbear
131
+ "C4", # flake8-comprehensions
132
+ "S", # flake8-bandit
133
+ "F", # pyflake
134
+ "E", # pycodestyle
135
+ "W", # pycodestyle
136
+ "UP", # pyupgrade
137
+ "I", # isort
138
+ "RUF", # ruff specific
139
+ ]
140
+ exclude = [
141
+ "bootstrap.py"
142
+ ]
143
+
144
+ [tool.ruff.lint.per-file-ignores]
145
+ "tests/**/*" = [
146
+ "D100",
147
+ "D101",
148
+ "D102",
149
+ "D103",
150
+ "D104",
151
+ "S101",
152
+ ]
153
+ "setup.py" = ["D100"]
154
+ "conftest.py" = ["D100"]
155
+ "docs/conf.py" = ["D100"]
156
+
157
+ [tool.ruff.lint.isort]
158
+ known-first-party = ["spl_core", "tests"]
159
+
160
+ [tool.mypy]
161
+ check_untyped_defs = true
162
+ disallow_any_generics = true
163
+ disallow_incomplete_defs = true
164
+ disallow_untyped_defs = true
165
+ mypy_path = "src/"
166
+ no_implicit_optional = true
167
+ show_error_codes = true
168
+ warn_unreachable = true
169
+ warn_unused_ignores = true
170
+ exclude = [
171
+ 'docs/.*',
172
+ 'setup.py',
173
+ ]
174
+
175
+ [[tool.mypy.overrides]]
176
+ module = "tests.*"
177
+ allow_untyped_defs = true
178
+
179
+ [[tool.mypy.overrides]]
180
+ module = "docs.*"
181
+ ignore_errors = true
182
+
183
+ [build-system]
184
+ requires = ["poetry-core>=1.0.0"]
185
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1 @@
1
+ __version__ = "4.0.0"
File without changes
@@ -0,0 +1,52 @@
1
+ import logging
2
+ import subprocess
3
+ from subprocess import CompletedProcess
4
+
5
+ from spl_core.project_creator.variant import Variant
6
+ from spl_core.project_creator.workspace_artifacts import WorkspaceArtifacts
7
+
8
+
9
+ class CMake:
10
+ executable = "cmake"
11
+
12
+ def __init__(self, workspace_artifacts: WorkspaceArtifacts):
13
+ self.logger = logging.getLogger(__name__)
14
+ self.workspace_artifacts = workspace_artifacts
15
+
16
+ def run(self, variant: Variant, build_kit: str = "prod", target: str = "all") -> CompletedProcess[bytes]:
17
+ ret_status = self.configure(variant, build_kit)
18
+ if ret_status.returncode == 0:
19
+ ret_status = self.build(variant, build_kit, target)
20
+ return ret_status
21
+
22
+ def configure(self, variant: Variant, build_kit: str = "prod") -> CompletedProcess[bytes]:
23
+ arguments = (
24
+ f" --log-level=DEBUG"
25
+ f" -S{self.workspace_artifacts.root_dir}"
26
+ f" -B{self.workspace_artifacts.get_build_dir(variant, build_kit)}"
27
+ f" -G Ninja "
28
+ f" -DBUILD_KIT:STRING={build_kit}"
29
+ f" -DVARIANT:STRING={variant.to_string()}"
30
+ f" -DCMAKE_BUILD_TYPE:STRING={variant.to_string('_')}"
31
+ )
32
+ if build_kit == "test":
33
+ toolchain = self.workspace_artifacts.root_dir.joinpath(
34
+ "tools\\toolchains\\gcc\\toolchain.cmake"
35
+ )
36
+ arguments += f" -DCMAKE_TOOLCHAIN_FILE={toolchain}"
37
+ return self.run_cmake(arguments)
38
+
39
+ def build(
40
+ self, variant: Variant, build_kit: str = "prod", target: str = "all"
41
+ ) -> CompletedProcess[bytes]:
42
+ arguments = (
43
+ f" --build {self.workspace_artifacts.get_build_dir(variant, build_kit)}"
44
+ f" --config {variant.to_string('_')}"
45
+ f" --target {target} -- "
46
+ )
47
+ return self.run_cmake(arguments)
48
+
49
+ def run_cmake(self, arguments: str) -> CompletedProcess[bytes]:
50
+ command = self.executable + " " + arguments
51
+ print(f"Running {command}")
52
+ return subprocess.run(command.split())
@@ -0,0 +1,17 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def to_path(input_path: str, check_if_exists: bool = True) -> Path:
5
+ return_path = Path(input_path)
6
+ if not check_if_exists or return_path.exists():
7
+ return return_path.absolute()
8
+ else:
9
+ raise FileNotFoundError(input_path)
10
+
11
+
12
+ def existing_path(input_path: str) -> Path:
13
+ return to_path(input_path, True)
14
+
15
+
16
+ def non_existing_path(input_path: str) -> Path:
17
+ return to_path(input_path, False)
File without changes
@@ -0,0 +1,48 @@
1
+ import argparse
2
+ from pathlib import Path
3
+
4
+
5
+ def main() -> None:
6
+ parser = argparse.ArgumentParser(description="Script with command line options")
7
+ parser.add_argument(
8
+ "--working-dir", help="Working directory", required=True
9
+ ) # Make the option mandatory
10
+ parser.add_argument(
11
+ "--wipe-all-gcda", action="store_true", help="Wipe all gcda files recursively"
12
+ )
13
+ parser.add_argument(
14
+ "--wipe-orphaned-gcno",
15
+ action="store_true",
16
+ help="Wipe orphaned gcno files recursively",
17
+ )
18
+
19
+ args = parser.parse_args()
20
+
21
+ # Access the command line options
22
+ working_dir = Path(args.working_dir) # Convert the string to a Path object
23
+ wipe_gcda = bool(args.wipe_all_gcda) # Convert the switch value to boolean
24
+ wipe_gcno = bool(args.wipe_orphaned_gcno) # Convert the switch value to boolean
25
+
26
+ if wipe_gcda:
27
+ wipe_gcda_files(working_dir)
28
+
29
+ if wipe_gcno:
30
+ wipe_gcno_files(working_dir)
31
+
32
+
33
+ def wipe_gcda_files(working_dir: Path) -> None:
34
+ for file in working_dir.glob("**/*.gcda"):
35
+ print(f"Deleting obsolete coverage data file: {file}")
36
+ file.unlink()
37
+
38
+
39
+ def wipe_gcno_files(working_dir: Path) -> None:
40
+ for file in working_dir.glob("**/*.gcno"):
41
+ obj_file = file.with_suffix(".obj")
42
+ if not obj_file.exists():
43
+ print(f"Deleting obsolete coverage notes file: {file}")
44
+ file.unlink()
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()
File without changes