-
Notifications
You must be signed in to change notification settings - Fork 88
/
build.ps1
768 lines (621 loc) · 20.3 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
#requires -Version 5
param(
[ValidateSet("vs2019", "vs2022", "nupkg", "nupkg-only")]
[Parameter(Position = 0)]
[string] $Target = "nupkg",
[ValidateSet("none", "download", "local")]
[Parameter(Position = 1)]
[string] $DownloadBinary = "download",
[Parameter(Position = 2)]
# absolute or relative path to directory containing cef binaries archives (used if DownloadBinary = local)
[string] $CefBinaryDir = "../cefsource/chromium/src/cef/binary_distrib/",
[Parameter(Position = 3)]
$CefVersion = "121.2.14+ga44b59f+chromium-121.0.6167.75",
[ValidateSet("tar.bz2","zip","7z")]
[Parameter(Position = 4)]
[string] $Extension = "tar.bz2",
[Parameter(Position = 5)]
[Switch] $NoDebugBuild,
[Parameter(Position = 6)]
[string] $Suffix,
[Parameter(Position = 7)]
[string] $BuildArches = "win-x86;win-x64;win-arm64"
)
Set-StrictMode -version latest
$ErrorActionPreference = "Stop";
$Extension = $Extension.ToLower();
Function WriteException($exp)
{
write-host "Caught an exception:" -ForegroundColor Yellow -NoNewline;
write-host " $($exp.Exception.Message)" -ForegroundColor Red;
write-host "`tException Type: $($exp.Exception.GetType().FullName)";
$stack = $exp.ScriptStackTrace;
$stack = $stack.replace("`n","`n`t");
write-host "`tStack Trace: $stack";
throw $exp;
}
function Write-Diagnostic
{
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[string] $Message
)
Write-Host
Write-Host $Message -ForegroundColor Green
Write-Host
}
# https://github.com/jbake/Powershell_scripts/blob/master/Invoke-BatchFile.ps1
function Invoke-BatchFile
{
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[string]$Path,
[Parameter(Position = 1, Mandatory = $true, ValueFromPipeline = $true)]
[string]$Parameters
)
$tempFile = [IO.Path]::GetTempFileName()
# NOTE: A better solution would be to use PSCX's Push-EnvironmentBlock before calling
# this and popping it before calling this function again as repeated use of this function
# can (unsurprisingly) cause the PATH variable to max out at Windows upper limit.
$batFile = [IO.Path]::GetTempFileName() + '.cmd'
Set-Content -Path $batFile -Value "`"$Path`" $Parameters && set > `"$tempFile`"`r`n"
& $batFile
#Brace must be on same line for foreach-object to work
Get-Content $tempFile | Foreach-Object {
if ($_ -match "^(.*?)=(.*)$")
{
Set-Content "env:\$($matches[1])" $matches[2]
}
}
Remove-Item $tempFile
Remove-Item $batFile
}
function Die
{
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $Message
)
Write-Host
Write-Error $Message
exit 1
}
function Warn
{
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $Message
)
Write-Host
Write-Host $Message -ForegroundColor Yellow
Write-Host
}
function DownloadDependencies()
{
$folder = Join-Path $env:LOCALAPPDATA .\nuget;
$Nuget = Join-Path $folder .\NuGet.exe
if (-not (Test-Path $Nuget))
{
if (-not (Test-Path $folder))
{
mkdir $folder
}
$Client = New-Object System.Net.WebClient;
$Client.DownloadFile('https://dist.nuget.org/win-x86-commandline/v5.11.0/nuget.exe', $Nuget);
}
$global:VSWherePath = Join-Path ${env:ProgramFiles} 'Microsoft Visual Studio\Installer\vswhere.exe'
if(-not (Test-Path $global:VSWherePath))
{
$global:VSWherePath = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
}
#Check if we already have vswhere which is included in newer versions of VS2019/VS2022
if(-not (Test-Path $global:VSwherePath))
{
Write-Diagnostic "Downloading VSWhere as no install found at $global:VSwherePath"
# Check if we already have a local copy and download if required
$global:VSwherePath = Join-Path $WorkingDir \vswhere.exe
# TODO: Check hash and download if hash differs
if(-not (Test-Path $global:VSwherePath))
{
$client = New-Object System.Net.WebClient;
$client.DownloadFile('https://github.com/Microsoft/vswhere/releases/download/2.5.2/vswhere.exe', $global:VSwherePath);
}
}
}
function WriteVersionToRuntimeJson
{
$Filename = Join-Path $WorkingDir NuGet\chromiumembeddedframework.runtime.json
Write-Diagnostic "Write Version ($CefPackageVersion) to $Filename"
$Regex1 = '": ".*"';
$Replace = '": "' + $CefPackageVersion + '"';
$RunTimeJsonData = Get-Content -Encoding UTF8 $Filename
$NewString = $RunTimeJsonData -replace $Regex1, $Replace
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines($Filename, $NewString, $Utf8NoBomEncoding)
}
function CheckDependencies()
{
# Check for cmake
if ($null -eq (Get-Command "cmake.exe" -ErrorAction SilentlyContinue))
{
Die "Unable to find cmake.exe in your PATH"
}
# Check for 7zip
if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe"))
{
Die "$env:ProgramFiles\7-Zip\7z.exe is required"
}
}
function Bootstrap
{
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
$Platform
)
Write-Diagnostic ("Creating folders for " + $Platform.ArchLong)
# Create default directory structure
$path = $Platform.Folder
# Copy include files and license.txt
Copy-Item $path\include $CefIncludeFolder -Recurse -Force | Out-Null
Copy-Item $path\License.txt $CefWorkingFolder -Force | Out-Null
$arch = $Platform.NativeArch
mkdir "cef\$arch" | Out-Null
mkdir "cef\$arch\debug" | Out-Null
mkdir "cef\$arch\debug\VS2019" | Out-Null
mkdir "cef\$arch\debug\VS2022" | Out-Null
mkdir "cef\$arch\release" | Out-Null
mkdir "cef\$arch\release\VS2019" | Out-Null
mkdir "cef\$arch\release\VS2022" | Out-Null
}
function Msvs
{
param(
[ValidateSet('v142', 'v143')]
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $Toolchain,
[Parameter(Position = 1, ValueFromPipeline = $true)]
[ValidateSet('Debug', 'Release')]
[string] $Configuration,
[Parameter(Position = 2, ValueFromPipeline = $true)]
[hashtable] $Platform
)
Write-Diagnostic "Targeting $Toolchain using configuration $Configuration on platform ($Platform.ArchLong)"
$VisualStudioVersion = $null
$VXXCommonTools = $null
$CmakeGenerator = $null
$CefProject = [IO.Path]::Combine($Platform.Folder, 'libcef_dll_wrapper','libcef_dll_wrapper.vcxproj');
$CefDir = $Platform.Folder
$Arch = $Platform.NativeArch
$VS_VER = 16;
$VS_OFFICIAL_VER = 2019;
if ($Toolchain -eq 'v143')
{
$VS_VER=17;
$VS_OFFICIAL_VER=2022;
}
Write-Diagnostic "VSWhere path $global:VSwherePath"
$versionSearchStr = "[$VS_VER.0," + ($VS_VER+1) + ".0)"
$VSInstallPath = & $global:VSwherePath -version $versionSearchStr -property installationPath
Write-Diagnostic "$($VS_OFFICIAL_VER)InstallPath: $VSInstallPath"
if($null -eq $VSInstallPath -or !(Test-Path $VSInstallPath))
{
$VSInstallPath = & $global:VSwherePath -version $versionSearchStr -property installationPath -products 'Microsoft.VisualStudio.Product.BuildTools'
Write-Diagnostic "BuildTools $($VS_OFFICIAL_VER)InstallPath: $VSInstallPath"
if($null -eq $VSInstallPath -or !(Test-Path $VSInstallPath))
{
Die "Visual Studio $VS_OFFICIAL_VER was not found"
}
}
$VisualStudioVersion = "$VS_VER.0"
$VXXCommonTools = Join-Path $VSInstallPath VC\Auxiliary\Build
$CmakeGenerator = "Visual Studio $VS_VER"
if ($null -eq $VXXCommonTools -or (-not (Test-Path($VXXCommonTools))))
{
Die 'Error unable to find any visual studio environment'
}
$VCVarsAll = Join-Path $VXXCommonTools vcvarsall.bat
if (-not (Test-Path $VCVarsAll))
{
Warn "Toolchain $Toolchain is not installed on your development machine, skipping $Configuration $Arch build."
Return
}
$VCVarsAllArch = $Platform.Arch
if ($VCVarsAllArch -eq "arm64")
{
$VCVarsAllArch = 'x64_arm64'
}
# Store the current environment variables so that we can reset them after running the build.
# This is because vcvarsall.bat appends e.g. to the PATH variable every time it is called,
# which can eventually lead to an error like "The input line is too long." when the PATH
# gets too long.
$PreviousEnvPath = $Env:Path
$PreviousEnvLib = $Env:Lib
$PreviousEnvLibPath = $Env:LibPath
$PreviousEnvInclude = $Env:Include
try
{
# Configure build environment
Invoke-BatchFile $VCVarsAll $VCVarsAllArch
Write-Diagnostic "pushd $CefDir"
Push-Location $CefDir
# Remove previously generated CMake data for the different platform/toolchain
Remove-Item CMakeCache.txt -ErrorAction:SilentlyContinue
Remove-Item -r CMakeFiles -ErrorAction:SilentlyContinue
$cmake_path = "cmake.exe";
if ($env:ChocolateyInstall -And (Test-Path ($env:ChocolateyInstall + "\bin\" + $cmake_path)))
{
$cmake_path = $env:ChocolateyInstall + "\bin\" + $cmake_path;
}
&"$cmake_path" --version
Write-Diagnostic "Running cmake: $cmake_path -Wno-dev -LAH -G '$CmakeGenerator' -A $Arch -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD ."
&"$cmake_path" -Wno-dev -LAH -G "$CmakeGenerator" -A $Arch -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD .
Pop-Location
$Arguments = @(
"$CefProject",
"/t:rebuild",
"/p:VisualStudioVersion=$VisualStudioVersion",
"/p:Configuration=$Configuration",
"/p:PlatformToolset=$Toolchain",
"/p:Platform=$Arch",
"/p:PreferredToolArchitecture=$Arch",
"/p:ConfigurationType=StaticLibrary"
)
$StartInfo = New-Object System.Diagnostics.ProcessStartInfo
$StartInfo.FileName = "msbuild.exe"
$StartInfo.Arguments = $Arguments
$StartInfo.EnvironmentVariables.Clear()
#Brace must be on same line for foreach-object to work
Get-ChildItem -Path env:* | ForEach-Object {
$StartInfo.EnvironmentVariables.Add($_.Name, $_.Value)
}
$StartInfo.UseShellExecute = $false
$StartInfo.CreateNoWindow = $false
$StartInfo.RedirectStandardError = $true
$StartInfo.RedirectStandardOutput = $true
$Process = New-Object System.Diagnostics.Process
$Process.StartInfo = $startInfo
$Process.Start()
$stdout = $Process.StandardOutput.ReadToEnd()
$stderr = $Process.StandardError.ReadToEnd()
$Process.WaitForExit()
if ($Process.ExitCode -ne 0)
{
Write-Host "Ran msbuild.exe with args: $Arguments"
Write-Host "stdout: $stdout"
Write-Host "stderr: $stderr"
Die "Build failed"
}
CreateCefSdk $Toolchain $Configuration $Platform
}
finally
{
# Reset the environment variables to their previous values.
$Env:Path = $PreviousEnvPath
$Env:Lib = $PreviousEnvLib
$Env:LibPath = $PreviousEnvLibPath
$Env:Include = $PreviousEnvInclude
}
}
function VSX
{
param(
[ValidateSet('v142', 'v143')]
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $toolchain,
[Parameter(Position = 1, ValueFromPipeline = $true)]
[hashtable] $Platform
)
Write-Diagnostic "Starting to build targeting toolchain $Toolchain"
if (! $NoDebugBuild)
{
Msvs "$toolchain" 'Debug' $Platform
}
Msvs "$toolchain" 'Release' $Platform
Write-Diagnostic "Finished build targeting toolchain $toolchain"
}
function CreateCefSdk
{
param(
[ValidateSet('v142', 'v143')]
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $Toolchain,
[Parameter(Position = 1, ValueFromPipeline = $true)]
[ValidateSet('Debug', 'Release')]
[string] $Configuration,
[Parameter(Position = 2, ValueFromPipeline = $true)]
[hashtable] $Platform
)
Write-Diagnostic "Creating sdk for $Toolchain"
$VisualStudioVersion = "VS2019"
if($Toolchain -eq "v143")
{
$VisualStudioVersion = "VS2022"
}
$CefArchDir = $Platform.Folder
$Arch = $Platform.NativeArch;
# cef_binary_3.y.z_windows32\out\debug\lib -> cef\win32\debug\vs2019
Copy-Item $CefArchDir\libcef_dll_wrapper\$Configuration\libcef_dll_wrapper.lib $CefWorkingFolder\$Arch\$Configuration\$VisualStudioVersion | Out-Null
Copy-Item $CefArchDir\libcef_dll_wrapper\$Configuration\libcef_dll_wrapper.pdb $CefWorkingFolder\$Arch\$Configuration\$VisualStudioVersion | Out-Null
# cef_binary_3.y.z_windows32\debug -> cef\win32\debug
Copy-Item $CefArchDir\$Configuration\libcef.lib $CefWorkingFolder\$Arch\$Configuration | Out-Null
}
function Nupkg
{
Write-Diagnostic "Building nuget package"
$Nuget = Join-Path $env:LOCALAPPDATA .\nuget\NuGet.exe
if (-not (Test-Path $Nuget))
{
Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget"
}
foreach ($platform in $Platforms.Values)
{
if(!$platform.Enabled)
{
continue
}
$arch = $platform.Arch
$archLong = $platform.ArchLong
# Build packages
. $Nuget pack nuget\chromiumembeddedframework.runtime.win.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties "Configuration=Release;Platform=$arch;CPlatform=$archLong;" -OutputDirectory nuget
}
# Meta Package
. $Nuget pack nuget\chromiumembeddedframework.runtime.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;' -OutputDirectory nuget
# Build sdk
$Filename = Resolve-Path ".\nuget\cef.sdk.props"
$Text = (Get-Content $Filename) -replace '<CefSdkVer>.*<\/CefSdkVer>', "<CefSdkVer>cef.sdk.$CefPackageVersion</CefSdkVer>"
[System.IO.File]::WriteAllLines($Filename, $Text)
. $Nuget pack nuget\cef.sdk.nuspec -NoPackageAnalysis -Version $CefPackageVersion -OutputDirectory nuget
if ($env:APPVEYOR_REPO_TAG -eq "True")
{
Get-ChildItem -Path .\Nuget -Filter *.nupkg -File | ForEach-Object {
appveyor PushArtifact $_.FullName
} | Out-Null
}
}
function ExtractArchive()
{
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
[string] $ArchivePath,
[Parameter(Position = 1, ValueFromPipeline = $true)]
[string] $CefFileName,
[Parameter(Position = 2, ValueFromPipeline = $true)]
[string] $OutputFolder
)
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
# Extract bzip file
sz x $ArchivePath;
if ($Extension -eq "tar.bz2")
{
# Extract tar file
$TarFile = ($ArchivePath).Substring(0, $ArchivePath.length - 4)
sz x $TarFile
# Sleep for a short period to allow 7z to release it's file handles
Start-Sleep -m 2000
# Remove tar file
Remove-Item $TarFile
}
$Folder = Join-Path $WorkingDir ($CefFileName.Substring(0, $CefFileName.length - ($Extension.Length+1)))
Move-Item ($Folder + '\*') $OutputFolder -force
Remove-Item $Folder
}
function DownloadCefBinaryAndUnzip()
{
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
[hashtable] $Platform
)
$CefBuildServerUrl = "https://cef-builds.spotifycdn.com/"
if($null -eq $global:CefBuildsJson)
{
$CefBuildServerJsonPackageList = $CefBuildServerUrl + "index.json"
$global:CefBuildsJson = Invoke-WebRequest -UseBasicParsing -Uri $CefBuildServerJsonPackageList | ConvertFrom-Json
}
$arch = $Platform.ArchLong
$CefWinCefVersion = $global:CefBuildsJson.($arch).versions | Where-Object {$_.cef_version -eq $CefVersion}
if($null -eq $CefWinCefVersion)
{
Die "Build Unavailable - $arch has no files for version $CefVersion"
}
#TODO Duplication
$CefFileName = ($CefWinCefVersion.files | Where-Object {$_.type -eq "standard"}).name
$CefFileHash = ($CefWinCefVersion.files | Where-Object {$_.type -eq "standard"}).sha1
$CefFileSize = (($CefWinCefVersion.files | Where-Object {$_.type -eq "standard"}).size /1MB)
$LocalFile = Join-Path $WorkingDir $CefFileName
if (-not (Test-Path $LocalFile))
{
$Client = New-Object System.Net.WebClient;
Write-Diagnostic "Downloading $CefFileName; this will take a while as the file is $CefFileSize MB."
$Client.DownloadFile($CefBuildServerUrl + [System.Web.HttpUtility]::UrlEncode($CefFileName), $LocalFile);
if (-not (Test-Path $LocalFile))
{
Die "Downloading $CefFileName failed"
}
$CefLocalFileHash = (Get-FileHash -Path $LocalFile -Algorithm SHA1).Hash
Write-Diagnostic "Download $CefFileName complete"
Write-Diagnostic "Expected SHA1 for $CefFileName $CefFileHash"
Write-Diagnostic "Actual SHA1 for $CefFileName $CefLocalFileHash"
if($CefLocalFileHash -ne $CefFileHash)
{
Die "SHA1 hash did not match"
}
}
if (-not (Test-Path (Join-Path $Platform.Folder '\include\cef_version.h')))
{
ExtractArchive $LocalFile $CefFileName $Platform.Folder
}
}
function CopyFromLocalCefBuild()
{
param(
[Parameter(Position = 0, ValueFromPipeline = $true)]
[hashtable] $Platform
)
# Example file names from cefsource build:
# 32-bit: cef_binary_3.2924.1538.gbfdeccd_windows32.tar.bz2
# 64-bit: cef_binary_3.2924.1538.gbfdeccd_windows64.tar.bz2
$archLong = $Platform.ArchLong
$CefFileName = "cef_binary_$($CefVersion)_$archLong." + $Extension;
$LocalFile = Join-Path $WorkingDir $CefFileName
if (-not (Test-Path $LocalFile))
{
Write-Diagnostic "Copy $CefFileName (approx 200mb)"
Copy-Item ($CefBinaryDir+$CefFileName) $LocalFile
Write-Diagnostic "Copy of $CefFileName complete"
}
if (-not (Test-Path (Join-Path $Platform.Folder '\include\cef_version.h')))
{
ExtractArchive $LocalFile $CefFileName $Platform.Folder
}
}
try
{
$global:CefBuildsJson = $null
$VSwherePath = $null
$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition;
Write-Diagnostic "pushd $WorkingDir"
Push-Location $WorkingDir
$CefWorkingFolder = Join-Path $WorkingDir 'cef'
$CefIncludeFolder = Join-Path $CefWorkingFolder 'include'
$Platforms = @{
'win-x86'=@{
Enabled=($BuildArches.Contains('win-x86') -or $BuildArches.Contains('x86'));
NativeArch='win32';
Arch='x86';
ArchLong='windows32';
Folder=Join-Path $WorkingDir 'cef_binary_3.y.z_windows32';
};
'win-x64'=@{
Enabled=$BuildArches.Contains('win-x64') -or $BuildArches.Contains('x64');
NativeArch='x64';
Arch='x64';
ArchLong='windows64';
Folder=Join-Path $WorkingDir 'cef_binary_3.y.z_windows64';
};
'win-arm64'=@{
Enabled=($BuildArches.Contains('win-arm64') -or $BuildArches.Contains('arm64'));
NativeArch='arm64';
Arch='arm64';
ArchLong='windowsarm64';
Folder=Join-Path $WorkingDir 'cef_binary_3.y.z_windowsarm64';
};
}
if($DownloadBinary -eq "local")
{
if ([System.IO.Path]::IsPathRooted($CefBinaryDir))
{
$CefBinaryDir = $CefBinaryDir
}
else
{
$CefBinaryDir = [System.IO.Path]::GetFullPath((Join-Path $WorkingDir "$CefBinaryDir/"))
}
if ($CefVersion -eq "auto")
{
$enabledPlatform = $Platforms.GetEnumerator() | Where-Object {
$_.Value.Enabled -eq $true
}
$enabledPlatformFileExtension = $enabledPlatform[0].Value.ArchLong + '.' + $Extension
#Take the version from the local binary only
$name = (Get-ChildItem -Filter cef_binary_*_$enabledPlatformFileExtension $CefBinaryDir)[0].Name;
$CefVersion = ($name -replace "cef_binary_", "") -replace "_$enabledPlatformFileExtension";
}
}
# Set CefVersion based on tag name - must start with leading "v" e.g. v3.3163.1663.g416ffeb
if ($env:APPVEYOR_REPO_TAG -eq "True")
{
$CefVersion = "$env:APPVEYOR_REPO_TAG_NAME".Substring(1) # trim leading "v"
Write-Diagnostic "Setting version based on tag to $CefVersion"
}
# Take the cef version and strip the commit hash, chromium version
# we should end up with something like 73.1.12
$CefPackageVersion = $CefVersion.SubString(0, $CefVersion.IndexOf('+'))
if($Suffix)
{
$CefPackageVersion = $CefPackageVersion + '-' + $Suffix
}
CheckDependencies
DownloadDependencies
WriteVersionToRuntimeJson
Write-Diagnostic("CEF Version: $CefVersion")
Write-Diagnostic("Enabled Architectures")
foreach($platform in $Platforms.Values)
{
if($platform.Enabled)
{
Write-Diagnostic("Arch: " + $platform.ArchLong)
}
}
if($Target -eq "nupkg-only")
{
Nupkg
return;
}
Write-Diagnostic ("Deleting working folder $CefWorkingFolder")
if (Test-Path($CefWorkingFolder))
{
Remove-Item $CefWorkingFolder -Recurse | Out-Null
}
foreach ($platform in $Platforms.Values)
{
if(!$platform.Enabled)
{
continue
}
switch -Exact ($DownloadBinary)
{
"none"
{
}
"download"
{
DownloadCefBinaryAndUnzip $platform
}
"local"
{
CopyFromLocalCefBuild $platform
}
}
Bootstrap $platform
}
# Loop through twice so the files have been downloaded
# extracted and validated before we attempt to build
# makes sure we have all platforms
foreach ($platform in $Platforms.Values)
{
# Create the folders for any that don't exist so the nuget packages are created with empty folders
# This can be removed once the new chromiumembeddedframework.runtime.resource package is created
[System.IO.Directory]::CreateDirectory([IO.Path]::Combine($platform.Folder, 'Resources','locales'))
if(!$platform.Enabled)
{
continue
}
switch -Exact ($Target)
{
"nupkg"
{
VSX v142 $platform
}
"vs2022"
{
VSX v143 $platform
}
"vs2019"
{
VSX v142 $platform
}
}
}
if($Target -eq "nupkg")
{
Nupkg
}
}
catch
{
WriteException $_;
}
finally
{
Pop-Location
}