diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..15614b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +.tools/* +cef/* +cef_binary_3.y.z_windows32/* +!cef_binary_3.y.z_windows32/.empty +cef_binary_3.y.z_windows64/* +!cef_binary_3.y.z_windows64/.empty + +*.nupkg +*.sdf +*.opensdf +*.suo +*.user +*.log +_ReSharper* +out +*Thumbs.db +*.bz2 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b69b142 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,29 @@ +// Copyright (c) 2008-2014 Marshall A. Greenblatt. Portions Copyright (c) +// 2006-2009 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/NuGet/cef.redist.nuspec b/NuGet/cef.redist.nuspec new file mode 100644 index 0000000..ea8e181 --- /dev/null +++ b/NuGet/cef.redist.nuspec @@ -0,0 +1,30 @@ + + + + cef.redist.$Platform$$DotConfiguration$ + $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 + https://raw.github.com/cefsharp/cef-binary/master/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-2015 + + + + + + + + + + + + diff --git a/NuGet/cef.redist.targets b/NuGet/cef.redist.targets new file mode 100644 index 0000000..49c3ac2 --- /dev/null +++ b/NuGet/cef.redist.targets @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NuGet/cef.sdk.nuspec b/NuGet/cef.sdk.nuspec new file mode 100644 index 0000000..1163288 --- /dev/null +++ b/NuGet/cef.sdk.nuspec @@ -0,0 +1,26 @@ + + + + cef.sdk + $version$ + CEF SDK + The CEF Authors + The CefSharp Authors + https://github.com/cefsharp/cef-binary + https://raw.github.com/cefsharp/cef-binary/master/NuGet/cef128x128.gif + https://raw.github.com/cefsharp/cef-binary/master/LICENSE.txt + false + CEF - 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-2015 + + + + + + + + diff --git a/NuGet/cef.sdk.props b/NuGet/cef.sdk.props new file mode 100644 index 0000000..d1f400c --- /dev/null +++ b/NuGet/cef.sdk.props @@ -0,0 +1,6 @@ + + + + cef.sdk.3.2924.1575 + + diff --git a/NuGet/cef128x128.gif b/NuGet/cef128x128.gif new file mode 100644 index 0000000..3908adf Binary files /dev/null and b/NuGet/cef128x128.gif differ diff --git a/NuGet/cef32x32.gif b/NuGet/cef32x32.gif new file mode 100644 index 0000000..b84a99f Binary files /dev/null and b/NuGet/cef32x32.gif differ diff --git a/README.md b/README.md index 8a43304..fb3f900 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,42 @@ -libcef-dll-wrapper -================== +# README -Personal fork of the libcef_dll_wrapper provided by Chromium which works better with CefSharp +This is a repackaging fork of the Chromium Embedded Framework (CEF) binary distribution files for Windows, found at http://www.magpcss.net/cef_downloads/ into [these NuGet packages](https://www.nuget.org/packages?q=Id%3A%22cef.redist%22%2C%22cef.sdk%22) + +To make it work properly for developers on VS2012 and VS2013 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. + +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 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 + + +# 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). + +Additionally, don't forget to view `chrome://credits/` for additional licences used by Chromium. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..846c82a --- /dev/null +++ b/README.txt @@ -0,0 +1,137 @@ +Chromium Embedded Framework (CEF) Standard Binary Distribution for Windows +------------------------------------------------------------------------------- + +Date: August 18, 2016 + +CEF Version: 3.2743.1447.g37d988b +CEF URL: https://bitbucket.org/chromiumembedded/cef.git + @37d988bda8bdff39f538ace426040faab1599b58 + +Chromium Verison: 52.0.2743.116 +Chromium URL: https://chromium.googlesource.com/chromium/src.git + @feb0ea45a0164eef52aa2631dd95d7c85fa65faa + +This distribution contains all components necessary to build and distribute an +application using CEF on the Windows platform. Please see the LICENSING +section of this document for licensing terms and conditions. + + +CONTENTS +-------- + +cefclient Contains the cefclient sample application configured to build + using the files in this distribution. This application demonstrates + a wide range of CEF functionalities. + +cefsimple Contains the cefsimple sample application configured to build + using the files in this distribution. This application demonstrates + the minimal functionality required to create a browser window. + +cmake Contains CMake configuration files shared by all targets. + +Debug Contains libcef.dll, libcef.lib and other components required to + build and run the debug version of CEF-based applications. By + default these files should be placed in the same directory as the + executable and will be copied there as part of the build process. + +include Contains all required CEF header files. + +libcef_dll Contains the source code for the libcef_dll_wrapper static library + that all applications using the CEF C++ API must link against. + +Release Contains libcef.dll, libcef.lib and other components required to + build and run the release version of CEF-based applications. By + default these files should be placed in the same directory as the + executable and will be copied there as part of the build process. + +Resources Contains resources required by libcef.dll. By default these files + should be placed in the same directory as libcef.dll and will be + copied there as part of the build process. + + +USAGE +----- + +Building using CMake: + CMake can be used to generate project files in many different formats. See + usage instructions at the top of the CMakeLists.txt file. + +Please visit the CEF Website for additional usage information. + +https://bitbucket.org/chromiumembedded/cef/ + + +REDISTRIBUTION +-------------- + +This binary distribution contains the below components. + +Required components: + +The following components are required. CEF will not function without them. + +* CEF core library. + * libcef.dll + +* Unicode support data. + * icudtl.dat + +* V8 snapshot data. + * natives_blob.bin + * snapshot_blob.bin + +Optional components: + +The following components are optional. If they are missing CEF will continue to +run but any related functionality may become broken or disabled. + +* Localized resources. + Locale file loading can be disabled completely using + CefSettings.pack_loading_disabled. The locales directory path can be + customized using CefSettings.locales_dir_path. + + * locales/ + Directory containing localized resources used by CEF, Chromium and Blink. A + .pak file is loaded from this directory based on the CefSettings.locale + value. Only configured locales need to be distributed. If no locale is + configured the default locale of "en-US" will be used. Without these files + arbitrary Web components may display incorrectly. + +* Other resources. + Pack file loading can be disabled completely using + CefSettings.pack_loading_disabled. The resources directory path can be + customized using CefSettings.resources_dir_path. + + * cef.pak + * cef_100_percent.pak + * cef_200_percent.pak + These files contain non-localized resources used by CEF, Chromium and Blink. + Without these files arbitrary Web components may display incorrectly. + + * cef_extensions.pak + This file contains non-localized resources required for extension loading. + Pass the `--disable-extensions` command-line flag to disable use of this + file. Without this file components that depend on the extension system, + such as the PDF viewer, will not function. + + * devtools_resources.pak + This file contains non-localized resources required for Chrome Developer + Tools. Without this file Chrome Developer Tools will not function. + +* Angle and Direct3D support. + * d3dcompiler_43.dll (required for Windows XP) + * d3dcompiler_47.dll (required for Windows Vista and newer) + * libEGL.dll + * libGLESv2.dll + Without these files HTML5 accelerated content like 2D canvas, 3D CSS and WebGL + will not function. + + +LICENSING +--------- + +The CEF project is BSD licensed. Please read the LICENSE.txt file included with +this binary distribution for licensing terms and conditions. Other software +included in this distribution is provided under other licenses. Please visit +"about:credits" in a CEF-based application for complete Chromium and third-party +licensing information. diff --git a/Tools/vswhere.exe b/Tools/vswhere.exe new file mode 100644 index 0000000..3ddcc9c Binary files /dev/null and b/Tools/vswhere.exe differ diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..b4720a2 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,30 @@ +environment: + VisualStudioVersion: 12.0 + +version: 53.0.0-CI{build} + +shallow_clone: true + +# Start builds on tags only (GitHub and BitBucket) +skip_non_tags: true + +# to run your custom scripts instead of automatic MSBuild +build_script: + - ps: .\build.ps1 + +# Disable tests +test: off + +artifacts: + - path: NuGet\*.nupkg + name: nupkgfiles + +# Publish to myget.org feed +deploy: + provider: NuGet + server: https://www.myget.org/F/cefsharp/api/v2/package + api_key: + secure: uftPtLACVpFbbbFBeFK6XD5fGkv33c+Xa3PWkyWgrod6FNl4AYGOtxScn+gsuuxD + skip_symbols: false + symbol_server: https://www.myget.org/F/cefsharp/api/v2/package + artifact: nupkgfiles \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..1c603e3 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,617 @@ +#requires -Version 3 + +param( + [ValidateSet("vs2012", "vs2013", "vs2015", "vs2017", "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 = "3.2924.1575.g97389a9" +) + +$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition + +$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' + +# Take the cef version and strip the commit hash +$CefPackageVersion = $CefVersion.SubString(0, $CefVersion.LastIndexOf('.')) + +# 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 + + Get-Content $tempFile | Foreach-Object { + if ($_ -match "^(.*?)=(.*)$") + { + Set-Content "env:\$($matches[1])" $matches[2] + } + } + Remove-Item $tempFile + Remove-Item $batFile +} + +function Write-Diagnostic +{ + param( + [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] + [string] $Message + ) + + Write-Host + Write-Host $Message -ForegroundColor Green + Write-Host +} + +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 TernaryReturn +{ + param( + [Parameter(Position = 0, ValueFromPipeline = $true)] + [bool] $Yes, + [Parameter(Position = 1, ValueFromPipeline = $true)] + $Value, + [Parameter(Position = 2, ValueFromPipeline = $true)] + $Value2 + ) + + if($Yes) { + return $Value + } + + $Value2 + +} + +function Bootstrap +{ + param() + + if($Target -eq "nupkg-only") { + return + } + + Write-Diagnostic "Bootstrapping" + + if (Test-Path($Cef)) { + Remove-Item $Cef -Recurse | Out-Null + } + + # 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\VS2012' | Out-Null + md 'cef\win32\debug\VS2013' | Out-Null + md 'cef\win32\debug\VS2015' | Out-Null + md 'cef\win32\debug\VS2017' | Out-Null + md 'cef\win32\release' | Out-Null + md 'cef\win32\release\VS2012' | Out-Null + md 'cef\win32\release\VS2013' | Out-Null + md 'cef\win32\release\VS2015' | Out-Null + md 'cef\win32\release\VS2017' | Out-Null + md 'cef\x64' | Out-Null + md 'cef\x64\debug' | Out-Null + md 'cef\x64\debug\VS2012' | Out-Null + md 'cef\x64\debug\VS2013' | Out-Null + md 'cef\x64\debug\VS2015' | Out-Null + md 'cef\x64\debug\VS2017' | Out-Null + md 'cef\x64\release' | Out-Null + md 'cef\x64\release\VS2012' | Out-Null + md 'cef\x64\release\VS2013' | Out-Null + md 'cef\x64\release\VS2015' | Out-Null + md 'cef\x64\release\VS2017' | Out-Null + +} + +function Msvs +{ + param( + [ValidateSet('v110', 'v120', 'v140', 'v141')] + [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')] + [string] $Platform + ) + + Write-Diagnostic "Targeting $Toolchain using configuration $Configuration on platform $Platform" + + $PlatformTarget = $null + $VisualStudioVersion = $null + $VXXCommonTools = $null + $CmakeGenerator = $null + + # https://github.com/Microsoft/vswhere/commit/a8c90e3218d6c4774f196d0400a8805038aa13b1 (Release mode / VS 2015 Update 3) + # SHA512: 06FAE35E3A5B74A5B0971FB19EE0987E15E413558C620AB66FB3188F6BF1C790919E8B163596744D126B3716D0E91C65F7C1325F5752614078E6B63E7C81D681 + $wswhere = Join-Path $WorkingDir Tools\vswhere + + switch -Exact ($Toolchain) { + 'v110' { + $PlatformTarget = '4.0' + $VisualStudioVersion = '11.0' + $VXXCommonTools = Join-Path $env:VS110COMNTOOLS '..\..\vc' + $CmakeGenerator = 'Visual Studio 11' + } + 'v120' { + $PlatformTarget = '12.0' + $VisualStudioVersion = '12.0' + $VXXCommonTools = Join-Path $env:VS120COMNTOOLS '..\..\vc' + $CmakeGenerator = 'Visual Studio 12' + } + 'v140' { + $PlatformTarget = '4.0' + $VisualStudioVersion = '14.0' + $VXXCommonTools = Join-Path $env:VS140COMNTOOLS '..\..\vc' + $CmakeGenerator = 'Visual Studio 14' + } + 'v141' { + $Ids = 'Community', 'Professional', 'Enterprise', 'BuildTools' | foreach { 'Microsoft.VisualStudio.Product.' + $_ } + $Instance = & $wswhere -version 15 -products $ids -requires 'Microsoft.Component.MSBuild' -format json ` + | convertfrom-json ` + | select-object -first 1 + + if($Instance -eq $null) { + Die "Visual Studio 2017 was not found" + } + + $PlatformTarget = '12.0' + $VisualStudioVersion = '15.0' + $VXXCommonTools = Join-Path $Instance.installationPath VC\Auxiliary\Build + $CmakeGenerator = 'Visual Studio 15' + + } + } + + if ($VXXCommonTools -eq $null -or (-not (Test-Path($VXXCommonTools)))) { + Die 'Error unable to find any visual studio environment' + } + + $CefProject = TernaryReturn ($Platform -eq 'x86') $Cef32vcx $Cef64vcx + $CefDir = TernaryReturn ($Platform -eq 'x86') $Cef32 $Cef64 + + $Arch = TernaryReturn ($Platform -eq 'x64') 'x64' 'win32' + $CmakeArch = TernaryReturn ($Platform -eq 'x64') ' Win64' '' + + $VCVarsAll = Join-Path $VXXCommonTools vcvarsall.bat + if (-not (Test-Path $VCVarsAll)) { + Die "Unable to find $VCVarsAll" + } + + $VCXProj = $Cef32vcx + if($Platform -eq 'x64') { + $VCXProj = $Cef64vcx + } + + # Only configure build environment once + if ($env:CEFSHARP_BUILD_IS_BOOTSTRAPPED -ne "$Toolchain$Platform") { + Invoke-BatchFile $VCVarsAll $Platform + pushd $CefDir + # Remove previously generated CMake data for the different platform/toolchain + rm CMakeCache.txt -ErrorAction:SilentlyContinue + rm -r CMakeFiles -ErrorAction:SilentlyContinue + cmake -G "$CmakeGenerator$CmakeArch" -DUSE_SANDBOX=Off + popd + $env:CEFSHARP_BUILD_IS_BOOTSTRAPPED = "$Toolchain$Platform" + } + + #Manually change project file to compile using /MDd and /MD + (Get-Content $CefProject) | Foreach-Object {$_ -replace "MultiThreadedDebug", 'MultiThreadedDebugDLL'} | Set-Content $CefProject + (Get-Content $CefProject) | Foreach-Object {$_ -replace "MultiThreaded", 'MultiThreadedDLL'} | Set-Content $CefProject + + $Arguments = @( + "$CefProject", + "/t:rebuild", + "/p:VisualStudioVersion=$VisualStudioVersion", + "/p:Configuration=$Configuration", + "/p:PlatformTarget=$PlatformTarget", + "/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() + + Get-ChildItem -Path env:* | ForEach-Object { + $StartInfo.EnvironmentVariables.Add($_.Name, $_.Value) + } + + $StartInfo.UseShellExecute = $false + $StartInfo.CreateNoWindow = $false + + $Process = New-Object System.Diagnostics.Process + $Process.StartInfo = $startInfo + $Process.Start() + $Process.WaitForExit() + + if($Process.ExitCode -ne 0) { + Die "Build failed" + } + + CreateCefSdk $Toolchain $Configuration $Platform +} + +function VSX +{ + param( + [ValidateSet('v110', 'v120', 'v140', 'v141')] + [Parameter(Position = 0, ValueFromPipeline = $true)] + [string] $Toolchain + ) + + if($Toolchain -eq 'v110' -and $env:VS110COMNTOOLS -eq $null) { + Warn "Toolchain $Toolchain is not installed on your development machine, skipping build." + Return + } + + if($Toolchain -eq 'v120' -and $env:VS120COMNTOOLS -eq $null) { + Warn "Toolchain $Toolchain is not installed on your development machine, skipping build." + Return + } + + if($Toolchain -eq 'v140' -and $env:VS140COMNTOOLS -eq $null) { + Warn "Toolchain $Toolchain is not installed on your development machine, skipping build." + Return + } + + if($Toolchain -eq 'v141' -and $env:VS150COMNTOOLS -eq $null) { + Warn "Toolchain $Toolchain is not installed on your development machine, skipping build." + Return + } + + Write-Diagnostic "Starting to build targeting toolchain $Toolchain" + + Msvs "$Toolchain" 'Debug' 'x86' + Msvs "$Toolchain" 'Release' 'x86' + Msvs "$Toolchain" 'Debug' 'x64' + Msvs "$Toolchain" 'Release' 'x64' + + Write-Diagnostic "Finished build targeting toolchain $Toolchain" +} + +function CreateCefSdk +{ + param( + [ValidateSet('v110', 'v120', 'v140', 'v141')] + [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')] + [string] $Platform + ) + + Write-Diagnostic "Creating sdk for $Toolchain" + + $VisualStudioVersion = $null + if($Toolchain -eq "v141") { + $VisualStudioVersion = "VS2017" + } elseif($Toolchain -eq "v140") { + $VisualStudioVersion = "VS2015" + } elseif($Toolchain -eq "v110") { + $VisualStudioVersion = "VS2012" + } else { + $VisualStudioVersion = "VS2013" + } + + $Arch = TernaryReturn ($Platform -eq 'x64') 'x64' 'win32' + $CefArchDir = TernaryReturn ($Platform -eq 'x64') $Cef64 $Cef32 + + # cef_binary_3.y.z_windows32\out\debug\lib -> cef\win32\debug\vs2013 + Copy-Item $CefArchDir\libcef_dll_wrapper\$Configuration\libcef_dll_wrapper.lib $Cef\$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 +} + +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" + } + + # Build 32bit packages + #. $Nuget pack nuget\cef.redist.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Debug;DotConfiguration=.Debug;Platform=x86;CPlatform=windows32;' -OutputDirectory nuget + . $Nuget pack nuget\cef.redist.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;DotConfiguration=;Platform=x86;CPlatform=windows32;' -OutputDirectory nuget + + # Build 64bit packages + #. $Nuget pack nuget\cef.redist.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Debug;DotConfiguration=.Debug;Platform=x64;CPlatform=windows64;' -OutputDirectory nuget + . $Nuget pack nuget\cef.redist.nuspec -NoPackageAnalysis -Version $CefPackageVersion -Properties 'Configuration=Release;DotConfiguration=;Platform=x64;CPlatform=windows64;' -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) + + . $Nuget pack nuget\cef.sdk.nuspec -NoPackageAnalysis -Version $CefPackageVersion -OutputDirectory nuget +} + +function DownloadNuget() +{ + $Nuget = Join-Path $env:LOCALAPPDATA .\nuget\NuGet.exe + if(-not (Test-Path $Nuget)) + { + $Client = New-Object System.Net.WebClient; + $Client.DownloadFile('http://nuget.org/nuget.exe', $Nuget); + } +} + +function DownloadCefBinaryAndUnzip() +{ + $Client = New-Object System.Net.WebClient; + + $CefBuildServerUrl = "http://opensource.spotify.com/cefbuilds/" + $CefBuildServerJsonPackageList = $CefBuildServerUrl + "index.json" + + $CefBuildsJson = Invoke-WebRequest -Uri $CefBuildServerJsonPackageList | ConvertFrom-Json + $CefWin32CefVersion = $CefBuildsJson.windows32.versions | Where-Object {$_.cef_version -eq $CefVersion} + $CefWin64CefVersion = $CefBuildsJson.windows64.versions | Where-Object {$_.cef_version -eq $CefVersion} + + $Cef32FileName = ($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).name + $Cef64FileName = ($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).name + + # 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' + } + + set-alias sz "$env:ProgramFiles\7-Zip\7z.exe" + + $LocalFile = Join-Path $WorkingDir $Cef32FileName + + if(-not (Test-Path $LocalFile)) + { + Write-Diagnostic "Download $Cef32FileName this will take a while as files are approx 200mb each" + $Client.DownloadFile($CefBuildServerUrl + $Cef32FileName, $LocalFile); + Write-Diagnostic "Download $Cef32FileName complete" + } + + if(-not (Test-Path (Join-Path $Cef32 '\include\cef_version.h'))) + { + # 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 ($Cef32FileName.Substring(0, $Cef32FileName.length - 8)) + Move-Item ($Folder + '\*') $Cef32 -force + Remove-Item $Folder + } + + $LocalFile = Join-Path $WorkingDir $Cef64FileName + + if(-not (Test-Path $LocalFile)) + { + + Write-Diagnostic "Download $Cef64FileName this will take a while as files are approx 200mb each" + $Client.DownloadFile($CefBuildServerUrl + $Cef64FileName, $LocalFile); + Write-Diagnostic "Download $Cef64FileName complete" + } + + if(-not (Test-Path (Join-Path $Cef64 '\include\cef_version.h'))) + { + # 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 + } +} + +function CopyFromLocalCefBuild() +{ + # 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 + + Write-Host $CefVersion + + $Cef32FileName = "cef_binary_$($CefVersion)_windows32.tar.bz2" + $Cef64FileName = "cef_binary_$($CefVersion)_windows64.tar.bz2" + + set-alias sz "$env:ProgramFiles\7-Zip\7z.exe" + + if ([System.IO.Path]::IsPathRooted($CefBinaryDir)) + { + $CefBuildDir = $CefBinaryDir + } + else + { + $CefBuildDir = 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'))) + { + # 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 ($Cef32FileName.Substring(0, $Cef32FileName.length - 8)) + 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" + } + + if(-not (Test-Path (Join-Path $Cef64 '\include\cef_version.h'))) + { + # 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 + } +} + +function CheckDependencies() +{ + #Check for cmake + if ((Get-Command "cmake.exe" -ErrorAction SilentlyContinue) -eq $null) + { + 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" + } +} + +CheckDependencies + +switch -Exact ($DownloadBinary) +{ + "none" { + } + "download" + { + DownloadCefBinaryAndUnzip + } + "local" + { + CopyFromLocalCefBuild + } +} + +DownloadNuget + +Bootstrap + +switch -Exact ($Target) { + "nupkg" { + #VSX v110 + VSX v120 + VSX v140 + VSX v141 + Nupkg + } + "nupkg-only" { + Nupkg + } + "vs2013" { + VSX v120 + } + "vs2012" { + VSX v110 + } + "vs2015" { + VSX v140 + } + "vs2017" { + VSX v141 + } +} diff --git a/cef_binary_3.y.z_windows32/.empty b/cef_binary_3.y.z_windows32/.empty new file mode 100644 index 0000000..e69de29 diff --git a/cef_binary_3.y.z_windows64/.empty b/cef_binary_3.y.z_windows64/.empty new file mode 100644 index 0000000..e69de29