Skip to content
Open
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ build*/
_build*/
install*/
_install*/
.vscode
.vs
out

Expand Down
33 changes: 33 additions & 0 deletions .vscode/cmake-vs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@REM SPDX-FileCopyrightText: 2025 Vector Informatik GmbH
@REM Wrapper used by VS Code tasks and CMake Tools.
@REM It discovers a Visual Studio installation, initializes the MSVC dev environment,
@REM then forwards all arguments to cmake so configure/build use consistent toolchains.
@echo off
setlocal

set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (
echo ERROR: Could not find vswhere at "%VSWHERE%".
exit /b 1
)

set "VSINSTALL="
for /f "usebackq delims=" %%I in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALL=%%I"

if "%VSINSTALL%"=="" (
for /f "usebackq delims=" %%I in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do set "VSINSTALL=%%I"
)

if "%VSINSTALL%"=="" (
echo ERROR: Could not find a Visual Studio installation with C++ tools.
exit /b 1
)

call "%VSINSTALL%\Common7\Tools\VsDevCmd.bat" -no_logo -arch=x64 -host_arch=x64 >nul
if errorlevel 1 (
echo ERROR: Failed to initialize VS developer environment.
exit /b 1
)

cmake %*
exit /b %ERRORLEVEL%
23 changes: 23 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2025 Vector Informatik GmbH
{
// Workspace-local tooling settings for Windows/MSVC development.
// CMake calls are routed through .vscode/cmake-vs.cmd and terminals default
// to a profile that preloads the Visual Studio developer environment.
"cmake.useCMakePresets": "always",
"cmake.cmakePath": "${workspaceFolder}\\.vscode\\cmake-vs.cmd",
"terminal.integrated.profiles.windows": {
"VS Dev PowerShell (x64)": {
"source": "PowerShell",
"args": [
"-NoExit",
"-ExecutionPolicy",
"Bypass",
"-File",
"${workspaceFolder}\\.vscode\\vs-dev-shell.ps1",
"-Arch",
"x64"
]
}
},
"terminal.integrated.defaultProfile.windows": "VS Dev PowerShell (x64)"
}
89 changes: 89 additions & 0 deletions .vscode/vs-dev-shell.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# SPDX-FileCopyrightText: 2025 Vector Informatik GmbH
#
# SPDX-License-Identifier: MIT

# Loads a Visual Studio developer shell into the current PowerShell session.
# Usage examples:
# .\.vscode\vs-dev-shell.ps1
# .\.vscode\vs-dev-shell.ps1 -Arch x64
# .\.vscode\vs-dev-shell.ps1 -Arch x64 cmake --build --preset debug
param(
[ValidateSet("x64", "x86", "arm64")]
[string]$Arch = "x64",

[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Command
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

function Get-VsInstallationPath {
$vswherePath = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
if (-not (Test-Path $vswherePath)) {
throw "Could not find vswhere at '$vswherePath'. Install Visual Studio Installer first."
}

$path = & $vswherePath -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $path) {
$path = & $vswherePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
}
if (-not $path) {
throw "Could not find a Visual Studio installation with C++ tools."
}

return $path.Trim()
}

function Import-VsDevEnvironment {
param(
[Parameter(Mandatory = $true)]
[string]$VsInstallPath,

[Parameter(Mandatory = $true)]
[string]$TargetArch
)

$vsDevCmd = Join-Path $VsInstallPath "Common7\Tools\VsDevCmd.bat"
if (-not (Test-Path $vsDevCmd)) {
throw "Could not find VsDevCmd.bat at '$vsDevCmd'."
}

$envDump = & cmd.exe /s /c "`"$vsDevCmd`" -no_logo -arch=$TargetArch -host_arch=$TargetArch && set"
if ($LASTEXITCODE -ne 0) {
throw "VsDevCmd failed with exit code $LASTEXITCODE."
}

foreach ($line in $envDump) {
if ($line -match "^([^=]+)=(.*)$") {
$name = $matches[1]
$value = $matches[2]
Set-Item -Path "Env:$name" -Value $value
}
}
}

try {
$env:VSCMD_SKIP_SENDTELEMETRY = "1"
$installPath = Get-VsInstallationPath
Import-VsDevEnvironment -VsInstallPath $installPath -TargetArch $Arch

Write-Host "Loaded Visual Studio dev environment:" -ForegroundColor Green
Write-Host " VS Path: $installPath"
Write-Host " Target: $Arch"

if ($null -ne $Command -and $Command.Length -gt 0 -and -not [string]::IsNullOrWhiteSpace($Command[0])) {
$exe = $Command[0]
$args = @()
if ($Command.Length -gt 1) {
$args = $Command[1..($Command.Length - 1)]
}

& $exe @args
exit $LASTEXITCODE
}
}
catch {
Write-Error $_
exit 1
}
2 changes: 1 addition & 1 deletion SilKit/ci/check_licenses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assemble_file_string()
# Yes this is weird that we single out some directories and the include "."
# But the regex filters only work if more than one path is provided
result="$(licensecheck --check='\.c.*$|\.h.*$|\.py|CMakeLists.txt|\.sh' \
--ignore='ThirdParty|.git|.clang-format' \
--ignore='ThirdParty|.git|.clang-format|\.vscode/cmake-vs\.cmd' \
--recursive -- ./SilKit/* ./Demos/* ./Utilities/* .)"

numfiles=$(echo "$result" | wc -l)
Expand Down
Loading