diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 326474b2..0ad1e3f4 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -30,7 +30,8 @@ "image_os": "win16", "github_feed_token": "{{env `GITHUB_FEED_TOKEN`}}", "go_versions": "1.9, 1.10, 1.11, 1.12, 1.13, 1.14", - "go_default": "1.14" + "go_default": "1.14", + "boost_default": "1.69.0" }, "sensitive-variables": ["install_password", "ssh_password", "client_secret", "github_feed_token"], "builders": [ @@ -516,8 +517,8 @@ { "type": "powershell", "environment_vars": [ - "BOOST_VERSIONS=1.69.0,1.72.0", - "BOOST_DEFAULT=1.69.0" + "ROOT_FOLDER={{user `root_folder`}}", + "BOOST_DEFAULT={{user `boost_default`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" @@ -651,8 +652,8 @@ { "type": "powershell", "environment_vars": [ - "BOOST_VERSIONS=1.69.0,1.72.0", - "BOOST_DEFAULT=1.69.0" + "ROOT_FOLDER={{user `root_folder`}}", + "BOOST_DEFAULT={{user `boost_default`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Boost.ps1" diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 94da1a0e..2023be50 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -30,7 +30,8 @@ "image_os": "win19", "github_feed_token": "{{env `GITHUB_FEED_TOKEN`}}", "go_versions": "1.9, 1.10, 1.11, 1.12, 1.13, 1.14", - "go_default": "1.14" + "go_default": "1.14", + "boost_default": "1.72.0" }, "sensitive-variables": ["install_password", "ssh_password", "client_secret", "github_feed_token"], "builders": [ @@ -497,8 +498,8 @@ { "type": "powershell", "environment_vars": [ - "BOOST_VERSIONS=1.69.0,1.72.0", - "BOOST_DEFAULT=1.72.0" + "ROOT_FOLDER={{user `root_folder`}}", + "BOOST_DEFAULT={{user `boost_default`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" @@ -638,8 +639,8 @@ { "type": "powershell", "environment_vars": [ - "BOOST_VERSIONS=1.69.0,1.72.0", - "BOOST_DEFAULT=1.72.0" + "ROOT_FOLDER={{user `root_folder`}}", + "BOOST_DEFAULT={{user `boost_default`}}" ], "scripts":[ "{{ template_dir }}/scripts/Installers/Validate-Boost.ps1" diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index 7f48125f..743dc7a1 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -14,6 +14,8 @@ Export-ModuleMember -Function @( 'Set-SystemVariable' 'Install-MSI' 'Install-EXE' + 'Get-ToolcachePackages' + 'Get-ToolsByName' 'Add-ContentToMarkdown' 'Add-SoftwareDetailsToMarkdown' 'Stop-SvcWithErrHandling' diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index a0bbe994..61dce562 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -275,6 +275,28 @@ function Get-VSExtensionVersion return $packageVersion } + +function Get-ToolcachePackages { + $toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json" + Get-Content -Raw $toolcachePath | ConvertFrom-Json +} + +function Get-ToolsByName { + param ( + [Parameter(Mandatory = $True)] + [string]$SoftwareName + ) + + (Get-ToolcachePackages).PSObject.Properties | Where-Object { $_.Name -match $SoftwareName } | ForEach-Object { + $packageNameParts = $_.Name.Split("-") + [PSCustomObject] @{ + ToolName = $packageNameParts[1] + Versions = $_.Value + Architecture = $packageNameParts[3,4] -join "-" + } + } +} + function Get-WinVersion { (Get-WmiObject -class Win32_OperatingSystem).Caption @@ -289,3 +311,4 @@ function Test-IsWin16 { (Get-WinVersion) -match "2016" } + diff --git a/images/win/scripts/Installers/Install-Boost.ps1 b/images/win/scripts/Installers/Install-Boost.ps1 index 907f82d9..0931fb25 100644 --- a/images/win/scripts/Installers/Install-Boost.ps1 +++ b/images/win/scripts/Installers/Install-Boost.ps1 @@ -4,8 +4,11 @@ ## Desc: Install boost using tool cache ################################################################################ -$BoostDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Boost" -$BoostVersions = $env:BOOST_VERSIONS.split(',') +Import-Module -Name ImageHelpers + +$SoftwareName = "Boost" +$BoostDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $SoftwareName +$BoostVersions = (Get-ToolsByName -SoftwareName $SoftwareName).Versions | Foreach-Object {"{0}.0" -f $_} $BoostDefault = $env:BOOST_DEFAULT foreach($BoostVersion in $BoostVersions) @@ -20,7 +23,5 @@ foreach($BoostVersion in $BoostVersions) Write-Host "Adding Boost $BoostVersion to the path..." # Add the Boost binaries to the path Add-MachinePathItem $BoostInstallationDir | Out-Null - # Set the BOOSTROOT environment variable - setx BOOST_ROOT $BoostInstallationDir /M | Out-Null } } diff --git a/images/win/scripts/Installers/Validate-Boost.ps1 b/images/win/scripts/Installers/Validate-Boost.ps1 index 9c97c28d..6289e165 100644 --- a/images/win/scripts/Installers/Validate-Boost.ps1 +++ b/images/win/scripts/Installers/Validate-Boost.ps1 @@ -3,6 +3,8 @@ ## Desc: Validate Boost ################################################################################ +Import-Module -Name ImageHelpers + function Validate-BoostVersion { Param @@ -37,7 +39,7 @@ else # Adding description of the software to Markdown $tmplMark = @" -#### {0} +#### {0} [{2}] _Environment:_ * {1}: root directory of the Boost version {0} installation @@ -45,31 +47,51 @@ _Environment:_ "@ $tmplMarkRoot = @" -#### {0} +#### {0} [{2}] +_Environment:_ * PATH: contains the location of Boost version {0} -* BOOST_ROOT: root directory of the Boost version {0} installation * {1}: root directory of the Boost version {0} installation "@ -$SoftwareName = 'Boost' $Description = New-Object System.Text.StringBuilder -$BoostRootDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Boost" -$BoostVersionsToInstall = $env:BOOST_VERSIONS.split(",") +$SoftwareName = 'Boost' +$BoostRootDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $SoftwareName +$BoostTools = Get-ToolsByName -SoftwareName $SoftwareName -foreach($BoostVersion in $BoostVersionsToInstall) +foreach ($BoostTool in $BoostTools) { - Validate-BoostVersion -BoostRootPath $BoostRootDirectory -BoostRelease $BoostVersion - $BoostVersionTag = "BOOST_ROOT_{0}" -f $BoostVersion.Replace('.', '_') + $BoostToolsetName = $BoostTool.Architecture + $BoostVersionsToInstall = $BoostTool.Versions | Foreach-Object {"{0}.0" -f $_} + foreach($BoostVersion in $BoostVersionsToInstall) + { + Validate-BoostVersion -BoostRootPath $BoostRootDirectory -BoostRelease $BoostVersion + $BoostVersionTag = "BOOST_ROOT_{0}" -f $BoostVersion.Replace('.', '_') - if($BoostVersion -eq $env:BOOST_DEFAULT) - { - $null = $Description.AppendLine(($tmplMarkRoot -f $BoostVersion, $BoostVersionTag)) - } - else - { - $null = $Description.AppendLine(($tmplMark -f $BoostVersion, $BoostVersionTag)) + if($BoostVersion -eq $env:BOOST_DEFAULT) + { + $null = $Description.AppendLine(($tmplMarkRoot -f $BoostVersion, $BoostVersionTag, $BoostToolsetName)) + } + else + { + $null = $Description.AppendLine(($tmplMark -f $BoostVersion, $BoostVersionTag, $BoostToolsetName)) + } } } +$CMakeFindBoostInfo = @" + +#### _Notes:_ +Link: https://cmake.org/cmake/help/latest/module/FindBoost.html + +If Boost was built using the ``boost-cmake`` project or from ``Boost 1.70.0`` on it provides a package +configuration file for use with find\_package's config mode. This module looks for the package +configuration file called BoostConfig.cmake or boost-config.cmake and stores the result in CACHE entry "Boost_DIR". +If found, the package configuration file is loaded and this module returns with no further action. +See documentation of the Boost CMake package configuration for details on what it provides. + +Set ``Boost_NO_BOOST_CMAKE to ON``, to disable the search for boost-cmake. +"@ + +$null = $Description.AppendLine($CMakeFindBoostInfo) Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description.ToString()