Skip to content

Commit

Permalink
[webview2] New port of Microsoft.Web.WebView2 (#25217)
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft authored Jun 14, 2022
1 parent 3cca353 commit 8d2bff3
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 0 deletions.
55 changes: 55 additions & 0 deletions ports/webview2/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
if(VCPKG_TARGET_IS_UWP)
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
endif()

set(VERSION 1.0.1210.39)

vcpkg_download_distfile(ARCHIVE
URLS "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${VERSION}"
FILENAME "microsoft.web.webview2.${VERSION}.zip"
SHA512 c87812247a466f4aaeac8be8b32be49166b4ddb5bbf65581d5df81d69eda340e9911144a8dd8401baa6e51f95337001cd18ff90cd36ca0af86cc65227e8e2ccf
)

vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE "${ARCHIVE}"
REF "${VERSION}"
NO_REMOVE_ONE_LEVEL
)

file(COPY
"${SOURCE_PATH}/build/native/include/"
DESTINATION "${CURRENT_PACKAGES_DIR}/include")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(COPY
"${SOURCE_PATH}/build/native/${VCPKG_TARGET_ARCHITECTURE}/WebView2LoaderStatic.lib"
DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
else()
file(COPY
"${SOURCE_PATH}/build/native/include-winrt/"
DESTINATION "${CURRENT_PACKAGES_DIR}/include")
file(COPY
"${SOURCE_PATH}/lib/Microsoft.Web.WebView2.Core.winmd"
DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY
"${SOURCE_PATH}/build/native/${VCPKG_TARGET_ARCHITECTURE}/WebView2Loader.dll.lib"
DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(COPY
"${SOURCE_PATH}/build/native/${VCPKG_TARGET_ARCHITECTURE}/WebView2Loader.dll"
"${SOURCE_PATH}/runtimes/win-${VCPKG_TARGET_ARCHITECTURE}/native_uap/Microsoft.Web.WebView2.Core.dll"
DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
endif()
if(NOT VCPKG_BUILD_TYPE)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(COPY "${CURRENT_PACKAGES_DIR}/bin" DESTINATION "${CURRENT_PACKAGES_DIR}/debug")
endif()
file(COPY "${CURRENT_PACKAGES_DIR}/lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug")
endif()

file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-webview2-config.cmake"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-webview2")

# The import libraries for webview fail with "Could not find proper second linker member"
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

configure_file("${SOURCE_PATH}/LICENSE.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)
21 changes: 21 additions & 0 deletions ports/webview2/unofficial-webview2-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)

if(NOT TARGET unofficial::webview2::webview2)
if(EXISTS "${_IMPORT_PREFIX}/lib/WebView2LoaderStatic.lib")
add_library(unofficial::webview2::webview2 STATIC IMPORTED)
set_target_properties(unofficial::webview2::webview2
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
IMPORTED_LOCATION "${_IMPORT_PREFIX}/lib/WebView2LoaderStatic.lib")
else()
add_library(unofficial::webview2::webview2 SHARED IMPORTED)
set_target_properties(unofficial::webview2::webview2
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/WebView2Loader.dll"
IMPORTED_IMPLIB "${_IMPORT_PREFIX}/lib/WebView2Loader.dll.lib")
endif()
endif()

unset(_IMPORT_PREFIX)
12 changes: 12 additions & 0 deletions ports/webview2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "webview2",
"version": "1.0.1210.39",
"description": "The WebView2 control allows you to embed web technologies (HTML, CSS, and JavaScript) using Microsoft Edge",
"homepage": "https://docs.microsoft.com/en-us/microsoft-edge/webview2",
"documentation": "https://docs.microsoft.com/en-us/microsoft-edge/webview2",
"license": "BSD-3-Clause",
"supports": "windows & (x86 | x64 | arm64)",
"dependencies": [
"wil"
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7512,6 +7512,10 @@
"baseline": "0.8.2",
"port-version": 2
},
"webview2": {
"baseline": "1.0.1210.39",
"port-version": 0
},
"wepoll": {
"baseline": "1.5.8",
"port-version": 1
Expand Down
9 changes: 9 additions & 0 deletions versions/w-/webview2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "67a13efe8865489439c423563ee9fdaecf8baab1",
"version": "1.0.1210.39",
"port-version": 0
}
]
}

0 comments on commit 8d2bff3

Please sign in to comment.