diff --git a/NuGet/cef.redist.nuspec b/NuGet/cef.redist.nuspec
deleted file mode 100644
index 7473268..0000000
--- a/NuGet/cef.redist.nuspec
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- cef.redist.$Platform$
- $version$
- The Chromium Embedded Framework Authors
- The CefSharp Authors
- https://github.com/cefsharp/cef-binary
- https://raw.github.com/cefsharp/cef-binary/master/NuGet/cef128x128.gif
- LICENSE.txt
- false
- CEF - the Chromium Embedded Framework.
- NOTE: This package is maintained on behalf of the CEF authors by the CefSharp project at http://github.com/cefsharp/cef-binary
- chrome chromium native embedded browser CEF nativepackage
- Copyright © 2008-2021
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/NuGet/cef.redist.x64.props b/NuGet/cef.redist.x64.props
deleted file mode 100644
index 78bc32d..0000000
--- a/NuGet/cef.redist.x64.props
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- $(TargetDir)
-
-
-
- <_CefRedist64 Include="$(MSBuildThisFileDirectory)..\CEF\**\*.*" />
-
-
-
-
-
\ No newline at end of file
diff --git a/NuGet/cef.redist.x86.props b/NuGet/cef.redist.x86.props
deleted file mode 100644
index 30766c5..0000000
--- a/NuGet/cef.redist.x86.props
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- $(TargetDir)
-
-
-
- <_CefRedist32 Include="$(MSBuildThisFileDirectory)..\CEF\**\*.*" />
-
-
-
-
-
\ No newline at end of file
diff --git a/NuGet/cef.sdk.props b/NuGet/cef.sdk.props
index 9fdb304..7f412a8 100644
--- a/NuGet/cef.sdk.props
+++ b/NuGet/cef.sdk.props
@@ -1,6 +1,6 @@
- cef.sdk.94.0.5
+ cef.sdk.138.0.15
diff --git a/NuGet/chromiumembeddedframework.runtime.json b/NuGet/chromiumembeddedframework.runtime.json
index ad77618..9dc32d3 100644
--- a/NuGet/chromiumembeddedframework.runtime.json
+++ b/NuGet/chromiumembeddedframework.runtime.json
@@ -2,17 +2,17 @@
"runtimes": {
"win-x64": {
"chromiumembeddedframework.runtime": {
- "chromiumembeddedframework.runtime.win-x64": "94.0.5"
+ "chromiumembeddedframework.runtime.win-x64": "138.0.15"
}
},
"win-x86": {
"chromiumembeddedframework.runtime": {
- "chromiumembeddedframework.runtime.win-x86": "94.0.5"
+ "chromiumembeddedframework.runtime.win-x86": "138.0.15"
}
},
"win-arm64": {
"chromiumembeddedframework.runtime": {
- "chromiumembeddedframework.runtime.win-arm64": "94.0.5"
+ "chromiumembeddedframework.runtime.win-arm64": "138.0.15"
}
},
}
diff --git a/NuGet/chromiumembeddedframework.runtime.nuspec b/NuGet/chromiumembeddedframework.runtime.nuspec
index 8053485..ef1fd41 100644
--- a/NuGet/chromiumembeddedframework.runtime.nuspec
+++ b/NuGet/chromiumembeddedframework.runtime.nuspec
@@ -26,13 +26,11 @@
-
-
-
-
+
+
diff --git a/NuGet/chromiumembeddedframework.runtime.props b/NuGet/chromiumembeddedframework.runtime.props
index bee07f1..e8a0eac 100644
--- a/NuGet/chromiumembeddedframework.runtime.props
+++ b/NuGet/chromiumembeddedframework.runtime.props
@@ -5,10 +5,7 @@
-->
-
-
-
\ No newline at end of file
diff --git a/NuGet/chromiumembeddedframework.runtime.win-arm64.props b/NuGet/chromiumembeddedframework.runtime.win-arm64.props
new file mode 100644
index 0000000..a143464
--- /dev/null
+++ b/NuGet/chromiumembeddedframework.runtime.win-arm64.props
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ <_CefRuntimeWinArm64Additional Include="$(MSBuildThisFileDirectory)..\CEF\win-arm64\**\*.*" />
+
+
+
+
+
+
+
+ $(TargetDir)
+
+
+
+ <_CefRuntimeWinArm64 Include="$(MSBuildThisFileDirectory)..\runtimes\win-arm64\native\*.*" />
+ <_CefRuntimeWinArm64 Include="$(MSBuildThisFileDirectory)..\CEF\win-arm64\**\*.*" />
+
+
+
+
+
\ No newline at end of file
diff --git a/NuGet/chromiumembeddedframework.runtime.win-x64.props b/NuGet/chromiumembeddedframework.runtime.win-x64.props
new file mode 100644
index 0000000..f6c0006
--- /dev/null
+++ b/NuGet/chromiumembeddedframework.runtime.win-x64.props
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ <_CefRuntimeWin64Additional Include="$(MSBuildThisFileDirectory)..\CEF\win-x64\**\*.*" />
+
+
+
+
+
+
+
+ $(TargetDir)
+
+
+
+ <_CefRuntimeWin64 Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\*.*" />
+ <_CefRuntimeWin64 Include="$(MSBuildThisFileDirectory)..\CEF\win-x64\**\*.*" />
+
+
+
+
+
\ No newline at end of file
diff --git a/NuGet/chromiumembeddedframework.runtime.win-x86.props b/NuGet/chromiumembeddedframework.runtime.win-x86.props
new file mode 100644
index 0000000..bc910c4
--- /dev/null
+++ b/NuGet/chromiumembeddedframework.runtime.win-x86.props
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ <_CefRuntimeWin32Additional Include="$(MSBuildThisFileDirectory)..\CEF\win-x86\**\*.*" />
+
+
+
+
+
+
+
+ $(TargetDir)
+
+
+
+ <_CefRuntimeWin32 Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\*.*" />
+ <_CefRuntimeWin32 Include="$(MSBuildThisFileDirectory)..\CEF\win-x86\**\*.*" />
+
+
+
+
+
\ No newline at end of file
diff --git a/NuGet/chromiumembeddedframework.runtime.win.nuspec b/NuGet/chromiumembeddedframework.runtime.win.nuspec
index 6c34f26..24080e2 100644
--- a/NuGet/chromiumembeddedframework.runtime.win.nuspec
+++ b/NuGet/chromiumembeddedframework.runtime.win.nuspec
@@ -22,14 +22,17 @@
Copyright © 2008-2021
-
+
+
+
+
-
+
diff --git a/README.md b/README.md
index 4108aa2..5dd300c 100644
--- a/README.md
+++ b/README.md
@@ -2,43 +2,19 @@
# README
-This is a repackaging fork of the Chromium Embedded Framework (CEF) binary distribution files for Windows, found at https://cef-builds.spotifycdn.com/index.html, into [these NuGet packages](https://www.nuget.org/packages?q=Id%3A%22cef.redist%22%2C%22cef.sdk%22)
+This repository contains a build script that compiles and packages the Chromium Embedded Framework (CEF) binary distribution files for Windows, found at https://cef-builds.spotifycdn.com/index.html
-To make it work properly for developers on VS2013 or VS2015 wanting to develop [CefSharp](http://github.com/cefsharp/CefSharp), we need to do some local modifications ([use dynamic linking](https://bitbucket.org/chromiumembedded/cef/wiki/LinkingDifferentRunTimeLibraries)) to make CefSharp.Core compile properly. This purpose of this repository is to track and maintain these modifications as well as tooling for maintaining the NuGet packages.
+To make it work properly for developers on VS2019 or VS2022 wanting to develop [CefSharp](http://github.com/cefsharp/CefSharp), we need to compile `libcef_dll_wrapper` for ([dynamic linking](https://bitbucket.org/chromiumembedded/cef/wiki/LinkingDifferentRunTimeLibraries)).
The modifications allow us to:
-- Re-package and distribute CEF `.dll` and `.pak` files in a piecemeal fashion using http://nuget.org (this is useful for both [Xilium.CefGlue](https://bitbucket.org/xilium/xilium.cefglue) and CefSharp developers and users alike)
+- Re-package and distribute CEF `.dll` and `.pak` files in a piecemeal fashion using http://nuget.org (this is useful for both [Xilium.CefGlue](https://gitlab.com/xiliumhq/chromiumembedded/cefglue) and CefSharp developers and users alike)
- Build `libcef_dll_wrapper.lib`s as mentioned above for [CefSharp](http://github.com/cefsharp/CefSharp)
-- Have a place to pick CEF `include` files for easy inclusion downstream (by `git submodule` vendor folders etc.)
-
-The original README for CEF can be found here: [README.txt](README.txt). It has some useful details about which CEF pieces are needed for what (e.g. browser developer tools, language support, different HTML5 features, WebGL support etc.)
-
-# Architecture
-
-Note to self: Add a diagram here based on: http://codepen.io/jornh/full/Iyebk explaining that this is the red layer with the native code from the upstream CEF (and Chromium projects)
-
-TODO: Explain each of the red pieces along the lines of this rough plan (subject to change):
-Foundation z: NuGets
-
-- C.F.Base.x64|Win32 ... (~ Bcl. Xxx ) ....
-- C.Foundation.Res.Lang
-- C.Foundation.Res.Dev
-
-- C.Foundation.WebGL (incl d*dxxxx43|46)
-- C.F.MDwrapper
-
- ## Easy
-
-- C.F.Bundle.x64(NoLang)
-- C.F.Bundle.Win32
-
-- CS.Core
-- CS.Wpf
+The CEF Readme.txt file is now included as part of the Nuget packages.
# License
-The code is licensed under the same license as the Chromium Embeddded Framework, i.e. the "new BSD" license. The full CEF license text can be found here: [LICENSE.txt](LICENSE.txt).
+The code is licensed under the same license as the Chromium Embeddded Framework, i.e. the "new BSD" license. The full CEF license text can be found here: [LICENSE.txt](https://bitbucket.org/chromiumembedded/cef/src/master/LICENSE.txt).
Additionally, don't forget to view `chrome://credits/` for additional licences used by Chromium.
diff --git a/appveyor.yml b/appveyor.yml
index dd3d487..319342b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,6 +1,6 @@
-image: Visual Studio 2019
+image: Visual Studio 2022
-version: 93.0.1-CI{build}
+version: 138.0.15-CI{build}
shallow_clone: true
diff --git a/build.ps1 b/build.ps1
index eecaf8b..9f940ea 100644
--- a/build.ps1
+++ b/build.ps1
@@ -1,7 +1,7 @@
#requires -Version 5
param(
- [ValidateSet("vs2019", "vs2021", "nupkg", "nupkg-only")]
+ [ValidateSet("vs2019", "vs2022", "nupkg", "nupkg-only")]
[Parameter(Position = 0)]
[string] $Target = "nupkg",
@@ -14,7 +14,7 @@ param(
[string] $CefBinaryDir = "../cefsource/chromium/src/cef/binary_distrib/",
[Parameter(Position = 3)]
- $CefVersion = "94.0.5+g506b164+chromium-94.0.4606.41",
+ $CefVersion = "138.0.15+gd0f1f64+chromium-138.0.7204.50",
[ValidateSet("tar.bz2","zip","7z")]
[Parameter(Position = 4)]
@@ -24,7 +24,10 @@ param(
[Switch] $NoDebugBuild,
[Parameter(Position = 6)]
- [string] $Suffix
+ [string] $Suffix,
+
+ [Parameter(Position = 7)]
+ [string] $BuildArches = "win-x86;win-x64;win-arm64"
)
Set-StrictMode -version latest
@@ -42,850 +45,730 @@ Function WriteException($exp)
throw $exp;
}
-try
+function Write-Diagnostic
{
- $WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition;
- if ($CefVersion -eq "auto" -and $DownloadBinary -eq "local")
- {
- #Take the version from the local binary only, requires only one version in that folder to work
- $name = (dir -Filter cef_binary_*_windows64.$Extension $CefBinaryDir)[0].Name;
- $CefVersion = ($name -replace "cef_binary_", "") -replace "_windows64.$Extension";
- }
-
- $Cef = Join-Path $WorkingDir 'cef'
- $CefInclude = Join-Path $Cef 'include'
- $Cef32 = Join-Path $WorkingDir 'cef_binary_3.y.z_windows32'
- $Cef32vcx = Join-Path (Join-Path $Cef32 'libcef_dll_wrapper') 'libcef_dll_wrapper.vcxproj'
- $Cef64 = Join-Path $WorkingDir 'cef_binary_3.y.z_windows64'
- $Cef64vcx = Join-Path (Join-Path $Cef64 'libcef_dll_wrapper') 'libcef_dll_wrapper.vcxproj'
- $CefArm64 = Join-Path $WorkingDir 'cef_binary_3.y.z_windowsarm64'
- $CefArm64vcx = Join-Path (Join-Path $CefArm64 'libcef_dll_wrapper') 'libcef_dll_wrapper.vcxproj'
-
- function Write-Diagnostic
- {
- param(
- [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
- [string] $Message
- )
-
- Write-Host
- Write-Host $Message -ForegroundColor Green
- Write-Host
- }
-
- # 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"
- }
-
- if($CefVersion.StartsWith('3.'))
- {
- # Take the cef version and strip the commit hash
- $CefPackageVersion = $CefVersion.SubString(0, $CefVersion.LastIndexOf('.'))
- }
- else
- {
- # 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
- }
+ 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
- )
+# 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()
+ $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"
+ # 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
+ & $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
+ #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
- )
+function Die
+{
+ param(
+ [Parameter(Position = 0, ValueFromPipeline = $true)]
+ [string] $Message
+ )
- Write-Host
- Write-Error $Message
- exit 1
+ Write-Host
+ Write-Error $Message
+ exit 1
- }
+}
- function Warn
- {
- param(
- [Parameter(Position = 0, ValueFromPipeline = $true)]
- [string] $Message
- )
+function Warn
+{
+ param(
+ [Parameter(Position = 0, ValueFromPipeline = $true)]
+ [string] $Message
+ )
- Write-Host
- Write-Host $Message -ForegroundColor Yellow
- Write-Host
+ Write-Host
+ Write-Host $Message -ForegroundColor Yellow
+ Write-Host
- }
+}
- function TernaryReturn
+function DownloadDependencies()
+{
+ $folder = Join-Path $env:LOCALAPPDATA .\nuget;
+ $Nuget = Join-Path $folder .\NuGet.exe
+ if (-not (Test-Path $Nuget))
{
- param(
- [Parameter(Position = 0, ValueFromPipeline = $true)]
- [bool] $Yes,
- [Parameter(Position = 1, ValueFromPipeline = $true)]
- $Value,
- [Parameter(Position = 2, ValueFromPipeline = $true)]
- $Value2
- )
-
- if ($Yes)
+ if (-not (Test-Path $folder))
{
- return $Value
+ mkdir $folder
}
+
+ $Client = New-Object System.Net.WebClient;
+ $Client.DownloadFile('https://dist.nuget.org/win-x86-commandline/v5.11.0/nuget.exe', $Nuget);
+ }
- $Value2
+ $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'
}
- function Bootstrap
+ #Check if we already have vswhere which is included in newer versions of VS2019/VS2022
+ if(-not (Test-Path $global:VSwherePath))
{
- param()
-
- if ($Target -eq "nupkg-only")
- {
- return
- }
-
- Write-Diagnostic "Bootstrapping"
-
- if (Test-Path($Cef))
+ 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))
{
- Remove-Item $Cef -Recurse | Out-Null
+ $client = New-Object System.Net.WebClient;
+ $client.DownloadFile('https://github.com/Microsoft/vswhere/releases/download/2.5.2/vswhere.exe', $global:VSwherePath);
}
+ }
+}
- # Copy include files
- Copy-Item $Cef64\include $CefInclude -Recurse | Out-Null
-
- # Create default directory structure
- md 'cef\win32' | Out-Null
- md 'cef\win32\debug' | Out-Null
- md 'cef\win32\debug\VS2019' | Out-Null
- md 'cef\win32\debug\VS2021' | Out-Null
- md 'cef\win32\release' | Out-Null
- md 'cef\win32\release\VS2019' | Out-Null
- md 'cef\win32\release\VS2021' | Out-Null
- md 'cef\x64' | Out-Null
- md 'cef\x64\debug' | Out-Null
- md 'cef\x64\debug\VS2019' | Out-Null
- md 'cef\x64\debug\VS2021' | Out-Null
- md 'cef\x64\release' | Out-Null
- md 'cef\x64\release\VS2019' | Out-Null
- md 'cef\x64\release\VS2021' | Out-Null
- md 'cef\arm64' | Out-Null
- md 'cef\arm64\debug' | Out-Null
- md 'cef\arm64\debug\VS2019' | Out-Null
- md 'cef\arm64\debug\VS2021' | Out-Null
- md 'cef\arm64\release' | Out-Null
- md 'cef\arm64\release\VS2019' | Out-Null
- md 'cef\arm64\release\VS2021' | 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)]
- [ValidateSet('x86', 'x64', 'arm64')]
- [string] $Platform
- )
+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)
+}
- Write-Diagnostic "Targeting $Toolchain using configuration $Configuration on platform $Platform"
+function CheckDependencies()
+{
+ # Check for cmake
+ if ($null -eq (Get-Command "cmake.exe" -ErrorAction SilentlyContinue))
+ {
+ Die "Unable to find cmake.exe in your PATH"
+ }
- $VisualStudioVersion = $null
- $VXXCommonTools = $null
- $CmakeGenerator = $null
+ # Check for 7zip
+ if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe"))
+ {
+ Die "$env:ProgramFiles\7-Zip\7z.exe is required"
+ }
+}
- $VS_VER = 16;
- $VS_OFFICIAL_VER = 2019;
-
- if ($_ -eq 'v143')
- {
- $VS_VER=17;
- $VS_OFFICIAL_VER=2021;
- }
-
- $programFilesDir = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0]
+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
+}
- $vswherePath = Join-Path $programFilesDir 'Microsoft Visual Studio\Installer\vswhere.exe'
- #Check if we already have vswhere which is included in newer versions of VS2019/VS2021
- if(-not (Test-Path $vswherePath))
- {
- Write-Diagnostic "Downloading VSWhere as no install found at $vswherePath"
-
- # Check if we already have a local copy and download if required
- $vswherePath = Join-Path $WorkingDir \vswhere.exe
+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;
- # TODO: Check hash and download if hash differs
- if(-not (Test-Path $vswherePath))
- {
- $client = New-Object System.Net.WebClient;
- $client.DownloadFile('https://github.com/Microsoft/vswhere/releases/download/2.5.2/vswhere.exe', $vswherePath);
- }
- }
+ if ($Toolchain -eq 'v143')
+ {
+ $VS_VER=17;
+ $VS_OFFICIAL_VER=2022;
+ }
- Write-Diagnostic "VSWhere path $vswherePath"
+ Write-Diagnostic "VSWhere path $global:VSwherePath"
- $versionSearchStr = "[$VS_VER.0," + ($VS_VER+1) + ".0)"
- $VSInstallPath = & $vswherePath -version $versionSearchStr -property installationPath
+ $versionSearchStr = "[$VS_VER.0," + ($VS_VER+1) + ".0)"
+ $VSInstallPath = & $global:VSwherePath -version $versionSearchStr -property installationPath
- Write-Diagnostic "$($VS_OFFICIAL_VER)InstallPath: $VSInstallPath"
+ Write-Diagnostic "$($VS_OFFICIAL_VER)InstallPath: $VSInstallPath"
- if($VSInstallPath -eq $null -or !(Test-Path $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"
+ $VisualStudioVersion = "$VS_VER.0"
+ $VXXCommonTools = Join-Path $VSInstallPath VC\Auxiliary\Build
+ $CmakeGenerator = "Visual Studio $VS_VER"
- if ($VXXCommonTools -eq $null -or (-not (Test-Path($VXXCommonTools))))
- {
- Die 'Error unable to find any visual studio environment'
- }
-
- $CefProject = $Cef32vcx
- $CefDir = $Cef32
- $Arch = 'win32'
- if ($Platform -eq 'x64')
- {
- $CefProject = $Cef64vcx
- $CefDir = $Cef64
- $Arch = 'x64'
- }
- elseif ($Platform -eq 'arm64')
- {
- $CefProject = $CefArm64vcx
- $CefDir = $CefArm64
- $Arch = 'arm64'
- }
+ 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 $Platform build."
- Return
- }
+ $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
+ }
- $VCXProj = $Cef32vcx
- $VCVarsAllArch = 'x86'
- if ($Platform -eq 'x64')
- {
- $VCXProj = $Cef64vcx
- $VCVarsAllArch = 'x64'
- }
- elseif ($Platform -eq 'arm64')
- {
- $VCXProj = $CefArm64vcx
- $VCVarsAllArch = 'x64_arm64'
- }
+ $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"
+ )
- # 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
+ $StartInfo = New-Object System.Diagnostics.ProcessStartInfo
+ $StartInfo.FileName = "msbuild.exe"
+ $StartInfo.Arguments = $Arguments
- try
- {
- # Configure build environment
- Invoke-BatchFile $VCVarsAll $VCVarsAllArch
- Write-Diagnostic "pushd $CefDir"
- pushd $CefDir
- # Remove previously generated CMake data for the different platform/toolchain
- rm CMakeCache.txt -ErrorAction:SilentlyContinue
- rm -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 -LAH -G '$CmakeGenerator' -A $Arch -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD ."
- &"$cmake_path" -LAH -G "$CmakeGenerator" -A $Arch -DUSE_SANDBOX=Off -DCEF_RUNTIME_LIBRARY_FLAG=/MD .
- popd
-
- $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.EnvironmentVariables.Clear()
- $StartInfo.UseShellExecute = $false
- $StartInfo.CreateNoWindow = $false
- $StartInfo.RedirectStandardError = $true
- $StartInfo.RedirectStandardOutput = $true
+ #Brace must be on same line for foreach-object to work
+ Get-ChildItem -Path env:* | ForEach-Object {
+ $StartInfo.EnvironmentVariables.Add($_.Name, $_.Value)
+ }
- $Process = New-Object System.Diagnostics.Process
- $Process.StartInfo = $startInfo
- $Process.Start()
+ $StartInfo.UseShellExecute = $false
+ $StartInfo.CreateNoWindow = $false
+ $StartInfo.RedirectStandardError = $true
+ $StartInfo.RedirectStandardOutput = $true
- $stdout = $Process.StandardOutput.ReadToEnd()
- $stderr = $Process.StandardError.ReadToEnd()
+ $Process = New-Object System.Diagnostics.Process
+ $Process.StartInfo = $startInfo
+ $Process.Start()
- $Process.WaitForExit()
+ $stdout = $Process.StandardOutput.ReadToEnd()
+ $stderr = $Process.StandardError.ReadToEnd()
- if ($Process.ExitCode -ne 0)
- {
- Write-Host "stdout: $stdout"
- Write-Host "stderr: $stderr"
- Die "Build failed"
- }
+ $Process.WaitForExit()
- CreateCefSdk $Toolchain $Configuration $Platform
- }
- finally
+ if ($Process.ExitCode -ne 0)
{
- # Reset the environment variables to their previous values.
- $Env:Path = $PreviousEnvPath
- $Env:Lib = $PreviousEnvLib
- $Env:LibPath = $PreviousEnvLibPath
- $Env:Include = $PreviousEnvInclude
+ Write-Host "Ran msbuild.exe with args: $Arguments"
+ Write-Host "stdout: $stdout"
+ Write-Host "stderr: $stderr"
+ Die "Build failed"
}
- }
- function VSX
+ CreateCefSdk $Toolchain $Configuration $Platform
+ }
+ finally
{
- param(
- [ValidateSet('v142', 'v143')]
- [Parameter(Position = 0, ValueFromPipeline = $true)]
- [string] $Toolchain
- )
+ # Reset the environment variables to their previous values.
+ $Env:Path = $PreviousEnvPath
+ $Env:Lib = $PreviousEnvLib
+ $Env:LibPath = $PreviousEnvLibPath
+ $Env:Include = $PreviousEnvInclude
+ }
+}
- Write-Diagnostic "Starting to build targeting toolchain $Toolchain"
+function VSX
+{
+ param(
+ [ValidateSet('v142', 'v143')]
+ [Parameter(Position = 0, ValueFromPipeline = $true)]
+ [string] $toolchain,
- if (! $NoDebugBuild)
- {
- Msvs "$Toolchain" 'Debug' 'x86'
- }
- Msvs "$Toolchain" 'Release' 'x86'
- if (! $NoDebugBuild)
- {
- Msvs "$Toolchain" 'Debug' 'x64'
- }
- Msvs "$Toolchain" 'Release' 'x64'
+ [Parameter(Position = 1, ValueFromPipeline = $true)]
+ [hashtable] $Platform
+ )
- if (! $NoDebugBuild)
- {
- Msvs "$Toolchain" 'Debug' 'arm64'
- }
- Msvs "$Toolchain" 'Release' 'arm64'
+ Write-Diagnostic "Starting to build targeting toolchain $Toolchain"
- Write-Diagnostic "Finished build targeting toolchain $Toolchain"
+ if (! $NoDebugBuild)
+ {
+ Msvs "$toolchain" 'Debug' $Platform
}
+ Msvs "$toolchain" 'Release' $Platform
- function CreateCefSdk
- {
- param(
- [ValidateSet('v142', 'v143')]
- [Parameter(Position = 0, ValueFromPipeline = $true)]
- [string] $Toolchain,
+ Write-Diagnostic "Finished build targeting toolchain $toolchain"
+}
- [Parameter(Position = 1, ValueFromPipeline = $true)]
- [ValidateSet('Debug', 'Release')]
- [string] $Configuration,
+function CreateCefSdk
+{
+ param(
+ [ValidateSet('v142', 'v143')]
+ [Parameter(Position = 0, ValueFromPipeline = $true)]
+ [string] $Toolchain,
- [Parameter(Position = 2, ValueFromPipeline = $true)]
- [ValidateSet('x86', 'x64', 'arm64')]
- [string] $Platform
- )
+ [Parameter(Position = 1, ValueFromPipeline = $true)]
+ [ValidateSet('Debug', 'Release')]
+ [string] $Configuration,
+
+ [Parameter(Position = 2, ValueFromPipeline = $true)]
+ [hashtable] $Platform
+ )
- Write-Diagnostic "Creating sdk for $Toolchain"
+ Write-Diagnostic "Creating sdk for $Toolchain"
- $VisualStudioVersion = "VS2019"
+ $VisualStudioVersion = "VS2019"
- if($Toolchain -eq "v143")
- {
- $VisualStudioVersion = "VS2021"
- }
+ if($Toolchain -eq "v143")
+ {
+ $VisualStudioVersion = "VS2022"
+ }
- $Arch = 'win32'
- $CefArchDir = $Cef32
- if ($Platform -eq 'x64')
- {
- $Arch = 'x64'
- $CefArchDir = $Cef64
- }
- elseif ($Platform -eq 'arm64')
- {
- $Arch = 'arm64'
- $CefArchDir = $CefArm64
- }
+ $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 $Cef\$Arch\$Configuration\$VisualStudioVersion | Out-Null
- Copy-Item $CefArchDir\libcef_dll_wrapper\$Configuration\libcef_dll_wrapper.pdb $Cef\$Arch\$Configuration\$VisualStudioVersion | Out-Null
+ # 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 $Cef\$Arch\$Configuration | 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"
- function Nupkg
+ $Nuget = Join-Path $env:LOCALAPPDATA .\nuget\NuGet.exe
+ if (-not (Test-Path $Nuget))
{
- Write-Diagnostic "Building nuget package"
+ Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget"
+ }
- $Nuget = Join-Path $env:LOCALAPPDATA .\nuget\NuGet.exe
- if (-not (Test-Path $Nuget))
+ foreach ($platform in $Platforms.Values)
+ {
+ if(!$platform.Enabled)
{
- Die "Please install nuget. More information available at: http://docs.nuget.org/docs/start-here/installing-nuget"
+ continue
}
- # Build 32bit packages
- . $Nuget pack nuget\cef.redist.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;Platform=x86;CPlatform=windows32;' -OutputDirectory nuget
- . $Nuget pack nuget\chromiumembeddedframework.runtime.win.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;Platform=x86;CPlatform=windows32;' -OutputDirectory nuget
+ $arch = $platform.Arch
+ $archLong = $platform.ArchLong
- # Build 64bit packages
- . $Nuget pack nuget\cef.redist.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;Platform=x64;CPlatform=windows64;' -OutputDirectory nuget
- . $Nuget pack nuget\chromiumembeddedframework.runtime.win.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;Platform=x64;CPlatform=windows64;' -OutputDirectory nuget
-
- # Build arm64 packages
- . $Nuget pack nuget\chromiumembeddedframework.runtime.win.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;Platform=arm64;CPlatform=windowsarm64;' -OutputDirectory nuget
+ # 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
+ # 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>', "cef.sdk.$CefPackageVersion"
- [System.IO.File]::WriteAllLines($Filename, $Text)
+ # Build sdk
+ $Filename = Resolve-Path ".\nuget\cef.sdk.props"
+ $Text = (Get-Content $Filename) -replace '.*<\/CefSdkVer>', "cef.sdk.$CefPackageVersion"
+ [System.IO.File]::WriteAllLines($Filename, $Text)
- . $Nuget pack nuget\cef.sdk.nuspec -NoPackageAnalysis -Version $CefPackageVersion -OutputDirectory nuget
+ . $Nuget pack nuget\cef.sdk.nuspec -NoPackageAnalysis -Version $CefPackageVersion -OutputDirectory nuget
- if ($env:APPVEYOR_REPO_TAG -eq "True")
- {
- appveyor PushArtifact "nuget\cef.redist.x86.$CefPackageVersion.nupkg"
- appveyor PushArtifact "nuget\cef.redist.x64.$CefPackageVersion.nupkg"
- appveyor PushArtifact "nuget\chromiumembeddedframework.runtime.win-x86.$CefPackageVersion.nupkg"
- appveyor PushArtifact "nuget\chromiumembeddedframework.runtime.win-x64.$CefPackageVersion.nupkg"
- appveyor PushArtifact "nuget\chromiumembeddedframework.runtime.win-arm64.$CefPackageVersion.nupkg"
- appveyor PushArtifact "nuget\chromiumembeddedframework.runtime.$CefPackageVersion.nupkg"
- appveyor PushArtifact "nuget\cef.sdk.$CefPackageVersion.nupkg"
- }
- }
-
- function DownloadNuget()
+ if ($env:APPVEYOR_REPO_TAG -eq "True")
{
- $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);
- }
+ 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;
- function DownloadCefBinaryAndUnzip()
+ if ($Extension -eq "tar.bz2")
{
- $Client = New-Object System.Net.WebClient;
+ # Extract tar file
+ $TarFile = ($ArchivePath).Substring(0, $ArchivePath.length - 4)
+ sz x $TarFile
- $CefBuildServerUrl = "https://cef-builds.spotifycdn.com/"
- $CefBuildServerJsonPackageList = $CefBuildServerUrl + "index.json"
+ # Sleep for a short period to allow 7z to release it's file handles
+ Start-Sleep -m 2000
- $CefBuildsJson = Invoke-WebRequest -UseBasicParsing -Uri $CefBuildServerJsonPackageList | ConvertFrom-Json
- $CefWin32CefVersion = $CefBuildsJson.windows32.versions | Where-Object {$_.cef_version -eq $CefVersion}
- $CefWin64CefVersion = $CefBuildsJson.windows64.versions | Where-Object {$_.cef_version -eq $CefVersion}
- $CefWinArm64CefVersion = $CefBuildsJson.windowsarm64.versions | Where-Object {$_.cef_version -eq $CefVersion}
-
- $Cef32FileName = ($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).name
- $Cef32FileHash = ($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).sha1
- $Cef32FileSize = (($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).size /1MB)
- $Cef64FileName = ($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).name
- $Cef64FileHash = ($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).sha1
- $Cef64FileSize = (($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).size /1MB)
- $CefArm64FileName = ($CefWinArm64CefVersion.files | Where-Object {$_.type -eq "standard"}).name
- $CefArm64FileHash = ($CefWinArm64CefVersion.files | Where-Object {$_.type -eq "standard"}).sha1
- $CefArm64FileSize = (($CefWinArm64CefVersion.files | Where-Object {$_.type -eq "standard"}).size /1MB)
-
- # Make sure there is a 32bit and 64bit version for the specified build
- if ($CefWin32CefVersion.cef_version -ne $CefWin64CefVersion.cef_version)
- {
- Die 'Win32 version is $CefWin32CefVersion.cef_version and Win64 version is $CefWin64CefVersion.cef_version - both must be the same'
- }
- if ($CefWin32CefVersion.cef_version -ne $CefWinArm64CefVersion.cef_version)
- {
- Die 'Win32 version is $CefWin32CefVersion.cef_version and WinArm64 version is $CefWinArm64CefVersion.cef_version - both must be the same'
- }
+ # Remove tar file
+ Remove-Item $TarFile
+ }
- set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
+ $Folder = Join-Path $WorkingDir ($CefFileName.Substring(0, $CefFileName.length - ($Extension.Length+1)))
+ Move-Item ($Folder + '\*') $OutputFolder -force
+ Remove-Item $Folder
+}
- $LocalFile = Join-Path $WorkingDir $Cef32FileName
+function DownloadCefBinaryAndUnzip()
+{
+ param(
+ [Parameter(Position = 0, ValueFromPipeline = $true)]
+ [hashtable] $Platform
+ )
- if (-not (Test-Path $LocalFile))
- {
- Write-Diagnostic "Downloading $Cef32FileName; this will take a while as the file is $Cef32FileSize MB."
- $Client.DownloadFile($CefBuildServerUrl + [System.Web.HttpUtility]::UrlEncode($Cef32FileName), $LocalFile);
-
- $Cef32LocalFileHash = (Get-FileHash -Path $LocalFile -Algorithm SHA1).Hash
-
- Write-Diagnostic "Download $Cef32FileName complete"
- Write-Diagnostic "Expected SHA1 for $Cef32FileName $Cef32FileHash"
- Write-Diagnostic "Actual SHA1 for $Cef32FileName $Cef32LocalFileHash"
-
- if($Cef32LocalFileHash -ne $Cef32FileHash)
- {
- Die "SHA1 hash did not match"
- }
- }
+ $CefBuildServerUrl = "https://cef-builds.spotifycdn.com/"
- if (-not (Test-Path (Join-Path $Cef32 '\include\cef_version.h')))
- {
- # Extract bzip file
- sz e $LocalFile
+ if($null -eq $global:CefBuildsJson)
+ {
+ $CefBuildServerJsonPackageList = $CefBuildServerUrl + "index.json"
+
+ $global:CefBuildsJson = Invoke-WebRequest -UseBasicParsing -Uri $CefBuildServerJsonPackageList | ConvertFrom-Json
+ }
+
+ $arch = $Platform.ArchLong
- # Extract tar file
- $TarFile = ($LocalFile).Substring(0, $LocalFile.length - 4)
- sz x $TarFile
+ $CefWinCefVersion = $global:CefBuildsJson.($arch).versions | Where-Object {$_.cef_version -eq $CefVersion}
- # Sleep for a short period to allow 7z to release it's file handles
- sleep -m 2000
+ if($null -eq $CefWinCefVersion)
+ {
+ Die "Build Unavailable - $arch has no files for version $CefVersion"
+ }
- # Remove tar file
- Remove-Item $TarFile
+ # CEF sometimes has multiple builds of the same version with one being Stable and one being Beta
+ # We'll take the newest build in that case
+ $CefStandardFiles = ($CefWinCefVersion.files | Where-Object {$_.type -eq "standard"} | Sort-Object -Descending -Property last_modified)[0];
- $Folder = Join-Path $WorkingDir ($Cef32FileName.Substring(0, $Cef32FileName.length - 8))
- Move-Item ($Folder + '\*') $Cef32 -force
- Remove-Item $Folder
- }
+ $CefFileName = $CefStandardFiles.name
+ $CefFileHash = $CefStandardFiles.sha1
+ $CefFileSize = $CefStandardFiles.size /1MB
- $LocalFile = Join-Path $WorkingDir $Cef64FileName
+ $LocalFile = Join-Path $WorkingDir $CefFileName
+ if (-not (Test-Path $LocalFile))
+ {
+ # The spotify build server uses case sensitive urls now, need to use EscapeDataString instead of UrlEncode
+ $UriEncodedFileName = [System.Uri]::EscapeDataString($CefFileName)
+ $FullUri = $CefBuildServerUrl + $UriEncodedFileName
+ Write-Diagnostic "Downloading $FullUri this will take a while as the file is $CefFileSize MB."
+
+ $Client = New-Object System.Net.WebClient;
+ $Client.DownloadFile($FullUri, $LocalFile);
if (-not (Test-Path $LocalFile))
{
- Write-Diagnostic "Downloading $Cef64FileName; this will take a while as the file is $Cef64FileSize MB."
- $Client.DownloadFile($CefBuildServerUrl + [System.Web.HttpUtility]::UrlEncode($Cef64FileName), $LocalFile);
-
- $Cef64LocalFileHash = (Get-FileHash -Path $LocalFile -Algorithm SHA1).Hash
-
- Write-Diagnostic "Download $Cef64FileName complete"
- Write-Diagnostic "Expected SHA1 for $Cef64FileName $Cef64FileHash"
- Write-Diagnostic "Actual SHA1 for $Cef64FileName $Cef64LocalFileHash"
-
- if($Cef64LocalFileHash -ne $Cef64FileHash)
- {
- Die "SHA1 hash did not match"
- }
+ Die "Downloading $CefFileName failed"
}
-
- if (-not (Test-Path (Join-Path $Cef64 '\include\cef_version.h')))
+
+ $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)
{
- # Extract bzip file
- sz e $LocalFile
-
- # Extract tar file
- $TarFile = ($LocalFile).Substring(0, $LocalFile.length - 4)
- sz x $TarFile
-
- # Sleep for a short period to allow 7z to release it's file handles
- sleep -m 2000
-
- # Remove tar file
- Remove-Item $TarFile
-
- $Folder = Join-Path $WorkingDir ($Cef64FileName.Substring(0, $Cef64FileName.length - 8))
- Move-Item ($Folder + '\*') $Cef64 -force
- Remove-Item $Folder
+ Die "SHA1 hash did not match"
}
+ }
- $LocalFile = Join-Path $WorkingDir $CefArm64FileName
+ if (-not (Test-Path (Join-Path $Platform.Folder '\include\cef_version.h')))
+ {
+ ExtractArchive $LocalFile $CefFileName $Platform.Folder
+ }
+}
- if (-not (Test-Path $LocalFile))
- {
- Write-Diagnostic "Downloading $CefArm64FileName; this will take a while as the file is $CefArm64FileSize MB."
- $Client.DownloadFile($CefBuildServerUrl + [System.Web.HttpUtility]::UrlEncode($CefArm64FileName), $LocalFile);
-
- $CefArm64LocalFileHash = (Get-FileHash -Path $LocalFile -Algorithm SHA1).Hash
-
- Write-Diagnostic "Download $CefArm64FileName complete"
- Write-Diagnostic "Expected SHA1 for $CefArm64FileName $CefArm64FileHash"
- Write-Diagnostic "Actual SHA1 for $CefArm64FileName $CefArm64LocalFileHash"
-
- if($CefArm64LocalFileHash -ne $CefArm64FileHash)
- {
- Die "SHA1 hash did not match"
- }
- }
+function CopyFromLocalCefBuild()
+{
+ param(
+ [Parameter(Position = 0, ValueFromPipeline = $true)]
+ [hashtable] $Platform
+ )
- if (-not (Test-Path (Join-Path $CefArm64 '\include\cef_version.h')))
- {
- # Extract bzip file
- sz e $LocalFile
+ # 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
- # Extract tar file
- $TarFile = ($LocalFile).Substring(0, $LocalFile.length - 4)
- sz x $TarFile
+ $archLong = $Platform.ArchLong
- # Sleep for a short period to allow 7z to release it's file handles
- sleep -m 2000
+ $CefFileName = "cef_binary_$($CefVersion)_$archLong." + $Extension;
- # Remove tar file
- Remove-Item $TarFile
+ $LocalFile = Join-Path $WorkingDir $CefFileName
- $Folder = Join-Path $WorkingDir ($CefArm64FileName.Substring(0, $CefArm64FileName.length - 8))
- Move-Item ($Folder + '\*') $CefArm64 -force
- Remove-Item $Folder
- }
+ if (-not (Test-Path $LocalFile))
+ {
+ Write-Diagnostic "Copy $CefFileName (approx 200mb)"
+ Copy-Item ($CefBinaryDir+$CefFileName) $LocalFile
+ Write-Diagnostic "Copy of $CefFileName complete"
}
- function CopyFromLocalCefBuild()
+ if (-not (Test-Path (Join-Path $Platform.Folder '\include\cef_version.h')))
{
- # 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
+ ExtractArchive $LocalFile $CefFileName $Platform.Folder
+ }
+}
- Write-Host $CefVersion
+try
+{
+ $global:CefBuildsJson = $null
+ $VSwherePath = $null
+ $WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition;
- $Cef32FileName = "cef_binary_$($CefVersion)_windows32." + $Extension;
- $Cef64FileName = "cef_binary_$($CefVersion)_windows64." + $Extension;
- $CefArm64FileName = "cef_binary_$($CefVersion)_windowsarm64." + $Extension;
+ Write-Diagnostic "pushd $WorkingDir"
+ Push-Location $WorkingDir
- set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
+ $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))
{
- $CefBuildDir = $CefBinaryDir
+ $CefBinaryDir = $CefBinaryDir
}
else
{
- $CefBuildDir = Join-Path $WorkingDir "$CefBinaryDir/"
+ $CefBinaryDir = [System.IO.Path]::GetFullPath((Join-Path $WorkingDir "$CefBinaryDir/"))
}
-
- $LocalFile = Join-Path $WorkingDir $Cef32FileName
-
- if (-not (Test-Path $LocalFile))
- {
- Write-Diagnostic "Copy $Cef32FileName (approx 200mb)"
- Copy-Item ($CefBuildDir+$Cef32FileName) $LocalFile
- Write-Diagnostic "Copy of $Cef32FileName complete"
- }
-
- if (-not (Test-Path (Join-Path $Cef32 '\include\cef_version.h')))
+
+ if ($CefVersion -eq "auto")
{
- # Extract bzip file
- sz x $LocalFile;
-
- if ($Extension -eq "tar.bz2")
- {
- # Extract tar file
- $TarFile = ($LocalFile).Substring(0, $LocalFile.length - 4)
- sz x $TarFile
-
- # Sleep for a short period to allow 7z to release it's file handles
- sleep -m 2000
-
- # Remove tar file
- Remove-Item $TarFile
+ $enabledPlatform = $Platforms.GetEnumerator() | Where-Object {
+ $_.Value.Enabled -eq $true
}
- $Folder = Join-Path $WorkingDir ($Cef32FileName.Substring(0, $Cef32FileName.length - ($Extension.Length+1)))
- Move-Item ($Folder + '\*') $Cef32 -force
- Remove-Item $Folder
- }
-
- $LocalFile = Join-Path $WorkingDir $Cef64FileName
-
- if (-not (Test-Path $LocalFile))
- {
- Write-Diagnostic "Copy $Cef64FileName (approx 200mb)"
- Copy-Item ($CefBuildDir+$Cef64FileName) $LocalFile;
- Write-Diagnostic "Copy of $Cef64FileName complete"
+ $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";
}
+ }
- if (-not (Test-Path (Join-Path $Cef64 '\include\cef_version.h')))
- {
- # Extract bzip file
- sz x $LocalFile;
-
- if ($Extension -eq "tar.bz2")
- {
- # Extract tar file
- $TarFile = ($LocalFile).Substring(0, $LocalFile.length - 4)
- sz x $TarFile
-
- # Sleep for a short period to allow 7z to release it's file handles
- sleep -m 2000
+ # 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
+ }
- # Remove tar file
- Remove-Item $TarFile
- }
- $Folder = Join-Path $WorkingDir ($Cef64FileName.Substring(0, $Cef64FileName.length - ($Extension.Length+1)))
- Move-Item ($Folder + '\*') $Cef64 -force
- Remove-Item $Folder
- }
+ CheckDependencies
+ DownloadDependencies
+ WriteVersionToRuntimeJson
- $LocalFile = Join-Path $WorkingDir $CefArm64FileName
+ Write-Diagnostic("CEF Version: $CefVersion")
+ Write-Diagnostic("Enabled Architectures")
- if (-not (Test-Path $LocalFile))
+ foreach($platform in $Platforms.Values)
+ {
+ if($platform.Enabled)
{
- Write-Diagnostic "Copy $CefArm64FileName (approx 200mb)"
- Copy-Item ($CefBuildDir+$CefArm64FileName) $LocalFile;
- Write-Diagnostic "Copy of $CefArm64FileName complete"
+ Write-Diagnostic("Arch: " + $platform.ArchLong)
}
+ }
- if (-not (Test-Path (Join-Path $CefArm64 '\include\cef_version.h')))
- {
- # Extract bzip file
- sz x $LocalFile;
-
- if ($Extension -eq "tar.bz2")
- {
- # Extract tar file
- $TarFile = ($LocalFile).Substring(0, $LocalFile.length - 4)
- sz x $TarFile
+ if($Target -eq "nupkg-only")
+ {
+ Nupkg
+ return;
+ }
- # Sleep for a short period to allow 7z to release it's file handles
- sleep -m 2000
+ Write-Diagnostic ("Deleting working folder $CefWorkingFolder")
- # Remove tar file
- Remove-Item $TarFile
- }
- $Folder = Join-Path $WorkingDir ($CefArm64FileName.Substring(0, $CefArm64FileName.length - ($Extension.Length+1)))
- Move-Item ($Folder + '\*') $CefArm64 -force
- Remove-Item $Folder
- }
- }
-
- function WriteVersionToRuntimeJson
+ if (Test-Path($CefWorkingFolder))
{
- $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)
+ Remove-Item $CefWorkingFolder -Recurse | Out-Null
}
- function CheckDependencies()
+ foreach ($platform in $Platforms.Values)
{
- # Check for cmake
- if ((Get-Command "cmake.exe" -ErrorAction SilentlyContinue) -eq $null)
+ if(!$platform.Enabled)
{
- Die "Unable to find cmake.exe in your PATH"
+ continue
}
- # Check for 7zip
- if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe"))
+ switch -Exact ($DownloadBinary)
{
- Die "$env:ProgramFiles\7-Zip\7z.exe is required"
+ "none"
+ {
+ }
+ "download"
+ {
+ DownloadCefBinaryAndUnzip $platform
+ }
+ "local"
+ {
+ CopyFromLocalCefBuild $platform
+ }
}
- }
- CheckDependencies
- WriteVersionToRuntimeJson
+ Bootstrap $platform
+ }
- switch -Exact ($DownloadBinary)
+ # 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)
{
- "none"
- {
- }
- "download"
+ # 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)
{
- DownloadCefBinaryAndUnzip
+ continue
}
- "local"
+
+ switch -Exact ($Target)
{
- CopyFromLocalCefBuild
+ "nupkg"
+ {
+ VSX v143 $platform
+ }
+ "vs2022"
+ {
+ VSX v143 $platform
+ }
+ "vs2019"
+ {
+ VSX v142 $platform
+ }
}
}
- DownloadNuget
-
- Bootstrap
-
- switch -Exact ($Target)
+ if($Target -eq "nupkg")
{
- "nupkg"
- {
- VSX v142
- Nupkg
- }
- "nupkg-only"
- {
- Nupkg
- }
- "vs2021"
- {
- VSX v143
- }
- "vs2019"
- {
- VSX v142
- }
+ Nupkg
}
}
catch
{
WriteException $_;
}
+finally
+{
+ Pop-Location
+}