Skip to content

Commit 568d1f5

Browse files
committed
Add support for building with VS2017(Toolset v141)
Manually cherry picked from 12dede8 with the following changes - Use the simpler usage as outlined in https://blogs.msdn.microsoft.com/heaths/2017/03/11/vswhere-now-searches-older-versions-of-visual-studio/ - Download VSWhere as required
1 parent a4a8434 commit 568d1f5

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

build.ps1

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#requires -Version 3
22

33
param(
4-
[ValidateSet("vs2012", "vs2013", "vs2015", "nupkg", "nupkg-only")]
4+
[ValidateSet("vs2012", "vs2013", "vs2015", "vs2017", "nupkg", "nupkg-only")]
55
[Parameter(Position = 0)]
66
[string] $Target = "nupkg",
77

@@ -146,25 +146,29 @@ function Bootstrap
146146
md 'cef\win32\debug\VS2012' | Out-Null
147147
md 'cef\win32\debug\VS2013' | Out-Null
148148
md 'cef\win32\debug\VS2015' | Out-Null
149+
md 'cef\win32\debug\VS2017' | Out-Null
149150
md 'cef\win32\release' | Out-Null
150151
md 'cef\win32\release\VS2012' | Out-Null
151152
md 'cef\win32\release\VS2013' | Out-Null
152153
md 'cef\win32\release\VS2015' | Out-Null
154+
md 'cef\win32\release\VS2017' | Out-Null
153155
md 'cef\x64' | Out-Null
154156
md 'cef\x64\debug' | Out-Null
155157
md 'cef\x64\debug\VS2012' | Out-Null
156158
md 'cef\x64\debug\VS2013' | Out-Null
157159
md 'cef\x64\debug\VS2015' | Out-Null
160+
md 'cef\x64\debug\VS2017' | Out-Null
158161
md 'cef\x64\release' | Out-Null
159162
md 'cef\x64\release\VS2012' | Out-Null
160163
md 'cef\x64\release\VS2013' | Out-Null
161164
md 'cef\x64\release\VS2015' | Out-Null
165+
md 'cef\x64\release\VS2017' | Out-Null
162166
}
163167

164168
function Msvs
165169
{
166170
param(
167-
[ValidateSet('v110', 'v120', 'v140')]
171+
[ValidateSet('v110', 'v120', 'v140', 'v141')]
168172
[Parameter(Position = 0, ValueFromPipeline = $true)]
169173
[string] $Toolchain,
170174

@@ -203,6 +207,33 @@ function Msvs
203207
$VXXCommonTools = Join-Path $env:VS140COMNTOOLS '..\..\vc'
204208
$CmakeGenerator = 'Visual Studio 14'
205209
}
210+
'v141' {
211+
$programFilesDir = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0]
212+
213+
$vswherePath = Join-Path $programFilesDir 'Microsoft Visual Studio\Installer\vswhere.exe'
214+
#Check if we already have vswhere which is included in newer versions of VS2017
215+
if(-not (Test-Path $vswherePath))
216+
{
217+
# Check if we already have a local copy and download if required
218+
$vswherePath = Join-Path $WorkingDir \vswhere.exe
219+
220+
# TODO: Check hash and download if hash differs
221+
if(-not (Test-Path $vswherePath))
222+
{
223+
$client = New-Object System.Net.WebClient;
224+
$client.DownloadFile('https://github.com/Microsoft/vswhere/releases/download/2.2.11/vswhere.exe', $vswherePath);
225+
}
226+
}
227+
$VS2017InstallPath = & $vswherePath -version 15 -property installationPath
228+
229+
if(-not (Test-Path $VS2017InstallPath)) {
230+
Die "Visual Studio 2017 was not found"
231+
}
232+
233+
$VisualStudioVersion = '15.0'
234+
$VXXCommonTools = Join-Path $VS2017InstallPath VC\Auxiliary\Build
235+
$CmakeGenerator = 'Visual Studio 15'
236+
}
206237
}
207238

208239
if ($VXXCommonTools -eq $null -or (-not (Test-Path($VXXCommonTools)))) {
@@ -217,7 +248,8 @@ function Msvs
217248

218249
$VCVarsAll = Join-Path $VXXCommonTools vcvarsall.bat
219250
if (-not (Test-Path $VCVarsAll)) {
220-
Die "Unable to find $VCVarsAll"
251+
Warn "Toolchain $Toolchain is not installed on your development machine, skipping $Configuration $Platform build."
252+
Return
221253
}
222254

223255
$VCXProj = $Cef32vcx
@@ -281,26 +313,11 @@ function Msvs
281313
function VSX
282314
{
283315
param(
284-
[ValidateSet('v110', 'v120', 'v140')]
316+
[ValidateSet('v110', 'v120', 'v140', 'v141')]
285317
[Parameter(Position = 0, ValueFromPipeline = $true)]
286318
[string] $Toolchain
287319
)
288320

289-
if ($Toolchain -eq 'v110' -and $env:VS110COMNTOOLS -eq $null) {
290-
Warn "Toolchain $Toolchain is not installed on your development machine, skipping build."
291-
Return
292-
}
293-
294-
if ($Toolchain -eq 'v120' -and $env:VS120COMNTOOLS -eq $null) {
295-
Warn "Toolchain $Toolchain is not installed on your development machine, skipping build."
296-
Return
297-
}
298-
299-
if ($Toolchain -eq 'v140' -and $env:VS140COMNTOOLS -eq $null) {
300-
Warn "Toolchain $Toolchain is not installed on your development machine, skipping build."
301-
Return
302-
}
303-
304321
Write-Diagnostic "Starting to build targeting toolchain $Toolchain"
305322

306323
Msvs "$Toolchain" 'Debug' 'x86'
@@ -314,7 +331,7 @@ function VSX
314331
function CreateCefSdk
315332
{
316333
param(
317-
[ValidateSet('v110', 'v120', 'v140')]
334+
[ValidateSet('v110', 'v120', 'v140', 'v141')]
318335
[Parameter(Position = 0, ValueFromPipeline = $true)]
319336
[string] $Toolchain,
320337

@@ -330,7 +347,9 @@ function CreateCefSdk
330347
Write-Diagnostic "Creating sdk for $Toolchain"
331348

332349
$VisualStudioVersion = $null
333-
if ($Toolchain -eq "v140") {
350+
if($Toolchain -eq "v141") {
351+
$VisualStudioVersion = "VS2017"
352+
} elseif($Toolchain -eq "v140") {
334353
$VisualStudioVersion = "VS2015"
335354
} elseif ($Toolchain -eq "v110") {
336355
$VisualStudioVersion = "VS2012"
@@ -597,4 +616,7 @@ switch -Exact ($Target) {
597616
"vs2015" {
598617
VSX v140
599618
}
619+
"vs2017" {
620+
VSX v141
621+
}
600622
}

0 commit comments

Comments
 (0)