diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-02-24 16:58:22 -0800 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-02-24 16:58:22 -0800 |
| commit | 5eae6e392a83f2f93d5d694897180ccd39f70080 (patch) | |
| tree | 189a6c13176f343a9ebbdbddf5c93d2c1559c88f | |
| parent | df4d385d3d88c3b4fdd46d9e9f580b5d902accbd (diff) | |
| parent | 58002f62392f15a42a8b30352aa007bbd82e74a9 (diff) | |
| download | vcpkg-5eae6e392a83f2f93d5d694897180ccd39f70080.tar.gz vcpkg-5eae6e392a83f2f93d5d694897180ccd39f70080.zip | |
Merge branch 'master' of https://github.com/microsoft/vcpkg
| -rw-r--r-- | scripts/findAnyMSBuildWithCppPlatformToolset.ps1 | 179 | ||||
| -rw-r--r-- | scripts/getWindowsSDK.ps1 | 62 |
2 files changed, 195 insertions, 46 deletions
diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 index 72155b4f5..f1ef1ae6b 100644 --- a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 +++ b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 @@ -7,63 +7,158 @@ param( [switch]$DisableVS2015 = $False ) +if ($DisableVS2017 -and $DisableVS2015) +{ + throw "Both VS2015 and VS2017 were disabled." +} + +function New-MSBuildInstance() +{ + param ($msbuildExePath, $toolsetVersion) + + $instance = new-object PSObject + $instance | add-member -type NoteProperty -Name msbuildExePath -Value $msbuildExePath + $instance | add-member -type NoteProperty -Name toolsetVersion -Value $toolsetVersion + + return $instance +} + +Write-Verbose "Executing $($MyInvocation.MyCommand.Name) with DisableVS2017=$DisableVS2017, DisableVS2015=$DisableVS2015" $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition -if (-not $DisableVS2017) +$validInstances = New-Object System.Collections.ArrayList + +# VS2017 +Write-Verbose "`n`n" +Write-Verbose "Checking for MSBuild from VS2017 instances..." +$VisualStudio2017InstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1 +Write-Verbose "VS2017 Candidates: $([system.String]::Join(',', $VisualStudio2017InstallationInstances))" +foreach ($instanceCandidate in $VisualStudio2017InstallationInstances) { - # VS2017 - $VisualStudio2017InstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1 - foreach ($instance in $VisualStudio2017InstallationInstances) + $VCFolder= "$instanceCandidate\VC\Tools\MSVC\" + + if (Test-Path $VCFolder) { - $VCFolder= "$instance\VC\Tools\MSVC\" + $instance = New-MSBuildInstance "$instanceCandidate\MSBuild\15.0\Bin\MSBuild.exe" "v141" + Write-Verbose "Found $instance" + $validInstances.Add($instance) > $null + } +} + +# VS2015 - in Program Files +Write-Verbose "`n`n" +Write-Verbose "Checking for MSBuild from VS2015 in Program Files..." +$CandidateProgramFiles = $(& $scriptsDir\getProgramFiles32bit.ps1), $(& $scriptsDir\getProgramFilesPlatformBitness.ps1) +Write-Verbose "Program Files Candidate locations: $([system.String]::Join(',', $CandidateProgramFiles))" +foreach ($ProgramFiles in $CandidateProgramFiles) +{ + $clExe= "$ProgramFiles\Microsoft Visual Studio 14.0\VC\bin\cl.exe" - if (Test-Path $VCFolder) - { - return "$instance\MSBuild\15.0\Bin\MSBuild.exe","v141" - } + if (!(Test-Path $clExe)) + { + Write-Verbose "$clExe - Not Found" + continue } + + Write-Verbose "$clExe - Found" + $instance = New-MSBuildInstance "$ProgramFiles\MSBuild\14.0\Bin\MSBuild.exe" "v140" + Write-Verbose "Found $instance" + $validInstances.Add($instance) > $null } -if (-not $DisableVS2015) +# VS2015 - through the registry +function NewCppRegistryPair() { - # Try to locate VS2015 through the Registry + param ($visualStudioEntry, $msBuildEntry) + + $instance = new-object PSObject + $instance | add-member -type NoteProperty -Name visualStudioEntry -Value $visualStudioEntry + $instance | add-member -type NoteProperty -Name msBuildEntry -Value $msBuildEntry + + return $instance +} + +Write-Verbose "`n`n" +Write-Verbose "Checking for MSBuild from VS2015 through the registry..." + +$registryPairs = +$(NewCppRegistryPair "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\visualstudio\14.0" "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\msbuild\toolsversions\14.0"), +$(NewCppRegistryPair "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\visualstudio\14.0" "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\msbuild\toolsversions\14.0") + +foreach ($pair in $registryPairs) +{ + $vsEntry = $pair.visualStudioEntry try { - # First ensure the compiler was installed (optional in 2015) - # In 64-bit systems, this is under the Wow6432Node. - try - { - $VS14InstallDir = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\visualstudio\14.0 InstallDir -erroraction Stop | % { $_.InstallDir }) - Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\visualstudio\14.0 - Found" - } - catch - { - $VS14InstallDir = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\visualstudio\14.0 InstallDir -erroraction Stop | % { $_.InstallDir }) - Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\visualstudio\14.0 - Found" - } - if (!(Test-Path "${VS14InstallDir}..\..\VC\bin\cl.exe")) { throw } - Write-Verbose "${VS14InstallDir}..\..\VC\bin\cl.exe - Found" - - - try - { - $MSBuild14 = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\msbuild\toolsversions\14.0 MSBuildToolsPath -erroraction Stop | % { $_.MSBuildToolsPath }) - Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\msbuild\toolsversions\14.0 - Found" - } - catch - { - $MSBuild14 = $(gp Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\msbuild\toolsversions\14.0 MSBuildToolsPath -erroraction Stop | % { $_.MSBuildToolsPath }) - Write-Verbose "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\msbuild\toolsversions\14.0 - Found" - } - if (!(Test-Path "${MSBuild14}MSBuild.exe")) { throw } - Write-Verbose "${MSBuild14}MSBuild.exe - Found" - - return "${MSBuild14}MSBuild.exe","v140" + $VS14InstallDir = $(gp $vsEntry InstallDir -erroraction Stop | % { $_.InstallDir }) + Write-Verbose "$vsEntry - Found" } catch { - Write-Verbose "Unable to locate a VS2015 installation with C++ support" + Write-Verbose "$vsEntry - Not Found" + continue } + + Write-Verbose "$VS14InstallDir - Obtained from registry" + # We want "${VS14InstallDir}..\..\VC\bin\cl.exe" + # Doing Split-path to avoid the ..\.. from appearing in the output + $clExePath = Split-path $VS14InstallDir -Parent + $clExePath = Split-path $clExePath -Parent + $clExePath = "$clExePath\VC\bin\cl.exe" + + if (!(Test-Path $clExePath)) + { + Write-Verbose "$clExePath - Not Found" + continue + } + + Write-Verbose "$clExePath - Found" + + $msbuildEntry = $pair.msBuildEntry + try + { + $MSBuild14 = $(gp $msbuildEntry MSBuildToolsPath -erroraction Stop | % { $_.MSBuildToolsPath }) + Write-Verbose "$msbuildEntry - Found" + } + catch + { + Write-Verbose "$msbuildEntry - Not Found" + continue + } + + Write-Verbose "${MSBuild14} - Obtained from registry" + $msbuildPath = "${MSBuild14}MSBuild.exe" + if (!(Test-Path $msbuildPath)) + { + Write-Verbose "$msbuildPath - Not Found" + continue + } + + $instance = New-MSBuildInstance $msbuildPath "v140" + Write-Verbose "Found $instance" + $validInstances.Add($instance) > $null } +Write-Verbose "`n`n`n" +Write-Verbose "The following MSBuild instances were found:" +foreach ($instance in $validInstances) +{ + Write-Verbose $instance +} + +# Selecting +foreach ($instance in $validInstances) +{ + if (!$DisableVS2017 -and $instance.toolsetVersion -eq "v141") + { + return $instance.msbuildExePath, $instance.toolsetVersion + } + + if (!$DisableVS2015 -and $instance.toolsetVersion -eq "v140") + { + return $instance.msbuildExePath, $instance.toolsetVersion + } +} + + throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed."
\ No newline at end of file diff --git a/scripts/getWindowsSDK.ps1 b/scripts/getWindowsSDK.ps1 index 7aeb532b5..90ca1b06b 100644 --- a/scripts/getWindowsSDK.ps1 +++ b/scripts/getWindowsSDK.ps1 @@ -1,39 +1,93 @@ [CmdletBinding()] param( + [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 "Executing $($MyInvocation.MyCommand.Name)" $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition + +$validInstances = New-Object System.Collections.ArrayList + $CandidateProgramFiles = $(& $scriptsDir\getProgramFiles32bit.ps1), $(& $scriptsDir\getProgramFilesPlatformBitness.ps1) +Write-Verbose "Program Files Candidate locations: $([system.String]::Join(',', $CandidateProgramFiles))" # Windows 10 SDK +Write-Verbose "`n" +Write-Verbose "Looking for Windows 10 SDK" foreach ($ProgramFiles in $CandidateProgramFiles) { $folder = "$ProgramFiles\Windows Kits\10\Include" if (!(Test-Path $folder)) { + Write-Verbose "$folder - Not Found" continue } + 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) { - if (Test-Path "$folder\$win10sdkV\um\windows.h") + $windowsheader = "$folder\$win10sdkV\um\windows.h" + if (!(Test-Path $windowsheader)) { - return $win10sdkV.ToString() + Write-Verbose "$windowsheader - Not Found" + continue } + + Write-Verbose "$windowsheader - Found" + $win10sdkVersionString = $win10sdkV.ToString() + Write-Verbose "Found $win10sdkVersionString" + $validInstances.Add($win10sdkVersionString) > $null } } # Windows 8.1 SDK +Write-Verbose "`n" +Write-Verbose "Looking for Windows 8.1 SDK" foreach ($ProgramFiles in $CandidateProgramFiles) { $folder = "$ProgramFiles\Windows Kits\8.1\Include" - if (Test-Path $folder) + if (!(Test-Path $folder)) + { + Write-Verbose "$folder - Not Found" + continue + } + + Write-Verbose "$folder - Found" + $win81sdkVersionString = "8.1" + Write-Verbose "Found $win81sdkVersionString" + $validInstances.Add($win81sdkVersionString) > $null +} + +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 "8.1" + return $instance } } |
