Commit 5f274519 authored by Volker Hilsheimer's avatar Volker Hilsheimer
Browse files

Implement role dependencies and aliases

Any machine installing a Windows compiler needs the tools, so might just
as well add windows-tools as an implicit role.

And for backwards compatibility, msvc2017/2019 can just be aliases to
msvc with a version.
parent 3d62fc8b
......@@ -204,6 +204,27 @@ def add_role(box, role, name, machine)
end
activity = false
# load attributes for the role, and add all required roles
if File.file?("#{role_path}/attributes.yml")
ex_attributes = YAML.load_file("#{role_path}/attributes.yml")
if ex_attributes["requires"]
ex_attributes["requires"].each do |required_role|
matching_roles = machine["roles"].select do |existing|
existing == required_role || existing["role"] == required_role ||
(existing.is_a?(Hash) && existing.key?(required_role))
end
add_role(box, required_role, name, machine) if matching_roles.empty?
end
end
if ex_attributes["alias"]
add_role(box, ex_attributes["alias"], name, machine)
activity = true
end
else
ex_attributes = {}
end
# check for pre--provisioning script to run locally
if File.file?("#{role_path}/pre-provision.sh")
pre_provision = lambda do |machine|
......@@ -213,11 +234,6 @@ def add_role(box, role, name, machine)
type: :local_command,
code: pre_provision
end
begin
ex_attributes = YAML.load_file("#{role_path}/attributes.yml")
rescue
ex_attributes = {}
end
if File.file?("#{role_path}/playbook.yml")
if Which.which("ansible")
......
requires:
- windows-tools
......@@ -3,11 +3,18 @@ param (
)
$variables = @{
"2017" = @{
Packages=("visualstudio2017buildtools", "visualstudio2017-workload-vctools")
ChannelId="VisualStudio.15.Release"
InstallDir="C:\Program Files (x86)\Microsoft Visual Studio\2017"
}
"2019" = @{
Packages=("visualstudio2019-workload-vctools")
ChannelId="VisualStudio.16.Release"
InstallDir="C:\Program Files (x86)\Microsoft Visual Studio\2019"
}
"2022" = @{
Packages=("visualstudio2022-workload-vctools")
ChannelId="VisualStudio.17.Release"
InstallDir="C:\Program Files (x86)\Microsoft Visual Studio\2022"
}
......@@ -21,12 +28,10 @@ if (!$variables.ContainsKey("$Version")) {
$channelId=$variables[$Version].ChannelId
$installDir=$variables[$Version].InstallDir
$packages = $variables[$Version].Packages
. "c:\opt\minicoin\util\install_helper.ps1"
$packages = (
"visualstudio${Version}-workload-vctools"
)
& cmd /c "winrm set winrm/config/winrs @{MaxMemoryPerShellMB=`"2147483647`"}"
......@@ -41,11 +46,12 @@ $vc_workloads = (
)
ForEach ( $p in $vc_workloads ) {
Install-Software -package $p -command "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -arguments @(
"modify", "--norestart", "--quiet",
"--productId", "Microsoft.VisualStudio.Product.BuildTools",
"--channelId", "$channelId", "--add"
)
Install-Software -package $p -command "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" `
-arguments @(
"modify", "--norestart", "--quiet",
"--productId", "Microsoft.VisualStudio.Product.BuildTools",
"--channelId", "$channelId", "--add"
)
}
chocolatey feature disable -n=allowGlobalConfirmation
......
alias:
role: msvc
version: 2017
. "c:\opt\minicoin\util\install_helper.ps1"
$packages = ( "visualstudio2017buildtools",
"visualstudio2017-workload-vctools")
cd "$($env:SystemDrive)\ProgramData\Chocolatey\bin"
.\chocolatey feature enable -n=allowGlobalConfirmation
ForEach ( $p in $packages ) { .\choco install --no-progress -y $p }
.\chocolatey feature disable -n=allowGlobalConfirmation
write-host "Updating PATH"
refreshenv
Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("INCLUDE", $env:INCLUDE, [System.EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("LIB", $env:LIB, [System.EnvironmentVariableTarget]::User)
shell:
# unfortunately, vagrant's reboot logic for Windows fails
# reboot: true
alias:
role: msvc
version: 2019
. "c:\opt\minicoin\util\install_helper.ps1"
$packages = (
"visualstudio2019-workload-vctools"
)
& cmd /c "winrm set winrm/config/winrs @{MaxMemoryPerShellMB=`"2147483647`"}"
chocolatey feature enable -n=allowGlobalConfirmation
ForEach ( $p in $packages ) {
$measurement = Measure-Command {
Run-KeepAlive -ScriptBlock {
param($package)
write-host "Installing $package"
& chocolatey install --no-progress --limitoutput -y $package | Out-Default
write-host "Done Installing $package"
} -Arguments $p -HeartBeat 30
}
$duration = ""
if ($measurement.TotalMinutes -lt 1) {
$duration = "$($measurement.TotalSeconds) Seconds"
} else {
$duration = $measurement.ToString("hh\:mm\:ss")
}
Write-Host "Installation of $p completed after $duration"
}
$vc_workloads = (
"Microsoft.VisualStudio.Component.VC.ATL",
"Microsoft.VisualStudio.Component.VC.ATLMFC"
)
ForEach ( $p in $vc_workloads ) {
$measurement = Measure-Command {
Run-KeepAlive -ScriptBlock {
param($package)
write-host "Installing Visual Studio component $package"
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify --norestart --quiet --productId Microsoft.VisualStudio.Product.BuildTools --channelId VisualStudio.16.Release --add $package | Out-Default
write-host "Done Installing $package"
} -Arguments $p -HeartBeat 30
}
$duration = ""
if ($measurement.TotalMinutes -lt 1) {
$duration = "$($measurement.TotalSeconds) Seconds"
} else {
$duration = $measurement.ToString("hh\:mm\:ss")
}
Write-Host "Installation of $p completed after $duration"
}
chocolatey feature disable -n=allowGlobalConfirmation
refreshenv
Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
[Environment]::SetEnvironmentVariable("PATH", $env:Path, 'user')
[Environment]::SetEnvironmentVariable("INCLUDE", $env:INCLUDE, 'user')
[Environment]::SetEnvironmentVariable("LIB", $env:LIB, 'user')
[Environment]::SetEnvironmentVariable("VSINSTALLDIR", "C:\Program Files (x86)\Microsoft Visual Studio\2019", 'user')
refreshenv
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment