Skip to content

Commit fb39310

Browse files
committed
Added Visual Studio 2019 support (tools v142) and switched to using the -A flag with cmake for arch (supported since VS 2008/cmake 3.1)
1 parent 289f43e commit fb39310

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

build.ps1

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#requires -Version 5
22

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

@@ -198,28 +198,32 @@ try
198198
md 'cef\win32\debug\VS2013' | Out-Null
199199
md 'cef\win32\debug\VS2015' | Out-Null
200200
md 'cef\win32\debug\VS2017' | Out-Null
201+
md 'cef\win32\debug\VS2019' | Out-Null
201202
md 'cef\win32\release' | Out-Null
202203
md 'cef\win32\release\VS2012' | Out-Null
203204
md 'cef\win32\release\VS2013' | Out-Null
204205
md 'cef\win32\release\VS2015' | Out-Null
205206
md 'cef\win32\release\VS2017' | Out-Null
207+
md 'cef\win32\release\VS2019' | Out-Null
206208
md 'cef\x64' | Out-Null
207209
md 'cef\x64\debug' | Out-Null
208210
md 'cef\x64\debug\VS2012' | Out-Null
209211
md 'cef\x64\debug\VS2013' | Out-Null
210212
md 'cef\x64\debug\VS2015' | Out-Null
211213
md 'cef\x64\debug\VS2017' | Out-Null
214+
md 'cef\x64\debug\VS2019' | Out-Null
212215
md 'cef\x64\release' | Out-Null
213216
md 'cef\x64\release\VS2012' | Out-Null
214217
md 'cef\x64\release\VS2013' | Out-Null
215218
md 'cef\x64\release\VS2015' | Out-Null
216219
md 'cef\x64\release\VS2017' | Out-Null
220+
md 'cef\x64\release\VS2019' | Out-Null
217221
}
218222

219223
function Msvs
220224
{
221225
param(
222-
[ValidateSet('v110', 'v120', 'v140', 'v141')]
226+
[ValidateSet('v110', 'v120', 'v140', 'v141', 'v142')]
223227
[Parameter(Position = 0, ValueFromPipeline = $true)]
224228
[string] $Toolchain,
225229

@@ -270,12 +274,15 @@ try
270274
$VXXCommonTools = Join-Path $env:VS140COMNTOOLS '..\..\vc'
271275
$CmakeGenerator = 'Visual Studio 14'
272276
}
273-
'v141'
277+
{($_ -eq 'v141') -or ($_ -eq 'v142')}
274278
{
279+
$VS_VER = 15;
280+
$VS_OFFICIAL_VER = 2017;
281+
if ($_ -eq 'v142'){$VS_VER=16;$VS_OFFICIAL_VER=2019;}
275282
$programFilesDir = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0]
276283

277284
$vswherePath = Join-Path $programFilesDir 'Microsoft Visual Studio\Installer\vswhere.exe'
278-
#Check if we already have vswhere which is included in newer versions of VS2017
285+
#Check if we already have vswhere which is included in newer versions of VS2017/VS2019
279286
if(-not (Test-Path $vswherePath))
280287
{
281288
Write-Diagnostic "Downloading VSWhere as no install found at $vswherePath"
@@ -292,19 +299,20 @@ try
292299
}
293300

294301
Write-Diagnostic "VSWhere path $vswherePath"
302+
303+
$versionSearchStr = "[$VS_VER.0," + ($VS_VER+1) + ".0)"
304+
$VS2017InstallPath = & $vswherePath -version $versionSearchStr -property installationPath
295305

296-
$VS2017InstallPath = & $vswherePath -version '[15.0,16.0)' -property installationPath
297-
298-
Write-Diagnostic "VS2017InstallPath: $VS2017InstallPath"
306+
Write-Diagnostic "$($VS_OFFICIAL_VER)InstallPath: $VS2017InstallPath"
299307

300308
if($VS2017InstallPath -eq $null -or !(Test-Path $VS2017InstallPath))
301309
{
302-
Die "Visual Studio 2017 was not found"
310+
Die "Visual Studio $VS_OFFICIAL_VER was not found"
303311
}
304312

305-
$VisualStudioVersion = '15.0'
313+
$VisualStudioVersion = "$VS_VER.0"
306314
$VXXCommonTools = Join-Path $VS2017InstallPath VC\Auxiliary\Build
307-
$CmakeGenerator = 'Visual Studio 15'
315+
$CmakeGenerator = "Visual Studio $VS_VER"
308316
}
309317
}
310318

@@ -317,7 +325,6 @@ try
317325
$CefDir = TernaryReturn ($Platform -eq 'x86') $Cef32 $Cef64
318326

319327
$Arch = TernaryReturn ($Platform -eq 'x64') 'x64' 'win32'
320-
$CmakeArch = TernaryReturn ($Platform -eq 'x64') ' Win64' ''
321328

322329
$VCVarsAll = Join-Path $VXXCommonTools vcvarsall.bat
323330
if (-not (Test-Path $VCVarsAll))
@@ -341,16 +348,14 @@ try
341348
# Remove previously generated CMake data for the different platform/toolchain
342349
rm CMakeCache.txt -ErrorAction:SilentlyContinue
343350
rm -r CMakeFiles -ErrorAction:SilentlyContinue
344-
Write-Diagnostic "Running cmake"
345351
$cmake_path = "cmake.exe";
346352
if ($env:ChocolateyInstall -And (Test-Path ($env:ChocolateyInstall + "\bin\" + $cmake_path)))
347353
{
348-
$cmake_path = $env:ChocolateyInstall + "\bin\" + $cmake_path;
349-
350-
&"$cmake_path" --version
354+
$cmake_path = $env:ChocolateyInstall + "\bin\" + $cmake_path;
351355
}
352-
&"$cmake_path" -LAH -G "$CmakeGenerator$CmakeArch" -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD .
353-
356+
&"$cmake_path" --version
357+
Write-Diagnostic "Running cmake: $cmake_path -LAH -G '$CmakeGenerator' -A $Arch -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD ."
358+
&"$cmake_path" -LAH -G "$CmakeGenerator" -A $Arch -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD .
354359
popd
355360
$env:CEFSHARP_BUILD_IS_BOOTSTRAPPED = "$Toolchain$Platform"
356361
}
@@ -404,7 +409,7 @@ try
404409
function VSX
405410
{
406411
param(
407-
[ValidateSet('v110', 'v120', 'v140', 'v141')]
412+
[ValidateSet('v110', 'v120', 'v140', 'v141', 'v142')]
408413
[Parameter(Position = 0, ValueFromPipeline = $true)]
409414
[string] $Toolchain
410415
)
@@ -428,7 +433,7 @@ try
428433
function CreateCefSdk
429434
{
430435
param(
431-
[ValidateSet('v110', 'v120', 'v140', 'v141')]
436+
[ValidateSet('v110', 'v120', 'v140', 'v141', 'v142')]
432437
[Parameter(Position = 0, ValueFromPipeline = $true)]
433438
[string] $Toolchain,
434439

@@ -444,7 +449,11 @@ try
444449
Write-Diagnostic "Creating sdk for $Toolchain"
445450

446451
$VisualStudioVersion = $null
447-
if($Toolchain -eq "v141")
452+
if($Toolchain -eq "v142")
453+
{
454+
$VisualStudioVersion = "VS2019"
455+
}
456+
elseif($Toolchain -eq "v141")
448457
{
449458
$VisualStudioVersion = "VS2017"
450459
}
@@ -775,6 +784,10 @@ try
775784
{
776785
VSX v141
777786
}
787+
"vs2019"
788+
{
789+
VSX v142
790+
}
778791
}
779792
}
780793
catch

0 commit comments

Comments
 (0)