spl-core 4.0.0__py3-none-any.whl

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/__init__.py +1 -0
  2. spl_core/common/__init__.py +0 -0
  3. spl_core/common/cmake.py +52 -0
  4. spl_core/common/path.py +17 -0
  5. spl_core/gcov_maid/__init__.py +0 -0
  6. spl_core/gcov_maid/gcov_maid.py +48 -0
  7. spl_core/kconfig/__init__.py +0 -0
  8. spl_core/kconfig/kconfig.py +271 -0
  9. spl_core/project_creator/__init__.py +0 -0
  10. spl_core/project_creator/creator.py +133 -0
  11. spl_core/project_creator/templates/project/cookiecutter.json +14 -0
  12. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.flake8 +2 -0
  13. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.gitignore +33 -0
  14. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/cmake-kits.json +11 -0
  15. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/cmake-variants.json +18 -0
  16. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/extensions.json +18 -0
  17. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/launch.json +37 -0
  18. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/settings.json +45 -0
  19. spl_core/project_creator/templates/project/{{cookiecutter.name}}/.vscode/tasks.json +93 -0
  20. spl_core/project_creator/templates/project/{{cookiecutter.name}}/CMakeLists.txt +43 -0
  21. spl_core/project_creator/templates/project/{{cookiecutter.name}}/KConfig +23 -0
  22. spl_core/project_creator/templates/project/{{cookiecutter.name}}/LICENSE +21 -0
  23. spl_core/project_creator/templates/project/{{cookiecutter.name}}/Pipfile +33 -0
  24. spl_core/project_creator/templates/project/{{cookiecutter.name}}/README.md +7 -0
  25. spl_core/project_creator/templates/project/{{cookiecutter.name}}/build.bat +1 -0
  26. spl_core/project_creator/templates/project/{{cookiecutter.name}}/build.ps1 +245 -0
  27. spl_core/project_creator/templates/project/{{cookiecutter.name}}/conf.py +200 -0
  28. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/Doxyfile.in +2774 -0
  29. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/common/index.rst +5 -0
  30. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/components/index.rst +23 -0
  31. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/doxygen-awesome/LICENSE +21 -0
  32. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/doxygen-awesome/doxygen-awesome.css +2530 -0
  33. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/software_architecture/index.rst +2 -0
  34. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/software_requirements/index.rst +7 -0
  35. spl_core/project_creator/templates/project/{{cookiecutter.name}}/doc/test_report_template.txt +46 -0
  36. spl_core/project_creator/templates/project/{{cookiecutter.name}}/index.rst +38 -0
  37. spl_core/project_creator/templates/project/{{cookiecutter.name}}/install-mandatory.bat +1 -0
  38. spl_core/project_creator/templates/project/{{cookiecutter.name}}/pytest.ini +9 -0
  39. spl_core/project_creator/templates/project/{{cookiecutter.name}}/scoopfile.json +47 -0
  40. spl_core/project_creator/templates/project/{{cookiecutter.name}}/test/test_build.py +39 -0
  41. spl_core/project_creator/templates/project/{{cookiecutter.name}}/test/test_unittests.py +28 -0
  42. spl_core/project_creator/templates/project/{{cookiecutter.name}}/test/utils.py +26 -0
  43. spl_core/project_creator/templates/project/{{cookiecutter.name}}/tools/setup/git-config.ps1 +8 -0
  44. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/CMakeLists.txt +3 -0
  45. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/doc/_images/screenshot.png +0 -0
  46. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/doc/design.rst +25 -0
  47. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/doc/index.rst +8 -0
  48. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/src/component.c +31 -0
  49. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/src/component.h +1 -0
  50. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/component/test/test_component.cc +60 -0
  51. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/main/CMakeLists.txt +2 -0
  52. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/main/doc/index.rst +14 -0
  53. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_components -%} components {%- endif %}/main/src/main.c +17 -0
  54. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_tools -%} tools {%- endif %}/toolchains/clang/toolchain.cmake +8 -0
  55. spl_core/project_creator/templates/project/{{cookiecutter.name}}/{% if cookiecutter.touch_tools -%} tools {%- endif %}/toolchains/gcc/toolchain.cmake +3 -0
  56. spl_core/project_creator/templates/variant/cookiecutter.json +4 -0
  57. spl_core/project_creator/templates/variant/{{cookiecutter.flavor}}/{{cookiecutter.subsystem}}/config.cmake +1 -0
  58. spl_core/project_creator/templates/variant/{{cookiecutter.flavor}}/{{cookiecutter.subsystem}}/config.txt +1 -0
  59. spl_core/project_creator/templates/variant/{{cookiecutter.flavor}}/{{cookiecutter.subsystem}}/parts.cmake +2 -0
  60. spl_core/project_creator/variant.py +23 -0
  61. spl_core/project_creator/workspace_artifacts.py +36 -0
  62. spl_core-4.0.0.dist-info/LICENSE +22 -0
  63. spl_core-4.0.0.dist-info/METADATA +62 -0
  64. spl_core-4.0.0.dist-info/RECORD +65 -0
  65. spl_core-4.0.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,45 @@
1
+ {
2
+ "python.testing.pytestEnabled": true,
3
+ "python.testing.pytestArgs": [
4
+ "test"
5
+ ],
6
+ "python.testing.unittestEnabled": false,
7
+ "python.analysis.extraPaths": [
8
+ "test"
9
+ ],
10
+ "cmake.configureOnOpen": false,
11
+ "cmake.buildDirectory": "${workspaceFolder}/build/${variant:variant}/${buildKit}",
12
+ "cmake.configureSettings": {
13
+ "BUILD_KIT": "${buildKit}",
14
+ "CMAKE_MESSAGE_LOG_LEVEL": "STATUS"
15
+ },
16
+ "cmake.generator": "Ninja",
17
+ "cmake.debugConfig": {
18
+ "MIMode": "gdb",
19
+ "miDebuggerPath": "gdb",
20
+ "stopAtEntry": true
21
+ },
22
+ "cmake.configureOnEdit": false,
23
+ "cmake.buildBeforeRun": false,
24
+ "cmake.environment": {
25
+ "PIPENV_VERBOSITY": "-1",
26
+ "PIPENV_VENV_IN_PROJECT": "1"
27
+ },
28
+ "cmake.buildToolArgs": [],
29
+ "git.ignoreLimitWarning": true,
30
+ "C_Cpp.errorSquiggles": "enabled",
31
+ "C_Cpp.default.cStandard": "gnu17",
32
+ "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
33
+ "C_Cpp.formatting": "vcFormat",
34
+ "files.associations": {
35
+ "*.h": "c",
36
+ "*.c": "c",
37
+ "Jenkinsfile": "groovy",
38
+ "*.py": "python"
39
+ },
40
+ "git.repositoryScanMaxDepth": 3,
41
+ "git-graph.maxDepthOfRepoSearch": 3,
42
+ "[python]": {
43
+ "editor.defaultFormatter": "ms-python.black-formatter"
44
+ }
45
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "Get mandatory tools",
6
+ "detail": "Installation of mandatory tools",
7
+ "type": "shell",
8
+ "command": ".\\build.ps1 -install",
9
+ "problemMatcher": []
10
+ },
11
+ {
12
+ "label": "Update all tools",
13
+ "detail": "Update of all installed scoop packages",
14
+ "type": "shell",
15
+ "command": ".\\build.ps1 -command 'scoop update --all'",
16
+ "problemMatcher": []
17
+ },
18
+ {
19
+ "label": "Environment",
20
+ "detail": "Print all environment variables for debugging purposes",
21
+ "type": "shell",
22
+ "command": "dir env:",
23
+ "problemMatcher": []
24
+ },
25
+ {
26
+ "type": "cmake",
27
+ "label": "Build with CMake",
28
+ "detail": "Build target 'all' of selected variant",
29
+ "command": "build",
30
+ "targets": [
31
+ "all"
32
+ ],
33
+ "group": {
34
+ "kind": "build",
35
+ "isDefault": true
36
+ },
37
+ "problemMatcher": [
38
+ {
39
+ "owner": "c/cpp",
40
+ "fileLocation": [
41
+ "absolute"
42
+ ],
43
+ "pattern": {
44
+ "regexp": "^ctc (I|W|E)(\\d+): \\[\"(.*)\" (\\d+)/(\\d+)\\] (.*)",
45
+ "file": 3,
46
+ "line": 4,
47
+ "column": 5,
48
+ "severity": 1,
49
+ "message": 6
50
+ }
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "type": "cmake",
56
+ "label": "Clean with CMake",
57
+ "command": "clean",
58
+ "problemMatcher": [],
59
+ "detail": "Clean build artifacts of selected variant"
60
+ },
61
+ {
62
+ "type": "cmake",
63
+ "label": "Configure with CMake",
64
+ "command": "configure",
65
+ "problemMatcher": [],
66
+ "detail": "Configure selected variant"
67
+ },
68
+ {
69
+ "label": "Configure variant",
70
+ "detail": "Feature configuration using KConfig",
71
+ "type": "shell",
72
+ "command": "pipenv run guiconfig",
73
+ "options": {
74
+ "env": {
75
+ "KCONFIG_CONFIG": "variants/${input:variant}/config.txt"
76
+ }
77
+ },
78
+ "problemMatcher": []
79
+ }
80
+ ],
81
+ "inputs": [
82
+ {
83
+ "type": "pickString",
84
+ "id": "variant",
85
+ "description": "Which variant do you want to select?",
86
+ "options": [
87
+ {%- for variant in cookiecutter.variants.values() -%}
88
+ "{{ variant["flavor"] }}/{{ variant["subsystem"] }}",
89
+ {%- endfor -%}
90
+ ]
91
+ }
92
+ ]
93
+ }
@@ -0,0 +1,43 @@
1
+ # cmake project definition
2
+ cmake_minimum_required(VERSION 3.24.0)
3
+ cmake_policy(VERSION 3.24)
4
+
5
+ set(BUILD_KIT prod CACHE STRING "Target Group to build.")
6
+
7
+ include(${CMAKE_SOURCE_DIR}/variants/${VARIANT}/config.cmake)
8
+
9
+ if(BUILD_KIT STREQUAL prod)
10
+ project(${VARIANT} C ASM)
11
+ else()
12
+ project(${VARIANT} C ASM CXX)
13
+ set(VARIANT_ADDITIONAL_COMPILE_C_FLAGS -Dstatic= -save-temps)
14
+ endif()
15
+
16
+ # Fetch all external dependencies into modules directory
17
+ set(FETCHCONTENT_BASE_DIR ${CMAKE_SOURCE_DIR}/build/modules CACHE INTERNAL "")
18
+ set(FETCHCONTENT_QUIET FALSE)
19
+ include(FetchContent)
20
+
21
+ # Include spl-core
22
+ if(DEFINED ENV{SPLCORE_PATH})
23
+ message(WARNING "SPLCORE_PATH defined! Use fixed SPL-CORE version from: $ENV{SPLCORE_PATH}")
24
+ include($ENV{SPLCORE_PATH}/cmake/spl.cmake)
25
+ else()
26
+ # Fetch spl-core
27
+ FetchContent_Declare(
28
+ spl-core
29
+ GIT_REPOSITORY https://github.com/avengineers/spl-core.git
30
+ GIT_TAG develop
31
+ )
32
+ FetchContent_MakeAvailable(spl-core)
33
+
34
+ # Include spl-core
35
+ include(${spl-core_SOURCE_DIR}/cmake/spl.cmake)
36
+ endif()
37
+
38
+ include(${CMAKE_SOURCE_DIR}/variants/${VARIANT}/parts.cmake)
39
+
40
+ # TODO: refactor/remove; we want to explicitly add includes where required
41
+ foreach(component_name ${COMPONENT_NAMES})
42
+ target_include_directories(${component_name} PUBLIC ${target_include_directories__INCLUDES})
43
+ endforeach()
@@ -0,0 +1,23 @@
1
+ mainmenu "SPL Example"
2
+
3
+ menu "Linking"
4
+ config LINKER_OUTPUT_FILE
5
+ string
6
+ prompt "LINKER_OUTPUT_FILE"
7
+ default "my_main.exe"
8
+ help
9
+ The output file generated by the linker (e.g. my_main.exe).
10
+
11
+ config LINKER_BYPRODUCTS_EXTENSIONS
12
+ string
13
+ prompt "LINKER_BYPRODUCTS_EXTENSIONS"
14
+ default "map"
15
+ help
16
+ The extensions of other byproducts generated by the linker (e.g. map)
17
+ endmenu
18
+
19
+ menu "Feature Model"
20
+ config USE_COMPONENT
21
+ bool "Enable features of component"
22
+ default n
23
+ endmenu
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 - present Marquardt GmbH and members of AVENGINEERS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ [[source]]
2
+ url = "https://pypi.org/simple"
3
+ verify_ssl = true
4
+ name = "pypi"
5
+
6
+ [packages]
7
+ cookiecutter = "*"
8
+ gcovr = "*"
9
+ hammocking = "*"
10
+ kconfiglib = "*"
11
+ jinja2 = "*"
12
+ pytest = "*"
13
+ pytest-env = "*"
14
+ testfixtures = "*"
15
+ junitparser = "*"
16
+ mashumaro = "*"
17
+ loguru = "*"
18
+ black = "*"
19
+ flake8 = "*"
20
+ sphinx = "*"
21
+ sphinx-rtd-theme = "*"
22
+ sphinxcontrib-mermaid = "*"
23
+ sphinx-needs = "*"
24
+ sphinx-test-reports = "*"
25
+ doxysphinx = "*"
26
+ sphinx-rtd-size = "*"
27
+ sphinxcontrib-datatemplates = "*"
28
+ pyelftools = "*"
29
+ sphinxcontrib-plantuml = "*"
30
+ pipenv = "*"
31
+
32
+ [requires]
33
+ python_version = "3.11"
@@ -0,0 +1,7 @@
1
+ # Software Product Line {{cookiecutter.name}}
2
+
3
+
4
+ ## Preparation
5
+
6
+ You can install required tools and install some VS Code extensions. The installer uses Scoop/PowerShell, so it will only run on Windows. The installation is done by executing `install-mandatory.bat`. In case you are sitting behind a proxy server, make sure to add:
7
+
@@ -0,0 +1 @@
1
+ powershell -ExecutionPolicy Bypass -File %~dp0build.ps1 %* || exit /b 1
@@ -0,0 +1,245 @@
1
+ <#
2
+ .DESCRIPTION
3
+ Wrapper for installing dependencies and building the product.
4
+
5
+ .Notes
6
+ On Windows, it may be required to call this script with the proper execution policy.
7
+ You can do this by issuing the following PowerShell command:
8
+
9
+ PS C:\> powershell -ExecutionPolicy Bypass -File .\build.ps1
10
+
11
+ For more information on Execution Policies:
12
+ https://go.microsoft.com/fwlink/?LinkID=135170
13
+ #>
14
+
15
+ param(
16
+ [Parameter(Mandatory = $false, HelpMessage = 'Install all dependencies required to build. (Switch, default: false)')]
17
+ [switch]$install = $false,
18
+ [Parameter(Mandatory = $false, HelpMessage = 'Clean build, wipe out all build artifacts. (Switch, default: false)')]
19
+ [switch]$clean = $false,
20
+ [Parameter(Mandatory = $false, HelpMessage = 'Build kit to be used. (String, default: "prod")')]
21
+ [string]$buildKit = "prod",
22
+ [Parameter(Mandatory = $false, HelpMessage = 'Target to be built. (String, default: "all")')]
23
+ [string]$target = "all",
24
+ [Parameter(Mandatory = $false, HelpMessage = 'Variants (of the product) to be built (List of strings, leave empty to be asked or "all" for automatic build of all variants)')]
25
+ [string[]]$variants = $null,
26
+ [Parameter(Mandatory = $false, HelpMessage = 'filter for selftests; define in pytest syntax: https://docs.pytest.org/en/6.2.x/usage.html; e.g. "Disco or test_CustA__Disco.py"')]
27
+ [string]$filter = "",
28
+ [Parameter(Mandatory = $false, HelpMessage = 'Additional build arguments for Ninja (e.g., "-d explain -d keepdepfile" for debugging purposes)')]
29
+ [string]$ninjaArgs = "",
30
+ [Parameter(Mandatory = $false, HelpMessage = 'Delete CMake cache and reconfigure. (Switch, default: false)')]
31
+ [switch]$reconfigure = $false
32
+ )
33
+
34
+ # Call a command and handle its exit code
35
+ Function Invoke-CommandLine {
36
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression', '', Justification = 'Usually this statement must be avoided (https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/avoid-using-invoke-expression?view=powershell-7.3), here it is OK as it does not execute unknown code.')]
37
+ param (
38
+ [Parameter(Mandatory = $true, Position = 0)]
39
+ [string]$CommandLine,
40
+ [Parameter(Mandatory = $false, Position = 1)]
41
+ [bool]$StopAtError = $true,
42
+ [Parameter(Mandatory = $false, Position = 2)]
43
+ [bool]$Silent = $false
44
+ )
45
+ if (-Not $Silent) {
46
+ Write-Output "Executing: $CommandLine"
47
+ }
48
+ $global:LASTEXITCODE = 0
49
+ Invoke-Expression $CommandLine
50
+ if ($global:LASTEXITCODE -ne 0) {
51
+ if ($StopAtError) {
52
+ Write-Error "Command line call '$CommandLine' failed with exit code $global:LASTEXITCODE"
53
+ }
54
+ else {
55
+ if (-Not $Silent) {
56
+ Write-Output "Command line call '$CommandLine' failed with exit code $global:LASTEXITCODE, continuing ..."
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ # Update/Reload current environment variable PATH with settings from registry
63
+ Function Initialize-EnvPath {
64
+ # workaround for system-wide installations
65
+ if ($Env:USER_PATH_FIRST) {
66
+ $Env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine")
67
+ }
68
+ else {
69
+ $Env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
70
+ }
71
+ }
72
+
73
+ function Test-RunningInCIorTestEnvironment {
74
+ return [Boolean]($Env:JENKINS_URL -or $Env:PYTEST_CURRENT_TEST -or $Env:GITHUB_ACTIONS)
75
+ }
76
+
77
+ # Build with given parameters
78
+ Function Invoke-Build {
79
+ param (
80
+ [Parameter(Mandatory = $false)]
81
+ [bool]$clean = $false,
82
+ [Parameter(Mandatory = $false)]
83
+ [string]$buildKit = "prod",
84
+ [Parameter(Mandatory = $true)]
85
+ [string]$target = "all",
86
+ [Parameter(Mandatory = $false)]
87
+ [string[]]$variants = $null,
88
+ [Parameter(Mandatory = $false)]
89
+ [string]$filter = "",
90
+ [Parameter(Mandatory = $false)]
91
+ [string]$ninjaArgs = "",
92
+ [Parameter(Mandatory = $false)]
93
+ [bool]$reconfigure = $false
94
+ )
95
+ if ("selftests" -eq $target) {
96
+ # Run python tests to test all relevant variants and platforms (build kits)
97
+ # (normally run in CI environment/Jenkins)
98
+ Write-Output "Running all selfstests ..."
99
+
100
+ # Build folder for CMake builds
101
+ $buildFolder = "build"
102
+
103
+ # fresh and clean CMake builds
104
+ if ($clean) {
105
+ if (Test-Path -Path $buildFolder) {
106
+ Write-Output "Removing build folder '$buildFolder' ..."
107
+ Remove-Item $buildFolder -Force -Recurse
108
+ }
109
+ }
110
+
111
+ # Filter pytest test cases
112
+ $filterCmd = ''
113
+ # Consider environment variable BRANCH_NAME (e.g. on Jenkins) to filter tests in release branch builds
114
+ if ($Env:BRANCH_NAME -and ($Env:BRANCH_NAME -match 'release/([^/]+/[^/]+)(.*)')) {
115
+ $filterCmd = "-k " + $Matches[1]
116
+ }
117
+ # otherwise consider command line option '-filter' if given
118
+ elseif ($filter) {
119
+ $filterCmd = "-k '$filter'"
120
+ }
121
+
122
+ # Test result of pytest
123
+ $pytestJunitXml = "test/output/test-report.xml"
124
+
125
+ # Delete any old pytest result
126
+ if (Test-Path -Path $pytestJunitXml) {
127
+ Remove-Item $pytestJunitXml -Force
128
+ }
129
+
130
+ # Finally run pytest
131
+ Invoke-CommandLine -CommandLine "python -m pipenv run python -m pytest test --junitxml=$pytestJunitXml $filterCmd"
132
+ }
133
+ else {
134
+ if ((-Not $variants) -or ($variants -eq 'all')) {
135
+ $dirs = Get-Childitem -Include config.cmake -Path variants -Recurse | Resolve-Path -Relative
136
+ $variantsList = @()
137
+ Foreach ($dir in $dirs) {
138
+ $variant = (get-item $dir).Directory.Parent.BaseName + "/" + (get-item $dir).Directory.BaseName
139
+ $variantsList += $variant
140
+ }
141
+ $variantsSelected = @()
142
+ if (-Not $variants) {
143
+ # variant selection by user if not specified
144
+ Write-Information -Tags "Info:" -MessageData "no '--variant <variant>' was given, please select from list:"
145
+ Foreach ($variant in $variantsList) {
146
+ Write-Information -Tags "Info:" -MessageData ("(" + [array]::IndexOf($variantsList, $variant) + ") " + $variant)
147
+ }
148
+ $variantsSelected += $variantsList[[int](Read-Host "Please enter selected variant number")]
149
+ Write-Information -Tags "Info:" -MessageData "Selected variant is: $variantsSelected"
150
+ }
151
+ else {
152
+ # otherwise build all variants
153
+ $variantsSelected = $variantsList
154
+ }
155
+ }
156
+ else {
157
+ $variantsSelected = $Variants.Replace('\', '/').Replace('./variant/', '').Replace('./variants/', '').Split(',')
158
+ }
159
+
160
+ # Select 'test' build kit based on target
161
+ if ($target.Contains("unittests") -or $target.Contains("reports")) {
162
+ $buildKit = "test"
163
+ }
164
+
165
+ Foreach ($variant in $variantsSelected) {
166
+ Write-Output "Building target '$target' with build kit '$buildKit' for variant '$variant' ..."
167
+
168
+ $buildFolder = "build/$variant/$buildKit"
169
+ # fresh and clean build
170
+ if ($clean) {
171
+ if (Test-Path -Path $buildFolder) {
172
+ Write-Output "Removing build folder '$buildFolder' ..."
173
+ Remove-Item $buildFolder -Force -Recurse
174
+ }
175
+ }
176
+
177
+ # delete CMake cache and reconfigure
178
+ if ($reconfigure) {
179
+ if (Test-Path -Path "$buildFolder/CMakeCache.txt") {
180
+ Remove-Item "$buildFolder/CMakeCache.txt" -Force
181
+ }
182
+ if (Test-Path -Path "$buildFolder/CMakeFiles") {
183
+ Remove-Item "$buildFolder/CMakeFiles" -Force -Recurse
184
+ }
185
+ }
186
+
187
+ # CMake configure
188
+ $additionalConfig = "-DBUILD_KIT='$buildKit'"
189
+ if ($buildKit -eq "test") {
190
+ $additionalConfig += " -DCMAKE_TOOLCHAIN_FILE='tools/toolchains/gcc/toolchain.cmake'"
191
+ }
192
+ Invoke-CommandLine -CommandLine "python -m pipenv run cmake -B '$buildFolder' -G Ninja -DVARIANT='$variant' $additionalConfig"
193
+
194
+ # CMake clean all dead artifacts. Required when running incremented builds to delete obsolete artifacts.
195
+ Invoke-CommandLine -CommandLine "python -m pipenv run cmake --build '$buildFolder' --target $target -- -t cleandead"
196
+ # CMake build
197
+ Invoke-CommandLine -CommandLine "python -m pipenv run cmake --build '$buildFolder' --target $target -- $ninjaArgs"
198
+ }
199
+ }
200
+ }
201
+
202
+ ## start of script
203
+ # Always set the $InformationPreference variable to "Continue" globally,
204
+ # this way it gets printed on execution and continues execution afterwards.
205
+ $InformationPreference = "Continue"
206
+
207
+ # Stop on first error
208
+ $ErrorActionPreference = "Stop"
209
+
210
+ Push-Location $PSScriptRoot
211
+ Write-Output "Running in ${pwd}"
212
+
213
+ try {
214
+ if ($install) {
215
+ # Installation of Scoop, Python and pipenv via bootstrap
216
+ if (-Not (Test-Path -Path '.bootstrap')) {
217
+ New-Item -ItemType Directory '.bootstrap'
218
+ }
219
+ Invoke-RestMethod "https://raw.githubusercontent.com/avengineers/bootstrap/v1.3.0/bootstrap.ps1" -OutFile ".\.bootstrap\bootstrap.ps1"
220
+ Invoke-CommandLine ". .\.bootstrap\bootstrap.ps1" -Silent $true
221
+ Write-Output "For installation changes to take effect, please close and re-open your current shell."
222
+ }
223
+ else {
224
+ # Call build system
225
+ if (Test-RunningInCIorTestEnvironment -or $Env:USER_PATH_FIRST) {
226
+ Initialize-EnvPath
227
+ }
228
+ # Call CMake
229
+ Invoke-Build `
230
+ -target $target `
231
+ -buildKit $buildKit `
232
+ -variants $variants `
233
+ -clean $clean `
234
+ -reconfigure $reconfigure `
235
+ -ninjaArgs $ninjaArgs `
236
+ -filter $filter
237
+ }
238
+ }
239
+ finally {
240
+ Pop-Location
241
+ if (-Not (Test-RunningInCIorTestEnvironment)) {
242
+ Read-Host -Prompt "Press Enter to continue ..."
243
+ }
244
+ }
245
+ ## end of script