diff --git a/build/bakefiles/multilib.bkl b/build/bakefiles/multilib.bkl index bdd73265b2..8627d538b7 100644 --- a/build/bakefiles/multilib.bkl +++ b/build/bakefiles/multilib.bkl @@ -184,6 +184,22 @@ $(TOP_SRCDIR)include/wx/msw/wrl + + x64 + x64 + arm64 + arm64 + x64 + x64 + x86 + x86 + x86 + + + + $(TOP_SRCDIR)3rdparty/webview2/build/native/$(webview_additional_libdirs_arch) + + -Wno-unknown-pragmas @@ -195,6 +211,7 @@ $(WEBVIEW_SRC) coredll basedll + $(webview_additional_libdirs) $(EXTRALIBS_WEBVIEW) $(WEBVIEW_HDR) $(webview_additional_include_wrl) @@ -208,6 +225,7 @@ $(WEBVIEW_HDR) $(webview_additional_include_wrl) $(webview_additional_include) + $(webview_additional_libdirs) $(webview_edge_pragma_warning) diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 70e8dcdb79..024475eb3f 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -87,7 +87,12 @@ elseif(WXMSW) endif() endif() - wx_webview_copy_webview2_loader(wxwebview) + if (wxUSE_WEBVIEW_EDGE_STATIC) + target_link_directories(wxwebview PUBLIC "${WEBVIEW2_PACKAGE_DIR}/build/native/$(LibrariesArchitecture)/") + else() + wx_webview_copy_webview2_loader(wxwebview) + endif() + endif() elseif(WXGTK) if(LIBSOUP_FOUND) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 241aa4bed1..70193f755d 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -477,6 +477,7 @@ if(WIN32) wx_option(wxUSE_TASKBARICON_BALLOONS "enable wxTaskBarIcon::ShowBalloon() method (Win32 only)") wx_option(wxUSE_UXTHEME "enable support for Windows XP themed look (Win32 only)") wx_option(wxUSE_WEBVIEW_EDGE "use wxWebView Edge (Chromium) backend (Windows 7+ only)" ${wxUSE_WEBVIEW_EDGE_DEFAULT}) + wx_option(wxUSE_WEBVIEW_EDGE_STATIC "use wxWebView Edge with static loader" OFF) wx_option(wxUSE_WEBVIEW_IE "use wxWebView IE backend (Win32 only)") wx_option(wxUSE_WINRT "enable WinRT support" ${wxUSE_WINRT_DEFAULT}) wx_option(wxUSE_WXDIB "use wxDIB class (Win32 only)") diff --git a/build/cmake/setup.h.in b/build/cmake/setup.h.in index 496fa988ee..42ab868fa8 100644 --- a/build/cmake/setup.h.in +++ b/build/cmake/setup.h.in @@ -332,6 +332,8 @@ #cmakedefine01 wxUSE_WEBVIEW_EDGE +#cmakedefine01 wxUSE_WEBVIEW_EDGE_STATIC + #if (defined(__WXGTK__) && !defined(__WXGTK3__)) || defined(__WXOSX__) #cmakedefine01 wxUSE_WEBVIEW_WEBKIT #else diff --git a/build/msw/wx_webview.vcxproj b/build/msw/wx_webview.vcxproj index 2e651b9927..1a0a5c6041 100644 --- a/build/msw/wx_webview.vcxproj +++ b/build/msw/wx_webview.vcxproj @@ -350,7 +350,7 @@ wxtiff$(wxSuffixDebug).lib;wxjpeg$(wxSuffixDebug).lib;wxpng$(wxSuffixDebug).lib;wxzlib$(wxSuffixDebug).lib;wxregex$(wxSuffix).lib;wxexpat$(wxSuffixDebug).lib;$(wxToolkitLibNamePrefix)core.lib;$(wxBaseLibNamePrefix).lib;%(AdditionalDependencies) $(OutDir)$(wxToolkitLibNamePrefix)$(ProjectName).lib true - $(OutDir);%(AdditionalLibraryDirectories) + $(OutDir);..\..\3rdparty\webview2\build\native\$(LibrariesArchitecture);%(AdditionalLibraryDirectories) true @@ -435,7 +435,7 @@ wxtiff$(wxSuffixDebug).lib;wxjpeg$(wxSuffixDebug).lib;wxpng$(wxSuffixDebug).lib;wxzlib$(wxSuffixDebug).lib;wxregex$(wxSuffix).lib;wxexpat$(wxSuffixDebug).lib;$(wxToolkitLibNamePrefix)core.lib;$(wxBaseLibNamePrefix).lib;%(AdditionalDependencies) $(OutDir)$(wxToolkitLibNamePrefix)$(ProjectName).lib true - $(OutDir);%(AdditionalLibraryDirectories) + $(OutDir);..\..\3rdparty\webview2\build\native\$(LibrariesArchitecture);%(AdditionalLibraryDirectories) false true true diff --git a/include/wx/android/setup.h b/include/wx/android/setup.h index d3af98775a..3ecdb97159 100644 --- a/include/wx/android/setup.h +++ b/include/wx/android/setup.h @@ -802,6 +802,13 @@ // Recommended setting: 1 when building for Windows with WebView2 SDK #define wxUSE_WEBVIEW_EDGE 0 +// Use the Edge (Chromium) wxWebView backend without loader DLL +// +// Default is 0, set it to 1 if you don't want to depend on WebView2Loader.dll. +// +// Recommended setting: 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + // Use the WebKit wxWebView backend // // Default is 1 on GTK and OSX diff --git a/include/wx/gtk/setup.h b/include/wx/gtk/setup.h index 99e7b70aba..88200afd17 100644 --- a/include/wx/gtk/setup.h +++ b/include/wx/gtk/setup.h @@ -803,6 +803,13 @@ // Recommended setting: 1 when building for Windows with WebView2 SDK #define wxUSE_WEBVIEW_EDGE 0 +// Use the Edge (Chromium) wxWebView backend without loader DLL +// +// Default is 0, set it to 1 if you don't want to depend on WebView2Loader.dll. +// +// Recommended setting: 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + // Use the WebKit wxWebView backend // // Default is 1 on GTK and OSX diff --git a/include/wx/motif/setup.h b/include/wx/motif/setup.h index 9d19b8096d..d661e9f9c5 100644 --- a/include/wx/motif/setup.h +++ b/include/wx/motif/setup.h @@ -803,6 +803,13 @@ // Recommended setting: 1 when building for Windows with WebView2 SDK #define wxUSE_WEBVIEW_EDGE 0 +// Use the Edge (Chromium) wxWebView backend without loader DLL +// +// Default is 0, set it to 1 if you don't want to depend on WebView2Loader.dll. +// +// Recommended setting: 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + // Use the WebKit wxWebView backend // // Default is 1 on GTK and OSX diff --git a/include/wx/msw/private/webview_edge.h b/include/wx/msw/private/webview_edge.h index 3e633adaf1..ec497f0e77 100644 --- a/include/wx/msw/private/webview_edge.h +++ b/include/wx/msw/private/webview_edge.h @@ -10,7 +10,9 @@ #ifndef wxWebViewEdge_PRIVATE_H #define wxWebViewEdge_PRIVATE_H +#if !wxUSE_WEBVIEW_EDGE_STATIC #include "wx/dynlib.h" +#endif #include "wx/msw/private/comptr.h" #include @@ -98,7 +100,9 @@ public: void UpdateWebMessageHandler(); +#if !wxUSE_WEBVIEW_EDGE_STATIC static wxDynamicLibrary ms_loaderDll; +#endif static wxString ms_browserExecutableDir; static bool Initialize(); diff --git a/include/wx/osx/setup.h b/include/wx/osx/setup.h index 7a47b59efe..8de661716d 100644 --- a/include/wx/osx/setup.h +++ b/include/wx/osx/setup.h @@ -809,6 +809,13 @@ // Recommended setting: 1 when building for Windows with WebView2 SDK #define wxUSE_WEBVIEW_EDGE 0 +// Use the Edge (Chromium) wxWebView backend without loader DLL +// +// Default is 0, set it to 1 if you don't want to depend on WebView2Loader.dll. +// +// Recommended setting: 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + // Use the WebKit wxWebView backend // // Default is 1 on GTK and OSX diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index ba6cf686bc..27c15fc3ae 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -799,6 +799,13 @@ // Recommended setting: 1 when building for Windows with WebView2 SDK #define wxUSE_WEBVIEW_EDGE 0 +// Use the Edge (Chromium) wxWebView backend without loader DLL +// +// Default is 0, set it to 1 if you don't want to depend on WebView2Loader.dll. +// +// Recommended setting: 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + // Use the WebKit wxWebView backend // // Default is 1 on GTK and OSX diff --git a/include/wx/univ/setup.h b/include/wx/univ/setup.h index d8a463d78e..b8d760e012 100644 --- a/include/wx/univ/setup.h +++ b/include/wx/univ/setup.h @@ -802,6 +802,13 @@ // Recommended setting: 1 when building for Windows with WebView2 SDK #define wxUSE_WEBVIEW_EDGE 0 +// Use the Edge (Chromium) wxWebView backend without loader DLL +// +// Default is 0, set it to 1 if you don't want to depend on WebView2Loader.dll. +// +// Recommended setting: 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + // Use the WebKit wxWebView backend // // Default is 1 on GTK and OSX diff --git a/interface/wx/webview.h b/interface/wx/webview.h index 2c13aa4588..03ffa1150f 100644 --- a/interface/wx/webview.h +++ b/interface/wx/webview.h @@ -362,6 +362,9 @@ public: loaded and Edge (Chromium) is installed) - Make sure to add a note about using the WebView2 SDK to your application documentation, as required by its licence + - With Visual Studio 2019 or newer @c wxUSE_WEBVIEW_EDGE_STATIC can be used + to static link the loader and remove the dependency on @c WebView2Loader.dll + at runtime. If enabled and available at runtime Edge will be selected as the default backend. If you require the IE backend use @c wxWebViewBackendIE when diff --git a/setup.h.in b/setup.h.in index 3e3f576193..8d90ffcc16 100644 --- a/setup.h.in +++ b/setup.h.in @@ -332,6 +332,8 @@ #define wxUSE_WEBVIEW_EDGE 0 +#define wxUSE_WEBVIEW_EDGE_STATIC 0 + #if (defined(__WXGTK__) && !defined(__WXGTK3__)) || defined(__WXOSX__) #define wxUSE_WEBVIEW_WEBKIT 0 #else diff --git a/src/msw/webview_edge.cpp b/src/msw/webview_edge.cpp index b6c8bed70b..7afc2189ec 100644 --- a/src/msw/webview_edge.cpp +++ b/src/msw/webview_edge.cpp @@ -42,6 +42,13 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewEdge, wxWebView); event.SetInt(wxerror); \ break; +#if wxUSE_WEBVIEW_EDGE_STATIC + #define wxCreateCoreWebView2EnvironmentWithOptions ::CreateCoreWebView2EnvironmentWithOptions + #define wxGetAvailableCoreWebView2BrowserVersionString ::GetAvailableCoreWebView2BrowserVersionString + + // Automatically link the static loader lib with MSVC + #pragma comment(lib, "WebView2LoaderStatic") +#else // WebView2Loader typedefs typedef HRESULT (__stdcall *CreateCoreWebView2EnvironmentWithOptions_t)( PCWSTR browserExecutableFolder, @@ -54,8 +61,9 @@ typedef HRESULT(__stdcall *GetAvailableCoreWebView2BrowserVersionString_t)( CreateCoreWebView2EnvironmentWithOptions_t wxCreateCoreWebView2EnvironmentWithOptions = NULL; GetAvailableCoreWebView2BrowserVersionString_t wxGetAvailableCoreWebView2BrowserVersionString = NULL; - wxDynamicLibrary wxWebViewEdgeImpl::ms_loaderDll; +#endif // wxUSE_WEBVIEW_EDGE_STATIC + wxString wxWebViewEdgeImpl::ms_browserExecutableDir; wxWebViewEdgeImpl::wxWebViewEdgeImpl(wxWebViewEdge* webview): @@ -132,6 +140,7 @@ HRESULT wxWebViewEdgeImpl::OnEnvironmentCreated( bool wxWebViewEdgeImpl::Initialize() { +#if !wxUSE_WEBVIEW_EDGE_STATIC if (ms_loaderDll.IsLoaded()) return true; @@ -144,7 +153,7 @@ bool wxWebViewEdgeImpl::Initialize() wxDL_INIT_FUNC(wx, GetAvailableCoreWebView2BrowserVersionString, loaderDll); if (!wxGetAvailableCoreWebView2BrowserVersionString || !wxCreateCoreWebView2EnvironmentWithOptions) return false; - +#endif // Check if a Edge browser can be found by the loader DLL wxCoTaskMemPtr versionStr; HRESULT hr = wxGetAvailableCoreWebView2BrowserVersionString( @@ -155,14 +164,18 @@ bool wxWebViewEdgeImpl::Initialize() return false; } +#if !wxUSE_WEBVIEW_EDGE_STATIC ms_loaderDll.Attach(loaderDll.Detach()); +#endif return true; } void wxWebViewEdgeImpl::Uninitialize() { +#if !wxUSE_WEBVIEW_EDGE_STATIC ms_loaderDll.Unload(); +#endif } void wxWebViewEdgeImpl::UpdateBounds()