Skip to content

Commit

Permalink
ci-staging: install visual studio components
Browse files Browse the repository at this point in the history
  • Loading branch information
VDanielEdwards committed Jul 18, 2024
1 parent b3c378f commit 91d88f7
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
param(
[ValidateSet("14.1", "14.3")]
[string[]] $InstallToolset = @()
)

function Write-ScriptLog {
param(
[Parameter(Mandatory)]
[ValidateSet("Visual Studio", "Toolset", "Component", "Execute")]
[string] $Category,

[Parameter(Mandatory)]
[string[]] $Message,

[ValidateSet("Error", "Notice")]
[string] $Level = "Notice"
)

if ($Level -eq "Notice") {
Write-Host "[$Category] $Message"
} else {
Write-Host "[$Category] [$Level] $Message"
}
}

$Vswhere = Get-Command vswhere
Write-ScriptLog "Visual Studio" "Path (vswhere): $($Vswhere.Path)"

$InstallationPath = & $Vswhere.Path -products * -latest -property installationPath
Write-ScriptLog "Visual Studio" "Installation Path (Visual Studio): $InstallationPath"

$VisualStudioVersion = "Unknown"

if ($InstallationPath -like "*\2019\*") {
$VisualStudioVersion = "2019"
} elseif ($InstallationPath -like "*\2022\*") {
$VisualStudioVersion = "2022"
} else {
Write-ScriptLog "Visual Studio" "Failed to detect Visual Studio version" -Level Error
exit 1
}

$InstallToolset = $InstallToolset | Sort-Object | Get-Unique

Write-ScriptLog "Visual Studio" "Version: $VisualStudioVersion"
Write-ScriptLog "Toolset" "Install: $($InstallToolset -join ", ")"

$ToolsetToComponents = @{
"2019 14.1" = @(
"Microsoft.VisualStudio.Component.VC.v141.x86.x64"
);
"2019 14.2" = @(
"Microsoft.VisualStudio.Component.VC.14.29.16.10.x86.x64"
);
"2022 14.1" = @(
"Microsoft.VisualStudio.Component.VC.v141.x86.x64"
);
"2022 14.2" = @(
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64"
);
"2022 14.3" = @(
"Microsoft.VisualStudio.Component.VC.14.39.17.9.x86.x64"
);
}

$ComponentsToInstall = @()

foreach ($Toolset in $InstallToolset) {
$Key = "$VisualStudioVersion $Toolset"
Write-ScriptLog "Component" "Selecting components for '$Key'"

$Components = $ToolsetToComponents[$Key]

if ($Components -eq $null) {
Write-ScriptLog "Component" "No components available for Visual Studio $VisualStudioVersion and Toolset $Toolset" -Level Error
exit 2
}

$ComponentsToInstall += $Components
}

Write-ScriptLog "Component" "Selected components for installation: $($ComponentsToInstall -join ", ")"

try {
Push-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"

$AddComponentArguments = $ComponentsToInstall | ForEach-Object { "--add `"" + $_ + "`"" }
$Arguments = @(
"/c", "vs_installer.exe",
"modify",
"--installPath", "`"$InstallationPath`"",
($AddComponentArguments -join " "),
'--quiet', '--norestart', '--nocache'
)

Write-ScriptLog "Execute" "cmd.exe $Arguments"

$InstallerProcess = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
} finally {
Pop-Location
}
8 changes: 6 additions & 2 deletions .github/actions/sil-kit-ci/impl-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ inputs:
required: true

c-compiler:
description: C compiler used under Linux
description: C compiler
required: true

cxx-compiler:
description: C++ compiler used under Linux
description: C++ compiler
required: true

msvc-arch:
Expand Down Expand Up @@ -83,6 +83,10 @@ runs:
# pull docker image for building via cmake
docker pull "${{ inputs.linux-docker-image }}"
- if: runner.os == 'Windows'
shell: powershell
run: ./Install-RequiredVisualStudioComponents -Toolset ${{ msvc-toolset }}

- name: (windows) setup msvc environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1.13.0
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CI for Pull Requests"

on:

pull_request:
branches: [ 'main' ]

concurrency:

group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

linux-fast:
name: 'Linux (PR)'
uses: ./.github/workflows/call-build.yml
with:
runs-on: ubuntu-22.04
preset-name: ci
c-compiler: gcc-8
cxx-compiler: g++-8
cmake-configure-args: >-
-D CMAKE_C_FLAGS_RELEASE="-g0 -O0"
-D CMAKE_CXX_FLAGS_RELEASE="-g0 -O0"
windows-x64-fast:
name: 'Windows (PR, x64)'
uses: ./.github/workflows/call-build.yml
with:
runs-on: windows-2019
preset-name: ci
msvc-arch: x64
msvc-toolset: 14.1
cmake-configure-args: >-
-D CMAKE_C_FLAGS_RELEASE="/Od"
-D CMAKE_CXX_FLAGS_RELEASE="/Od"

0 comments on commit 91d88f7

Please sign in to comment.