Merge getWindowsSDK into bootstrap.ps1

This commit is contained in:
Alexander Karatarakis 2018-05-19 17:50:51 -07:00
parent 658f1caaab
commit 9e4196d495
3 changed files with 118 additions and 128 deletions

View File

@ -76,11 +76,128 @@ function findAnyMSBuildWithCppPlatformToolset([string]$withVSPath)
throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed." throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed."
} }
function getWindowsSDK( [Parameter(Mandatory=$False)][switch]$DisableWin10SDK = $False,
[Parameter(Mandatory=$False)][switch]$DisableWin81SDK = $False)
{
if ($DisableWin10SDK -and $DisableWin81SDK)
{
throw "Both Win10SDK and Win81SDK were disabled."
}
Write-Verbose "Finding WinSDK"
$validInstances = New-Object System.Collections.ArrayList
# Windows 10 SDK
function CheckWindows10SDK($path)
{
if ($path -eq $null)
{
return
}
$folder = (Join-Path $path "Include")
if (!(Test-Path $folder))
{
Write-Verbose "$folder - Not Found"
return
}
Write-Verbose "$folder - Found"
$win10sdkVersions = @(Get-ChildItem $folder | Where-Object {$_.Name -match "^10"} | Sort-Object)
[array]::Reverse($win10sdkVersions) # Newest SDK first
foreach ($win10sdkV in $win10sdkVersions)
{
$windowsheader = "$folder\$win10sdkV\um\windows.h"
if (!(Test-Path $windowsheader))
{
Write-Verbose "$windowsheader - Not Found"
continue
}
Write-Verbose "$windowsheader - Found"
$ddkheader = "$folder\$win10sdkV\shared\sdkddkver.h"
if (!(Test-Path $ddkheader))
{
Write-Verbose "$ddkheader - Not Found"
continue
}
Write-Verbose "$ddkheader - Found"
$win10sdkVersionString = $win10sdkV.ToString()
Write-Verbose "Found $win10sdkVersionString"
$validInstances.Add($win10sdkVersionString) > $null
}
}
Write-Verbose "`n"
Write-Verbose "Looking for Windows 10 SDK"
$regkey10 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue
$regkey10Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue
if (vcpkgHasProperty -object $regkey10 "KitsRoot10") { CheckWindows10SDK($regkey10.KitsRoot10) }
if (vcpkgHasProperty -object $regkey10Wow6432 "KitsRoot10") { CheckWindows10SDK($regkey10Wow6432.KitsRoot10) }
CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10")
CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10")
# Windows 8.1 SDK
function CheckWindows81SDK($path)
{
if ($path -eq $null)
{
return
}
$folder = "$path\Include"
if (!(Test-Path $folder))
{
Write-Verbose "$folder - Not Found"
return
}
Write-Verbose "$folder - Found"
$win81sdkVersionString = "8.1"
Write-Verbose "Found $win81sdkVersionString"
$validInstances.Add($win81sdkVersionString) > $null
}
Write-Verbose "`n"
Write-Verbose "Looking for Windows 8.1 SDK"
$regkey81 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue
$regkey81Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue
if (vcpkgHasProperty -object $regkey81 "KitsRoot81") { CheckWindows81SDK($regkey81.KitsRoot81) }
if (vcpkgHasProperty -object $regkey81Wow6432 "KitsRoot81") { CheckWindows81SDK($regkey81Wow6432.KitsRoot81) }
CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1")
CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1")
Write-Verbose "`n`n`n"
Write-Verbose "The following Windows SDKs were found:"
foreach ($instance in $validInstances)
{
Write-Verbose $instance
}
# Selecting
foreach ($instance in $validInstances)
{
if (!$DisableWin10SDK -and $instance -match "10.")
{
return $instance
}
if (!$DisableWin81SDK -and $instance -match "8.1")
{
return $instance
}
}
throw "Could not detect a Windows SDK / TargetPlatformVersion"
}
$msbuildExeWithPlatformToolset = findAnyMSBuildWithCppPlatformToolset $withVSPath $msbuildExeWithPlatformToolset = findAnyMSBuildWithCppPlatformToolset $withVSPath
$msbuildExe = $msbuildExeWithPlatformToolset[0] $msbuildExe = $msbuildExeWithPlatformToolset[0]
$platformToolset = $msbuildExeWithPlatformToolset[1] $platformToolset = $msbuildExeWithPlatformToolset[1]
$windowsSDK = & $scriptsDir\getWindowsSDK.ps1 $windowsSDK = getWindowsSDK
$arguments = ( $arguments = (
"`"/p:VCPKG_VERSION=-$gitHash`"", "`"/p:VCPKG_VERSION=-$gitHash`"",

View File

@ -1,126 +0,0 @@
[CmdletBinding()]
param(
[Parameter(Mandatory=$False)]
[switch]$DisableWin10SDK = $False,
[Parameter(Mandatory=$False)]
[switch]$DisableWin81SDK = $False
)
Set-StrictMode -Version Latest
$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
. "$scriptsDir\VcpkgPowershellUtils.ps1"
if ($DisableWin10SDK -and $DisableWin81SDK)
{
throw "Both Win10SDK and Win81SDK were disabled."
}
Write-Verbose "Executing $($MyInvocation.MyCommand.Name)"
$validInstances = New-Object System.Collections.ArrayList
# Windows 10 SDK
function CheckWindows10SDK($path)
{
if ($path -eq $null)
{
return
}
$folder = (Join-Path $path "Include")
if (!(Test-Path $folder))
{
Write-Verbose "$folder - Not Found"
return
}
Write-Verbose "$folder - Found"
$win10sdkVersions = @(Get-ChildItem $folder | Where-Object {$_.Name -match "^10"} | Sort-Object)
[array]::Reverse($win10sdkVersions) # Newest SDK first
foreach ($win10sdkV in $win10sdkVersions)
{
$windowsheader = "$folder\$win10sdkV\um\windows.h"
if (!(Test-Path $windowsheader))
{
Write-Verbose "$windowsheader - Not Found"
continue
}
Write-Verbose "$windowsheader - Found"
$ddkheader = "$folder\$win10sdkV\shared\sdkddkver.h"
if (!(Test-Path $ddkheader))
{
Write-Verbose "$ddkheader - Not Found"
continue
}
Write-Verbose "$ddkheader - Found"
$win10sdkVersionString = $win10sdkV.ToString()
Write-Verbose "Found $win10sdkVersionString"
$validInstances.Add($win10sdkVersionString) > $null
}
}
Write-Verbose "`n"
Write-Verbose "Looking for Windows 10 SDK"
$regkey10 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue
$regkey10Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue
if (vcpkgHasProperty -object $regkey10 "KitsRoot10") { CheckWindows10SDK($regkey10.KitsRoot10) }
if (vcpkgHasProperty -object $regkey10Wow6432 "KitsRoot10") { CheckWindows10SDK($regkey10Wow6432.KitsRoot10) }
CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10")
CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10")
# Windows 8.1 SDK
function CheckWindows81SDK($path)
{
if ($path -eq $null)
{
return
}
$folder = "$path\Include"
if (!(Test-Path $folder))
{
Write-Verbose "$folder - Not Found"
return
}
Write-Verbose "$folder - Found"
$win81sdkVersionString = "8.1"
Write-Verbose "Found $win81sdkVersionString"
$validInstances.Add($win81sdkVersionString) > $null
}
Write-Verbose "`n"
Write-Verbose "Looking for Windows 8.1 SDK"
$regkey81 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue
$regkey81Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue
if (vcpkgHasProperty -object $regkey81 "KitsRoot81") { CheckWindows81SDK($regkey81.KitsRoot81) }
if (vcpkgHasProperty -object $regkey81Wow6432 "KitsRoot81") { CheckWindows81SDK($regkey81Wow6432.KitsRoot81) }
CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1")
CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1")
Write-Verbose "`n`n`n"
Write-Verbose "The following Windows SDKs were found:"
foreach ($instance in $validInstances)
{
Write-Verbose $instance
}
# Selecting
foreach ($instance in $validInstances)
{
if (!$DisableWin10SDK -and $instance -match "10.")
{
return $instance
}
if (!$DisableWin81SDK -and $instance -match "8.1")
{
return $instance
}
}
throw "Could not detect a Windows SDK / TargetPlatformVersion"

View File

@ -17,7 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{F589
..\scripts\fetchDependency.ps1 = ..\scripts\fetchDependency.ps1 ..\scripts\fetchDependency.ps1 = ..\scripts\fetchDependency.ps1
..\scripts\getVisualStudioInstances.ps1 = ..\scripts\getVisualStudioInstances.ps1 ..\scripts\getVisualStudioInstances.ps1 = ..\scripts\getVisualStudioInstances.ps1
..\scripts\get_triplet_environment.cmake = ..\scripts\get_triplet_environment.cmake ..\scripts\get_triplet_environment.cmake = ..\scripts\get_triplet_environment.cmake
..\scripts\getWindowsSDK.ps1 = ..\scripts\getWindowsSDK.ps1
..\scripts\internalCI.ps1 = ..\scripts\internalCI.ps1 ..\scripts\internalCI.ps1 = ..\scripts\internalCI.ps1
..\scripts\ports.cmake = ..\scripts\ports.cmake ..\scripts\ports.cmake = ..\scripts\ports.cmake
..\scripts\SHA256Hash.ps1 = ..\scripts\SHA256Hash.ps1 ..\scripts\SHA256Hash.ps1 = ..\scripts\SHA256Hash.ps1