Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support variants with arbitrary path depth, some cleanup #73

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,8 @@
"titleBar.inactiveBackground": "#21573299",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#215732"
"peacock.color": "#215732",
"editor.formatOnSave": true,
"restructuredtext.pythonRecommendation.disabled": true,
"files.insertFinalNewline": true
}
50 changes: 0 additions & 50 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,13 @@
"command": ".\\build.ps1 -install",
"problemMatcher": []
},
{
"label": "Update all tools",
"detail": "Update of all installed scoop packages",
"type": "shell",
"command": ".\\build.ps1 -command 'scoop update --all'",
"problemMatcher": []
},
{
"label": "Environment",
"detail": "Print all environment variables for debugging purposes",
"type": "shell",
"command": "dir env:",
"problemMatcher": []
},
{
"type": "cmake",
"label": "Build with CMake",
"detail": "Build target 'all' of selected variant",
"command": "build",
"targets": [
"all"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
{
"owner": "c/cpp",
"fileLocation": [
"absolute"
],
"pattern": {
"regexp": "^ctc (I|W|E)(\\d+): \\[\"(.*)\" (\\d+)/(\\d+)\\] (.*)",
"file": 3,
"line": 4,
"column": 5,
"severity": 1,
"message": 6
}
}
]
},
{
"type": "cmake",
"label": "Clean with CMake",
"command": "clean",
"problemMatcher": [],
"detail": "Clean build artifacts of selected variant"
},
{
"type": "cmake",
"label": "Configure with CMake",
"command": "configure",
"problemMatcher": [],
"detail": "Configure selected variant"
},
{
"label": "Configure variant",
"detail": "Feature configuration using KConfig",
Expand Down
47 changes: 40 additions & 7 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ function Invoke-Build-System {
[bool]$configureOnly = $false
)
# Determine variants to be built
$defaultVariantsFolder = ".\variants\"
if ((-Not $variants) -or ($variants -eq 'all')) {
$dirs = Get-Childitem -Include config.cmake -Path variants -Recurse | Resolve-Path -Relative
$variantConfigs = Get-Childitem -Include config.cmake -Path $defaultVariantsFolder -Recurse | Resolve-Path -Relative
$variantsList = @()
Foreach ($dir in $dirs) {
$variant = (get-item $dir).Directory.Parent.BaseName + "/" + (get-item $dir).Directory.BaseName
Foreach ($variantConfig in $variantConfigs) {
$variant = ((Get-Item $variantConfig).Directory | Resolve-Path -Relative).Replace($defaultVariantsFolder, "").Replace("\", "/")
$variantsList += $variant
}
$variantsSelected = @()
Expand Down Expand Up @@ -153,7 +154,7 @@ function Invoke-Build-System {
}
}
else {
$variantsSelected = $Variants.Replace('\', '/').Replace('./variant/', '').Replace('./variants/', '').Split(',') | ForEach-Object { $_.TrimEnd('/') }
$variantsSelected = $Variants.Replace($defaultVariantsFolder, "").Replace("\", "/").Split(',') | ForEach-Object { $_.TrimEnd('/') }
}

# Select 'test' build kit based on target
Expand Down Expand Up @@ -264,6 +265,16 @@ function New-Directory {
}
}

function Get-User-Menu-Selection {
if ((-Not $install) -and (-Not $build) -and (-Not $command) -and (-Not $selftests)) {
Clear-Host
Write-Information -Tags "Info:" -MessageData "None of the following command line options was given:"
Write-Information -Tags "Info:" -MessageData ("(1) -install: installation of mandatory dependencies")
Write-Information -Tags "Info:" -MessageData ("(2) -build: execute CMake build")
return(Read-Host "Please make a selection")
}
}

function Invoke-Bootstrap {
# Download bootstrap scripts from external repository
Invoke-RestMethod -Uri https://raw.githubusercontent.com/avengineers/bootstrap-installer/v1.14.0/install.ps1 | Invoke-Expression
Expand All @@ -285,17 +296,39 @@ Push-Location $PSScriptRoot
Write-Output "Running in ${pwd}"

try {
if (Test-RunningInCIorTestEnvironment -or $Env:USER_PATH_FIRST) {
Initialize-EnvPath
}

$selectedOption = Get-User-Menu-Selection

switch ($selectedOption) {
'1' {
Write-Information -Tags "Info:" -MessageData "Installing Dependencies ..."
$install = $true
}
'2' {
Write-Information -Tags "Info:" -MessageData "Building ..."
$build = $true
}
default {
Write-Information -Tags "Info:" -MessageData "Nothing selected."
}
}

if ($install) {
if ($clean) {
Remove-Path ".venv"
}

# bootstrap environment
Invoke-Bootstrap
}

if (Test-RunningInCIorTestEnvironment -or $Env:USER_PATH_FIRST) {
Initialize-EnvPath
if (Test-RunningInCIorTestEnvironment -or $Env:USER_PATH_FIRST) {
Initialize-EnvPath
}

Write-Host -ForegroundColor Black -BackgroundColor Blue "For installation changes to take effect, please close and re-open your current terminal."
}

if ($build) {
Expand Down
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[pytest]
pythonpath =
test
"test"
testpaths =
test
"test"
junit_logging = all
addopts =
--capture=tee-sys
Expand Down
4 changes: 2 additions & 2 deletions src/examples/check_abort/src/check_abort.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "check_abort.h"

// Example function to demonstrate the use of MC/DC coverage.
// See this youtvbe video for more information:
// Example function to demonstrate the use of MC/DC (code coverage metric).
// See this youtube video for more information:
// https://www.youtube.com/watch?v=k0_PF8MtEEo
boolean CheckAbort(boolean off_course, boolean abort_commanded, boolean valid_abort_command) {
if (off_course || (abort_commanded && valid_abort_command)) {
Expand Down
2 changes: 1 addition & 1 deletion src/examples/check_abort/test/test_check_abort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
#include "mockup_src_examples_check_abort.h"

// Just provide a simple test case for the function CheckAbort
// to reach 100% MC/DC coverage.
// to reach 100% MC/DC.
TEST(check_abort, test_mcdc)
{
CREATE_MOCK(mymock);
Expand Down
8 changes: 3 additions & 5 deletions tools/toolchains/clang/toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# TODO: caching required due to cmake tools extension issue: https://github.com/microsoft/vscode-cmake-tools/issues/1188
# TODO: get debugging running (lldb-mi not found in any current package, switching back to gcc)
set(CMAKE_C_COMPILER clang CACHE STRING "C Compiler")
# TODO: clarify why llvm-cov produces invalid gcov files (contain blank lines), releated GCOVR issue: https://github.com/gcovr/gcovr/issues/331
set(GCOVR_ADDITIONAL_OPTIONS --gcov-executable \"llvm-cov gcov\" --gcov-ignore-parse-errors --html-title \"Code Coverage Report \(tool suite: LLVM Clang\)\")

set(CMAKE_CXX_COMPILER clang++ CACHE STRING "CXX Compiler")
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER} CACHE STRING "ASM Compiler")

# TODO: clarify why llvm-cov produces invalid gcov files (contain blank lines), releated GCOVR issue: https://github.com/gcovr/gcovr/issues/331
set(GCOVR_ADDITIONAL_OPTIONS --gcov-executable \"llvm-cov gcov\" --gcov-ignore-parse-errors --html-title \"Code Coverage Report \(tool suite: LLVM Clang\)\")