summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2021-03-23 10:58:26 +0100
committerMichal Klocek <michal.klocek@qt.io>2021-05-22 14:10:19 +0200
commite6a7c6548f15cb158c1a5a2ac97fadaecb54f1ee (patch)
tree7d50d6df4904590e6fa2edafd78ffb8ac439d2e8 /src
parent6d6037be24bcbff5efada34ed39331c7c8b28f3b (diff)
Add windows to the cmake build
Fix cmake for windows builds and add QtWebEngineSandbox target. Task-number: QTBUG-91760 Change-Id: If962a81ddfb509d104ad8ffbfbf34f1150ae82ce Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt49
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp13
-rw-r--r--src/core/api/qtwebenginecoreglobal_p.h12
-rw-r--r--src/core/configure/BUILD.root.gn.in12
-rw-r--r--src/core/process_main.cpp9
-rw-r--r--src/core/qtwebengine.gni2
-rw-r--r--src/core/sandbox_win.cpp (renamed from src/core/process_main.h)57
-rw-r--r--src/core/web_engine_context.cpp14
-rw-r--r--src/core/web_engine_context.h4
-rw-r--r--src/gn/CMakeLists.txt7
-rw-r--r--src/process/CMakeLists.txt5
-rw-r--r--src/process/QtWebEngineProcess.exe.manifest (renamed from src/process/process.exe.manifest)0
-rw-r--r--src/process/main.cpp14
-rw-r--r--src/process/support_win.cpp44
14 files changed, 142 insertions, 100 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index dc478ca05..f3479d193 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -125,7 +125,7 @@ foreach(config ${configs})
permission_manager_qt.cpp permission_manager_qt.h
platform_notification_service_qt.cpp platform_notification_service_qt.h
pref_service_adapter.cpp pref_service_adapter.h
- process_main.cpp process_main.h
+ process_main.cpp
profile_adapter.cpp profile_adapter.h
profile_adapter_client.cpp profile_adapter_client.h
profile_io_data_qt.cpp profile_io_data_qt.h
@@ -479,6 +479,25 @@ foreach(config ${configs})
)
endif()
+ if(WIN32)
+ get_filename_component(windowsSdkPath $ENV{WINDOWSSDKDIR} DIRECTORY)
+ get_filename_component(visualStudioPath $ENV{VSINSTALLDIR} DIRECTORY)
+ list(APPEND gnArgArg
+ use_sysroot=false
+ enable_session_service=false
+ ninja_use_custom_environment_files=false
+ win_linker_timing=true
+ com_init_check_hook_disabled=true
+ heterogeneous_executables=true
+ enable_vr=false
+ use_incremental_linking=false
+ visual_studio_version=2019
+ visual_studio_path=\"${visualStudioPath}\"
+ windows_sdk_path=\"${windowsSdkPath}\"
+ target_cpu="x64"
+ )
+ endif()
+
list(JOIN gnArgArg " " gnArgArg)
list(APPEND gnArg "--args=${gnArgArg}")
@@ -509,19 +528,27 @@ endforeach()
# NINJA CALL
##
+if(WIN32)
+ set(sandboxOutput QtWebEngineCoreSandbox.lib)
+ set(sandboxTarget QtWebEngineCoreSandbox)
+else()
+ unset(sandboxOutput)
+ unset(sandboxTarget)
+endif()
+
add_custom_command(
- OUTPUT QtWebEngineCore.stamp
+ OUTPUT QtWebEngineCore.stamp ${sandboxOutput}
WORKING_DIRECTORY ${buildDir}/$<CONFIG>
COMMAND Ninja::ninja
$ENV{NINJAFLAGS}
-C ${buildDir}/$<CONFIG>
- QtWebEngineCore
+ QtWebEngineCore ${sandboxTarget}
USES_TERMINAL
VERBATIM
COMMAND_EXPAND_LISTS
)
-add_custom_target(ninja DEPENDS QtWebEngineCore.stamp)
+add_custom_target(ninja DEPENDS QtWebEngineCore.stamp ${sandboxOutput})
##
# WEBENGINECORE SETUP
@@ -530,8 +557,14 @@ add_custom_target(ninja DEPENDS QtWebEngineCore.stamp)
add_dependencies(WebEngineCore ninja)
target_include_directories(WebEngineCore PRIVATE ${buildDir}/$<CONFIG>/gen)
add_library(GnObjects OBJECT IMPORTED GLOBAL)
+add_dependencies(GnObjects ninja)
target_link_libraries(WebEngineCore PRIVATE GnObjects)
+if(WIN32)
+ add_library(WebEngineCoreSandbox STATIC IMPORTED GLOBAL)
+ add_dependencies(WebEngineCoreSandbox ninja)
+endif()
+
foreach(config ${configs})
string(TOUPPER ${config} cfg)
set_property(TARGET GnObjects PROPERTY IMPORTED_OBJECTS_${cfg} ${${cfg}_NINJA_OBJECTS})
@@ -546,6 +579,14 @@ foreach(config ${configs})
# we depend on WebEnigneCore stamp, but ninja backend generator needs more
add_custom_command(OUTPUT ${${cfg}_NINJA_OBJECTS} ${${cfg}_NINJA_ARCHIVES} DEPENDS QtWebEngineCore.stamp)
add_custom_target(generate_${cfg} DEPENDS ${${cfg}_NINJA_OBJECTS} ${${cfg}_NINJA_ARCHIVES})
+ if(WIN32)
+ set(sandboxLibraryPath ${buildDir}/${config}/QtWebEngineCoreSandbox.lib)
+ set_property(TARGET WebEngineCoreSandbox
+ PROPERTY IMPORTED_LOCATION_${cfg} ${sandboxLibraryPath})
+ set_source_files_properties(${sandboxLibraryPath} PROPERTIES GENERATED TRUE)
+ add_custom_command(OUTPUT ${sandboxLibraryPath} DEPENDS QtWebEngineCoreSandbox.lib)
+ add_custom_target(generate_sandbox_${cfg} DEPENDS ${sandboxLibraryPath})
+ endif()
endforeach()
##
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index e6a551e65..182926889 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -208,6 +208,19 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize()
}
} // namespace QtWebEngineCore
+#if defined(Q_OS_WIN)
+namespace QtWebEngineSandbox {
+sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info)
+{
+ static sandbox::SandboxInterfaceInfo *g_info = nullptr;
+ if (info) {
+ Q_ASSERT(g_info == nullptr);
+ g_info = info;
+ }
+ return g_info;
+}
+} //namespace
+#endif
static void initialize()
{
#if QT_CONFIG(opengl)
diff --git a/src/core/api/qtwebenginecoreglobal_p.h b/src/core/api/qtwebenginecoreglobal_p.h
index 655b2a814..8214fc19c 100644
--- a/src/core/api/qtwebenginecoreglobal_p.h
+++ b/src/core/api/qtwebenginecoreglobal_p.h
@@ -65,4 +65,16 @@
#define Q_WEBENGINECORE_PRIVATE_EXPORT Q_WEBENGINECORE_EXPORT
+namespace QtWebEngineCore {
+Q_WEBENGINECORE_PRIVATE_EXPORT int processMain(int argc, const char **argv);
+} // namespace
+#if defined(Q_OS_WIN)
+namespace sandbox {
+struct SandboxInterfaceInfo;
+}
+namespace QtWebEngineSandbox {
+Q_WEBENGINECORE_PRIVATE_EXPORT sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info = nullptr);
+void initializeStaticCopy(int argc, const char **argv);
+}
+#endif
#endif // QTWEBENGINECOREGLOBAL_P_H
diff --git a/src/core/configure/BUILD.root.gn.in b/src/core/configure/BUILD.root.gn.in
index 116c6bbeb..77d07f451 100644
--- a/src/core/configure/BUILD.root.gn.in
+++ b/src/core/configure/BUILD.root.gn.in
@@ -341,8 +341,16 @@ source_set("qtwebengine_sources") {
}
if (is_win) {
- shared_library("qtwebengine_sandbox_win") {
- cmake_config = "@GN_CONFIG@"
+ static_library("QtWebEngineCoreSandbox") {
+ complete_static_lib = true
+ configs += [ ":cpp17_config",
+ ":QtWebEngineCore_config",
+ "//build/config:precompiled_headers"
+ ]
+ output_dir = "$root_out_dir"
+ sources = [
+ "@GN_SOURCE_ROOT@/sandbox_win.cpp"
+ ]
public_deps = [ "//sandbox/win:sandbox" ]
}
}
diff --git a/src/core/process_main.cpp b/src/core/process_main.cpp
index 827e31037..709f8bd6d 100644
--- a/src/core/process_main.cpp
+++ b/src/core/process_main.cpp
@@ -37,8 +37,7 @@
**
****************************************************************************/
-#include "process_main.h"
-
+#include "qtwebenginecoreglobal_p.h"
#include "content_main_delegate_qt.h"
#include "content/public/app/content_main.h"
#if defined(OS_WIN)
@@ -51,10 +50,6 @@
namespace QtWebEngineCore {
-#if defined(OS_WIN)
-extern sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info = nullptr);
-#endif
-
/*! \internal */
int processMain(int argc, const char **argv)
{
@@ -63,7 +58,7 @@ int processMain(int argc, const char **argv)
#if defined(OS_WIN)
HINSTANCE instance_handle = NULL;
- params.sandbox_info = staticSandboxInterfaceInfo();
+ params.sandbox_info = QtWebEngineSandbox::staticSandboxInterfaceInfo();
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (!params.sandbox_info) {
content::InitializeSandboxInfo(&sandbox_info);
diff --git a/src/core/qtwebengine.gni b/src/core/qtwebengine.gni
index 11352a3e8..49217603f 100644
--- a/src/core/qtwebengine.gni
+++ b/src/core/qtwebengine.gni
@@ -68,7 +68,7 @@ if (enable_extensions) {
}
if (is_win) {
- data_deps = [ ":qtwebengine_sandbox_win" ]
+ data_deps = [ ":QtWebEngineCoreSandbox" ]
}
defines = [
diff --git a/src/core/process_main.h b/src/core/sandbox_win.cpp
index fed2f3064..01538d318 100644
--- a/src/core/process_main.h
+++ b/src/core/sandbox_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -37,21 +37,46 @@
**
****************************************************************************/
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#include "qtwebenginecoreglobal_p.h"
+#include "sandbox/win/src/process_mitigations.h"
+#include "sandbox/win/src/sandbox_factory.h"
-#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>
+#ifndef NDEBUG
+#include "base/command_line.h"
+#include "base/logging.h"
+#endif
-namespace QtWebEngineCore {
+namespace QtWebEngineSandbox {
+// A duplicate of the function by same name in startup_helper_win.cc
+static void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo *info)
+{
+ info->broker_services = sandbox::SandboxFactory::GetBrokerServices();
+ if (!info->broker_services) {
+ info->target_services = sandbox::SandboxFactory::GetTargetServices();
+ } else {
+ // Ensure the proper mitigations are enforced for the browser process.
+ sandbox::ApplyProcessMitigationsToCurrentProcess(
+ sandbox::MITIGATION_DEP | sandbox::MITIGATION_DEP_NO_ATL_THUNK |
+ sandbox::MITIGATION_HARDEN_TOKEN_IL_POLICY);
+ // Note: these mitigations are "post-startup". Some mitigations that need
+ // to be enabled sooner (e.g. MITIGATION_EXTENSION_POINT_DISABLE) are done
+ // so in Chrome_ELF.
+ }
+}
-Q_WEBENGINECORE_PRIVATE_EXPORT int processMain(int argc, const char **argv);
-
-} // namespace
+// Initializes the staticlib copy of //base and //sandbox used for Windows sandboxing
+void initializeStaticCopy(int argc, const char **argv)
+{
+#ifndef NDEBUG
+ // Initialize //base for debugging
+ base::CommandLine::Init(argc, argv);
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ logging::InitLogging(settings);
+#endif
+ sandbox::SandboxInterfaceInfo *info = new sandbox::SandboxInterfaceInfo();
+ memset(info, 0, sizeof(sandbox::SandboxInterfaceInfo));
+ InitializeSandboxInfo(info);
+ QtWebEngineSandbox::staticSandboxInterfaceInfo(info);
+}
+} // namespace QtWebEngineSandbox
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index b3a44def6..ed2a240d6 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -287,18 +287,6 @@ static void logContext(const char *glType, base::CommandLine *cmd)
}
}
-#if defined(Q_OS_WIN)
-sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info)
-{
- static sandbox::SandboxInterfaceInfo *g_info = nullptr;
- if (info) {
- Q_ASSERT(g_info == nullptr);
- g_info = info;
- }
- return g_info;
-}
-#endif
-
extern std::unique_ptr<base::MessagePump> messagePumpFactory();
static void setupProxyPac(base::CommandLine *commandLine)
@@ -806,7 +794,7 @@ WebEngineContext::WebEngineContext()
content::ContentMainParams contentMainParams(m_mainDelegate.get());
#if defined(OS_WIN)
- contentMainParams.sandbox_info = staticSandboxInterfaceInfo();
+ contentMainParams.sandbox_info = QtWebEngineSandbox::staticSandboxInterfaceInfo();
sandbox::SandboxInterfaceInfo sandbox_info = {0};
if (!contentMainParams.sandbox_info) {
content::InitializeSandboxInfo(&sandbox_info);
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index 9ac598c67..0c2d18bcd 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -97,10 +97,6 @@ class ProfileAdapter;
bool usingSoftwareDynamicGL();
-#ifdef Q_OS_WIN
-Q_WEBENGINECORE_PRIVATE_EXPORT sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info = nullptr);
-#endif
-
typedef std::tuple<bool, QString, QString> ProxyAuthentication;
class WebEngineContext : public base::RefCounted<WebEngineContext> {
diff --git a/src/gn/CMakeLists.txt b/src/gn/CMakeLists.txt
index 7a419ec67..9a11184c3 100644
--- a/src/gn/CMakeLists.txt
+++ b/src/gn/CMakeLists.txt
@@ -9,12 +9,17 @@ project(Gn
set(GN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gn)
set(GN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-set(GN_EXECUTABLE gn)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
find_package(Python2 REQUIRED)
find_package(Ninja 1.7.2 REQUIRED)
+if(WIN32)
+ set(GN_EXECUTABLE gn.exe)
+else()
+ set(GN_EXECUTABLE gn)
+endif()
+
file(MAKE_DIRECTORY ${GN_BINARY_DIR})
add_custom_command(
OUTPUT ${GN_EXECUTABLE}
diff --git a/src/process/CMakeLists.txt b/src/process/CMakeLists.txt
index 7f1b40b90..3b0ee588f 100644
--- a/src/process/CMakeLists.txt
+++ b/src/process/CMakeLists.txt
@@ -10,6 +10,11 @@ get_target_property(isFramework WebEngineCore FRAMEWORK)
qt_internal_add_executable(${qtWebEngineProcessName} SOURCES main.cpp)
+if(WIN32)
+ target_sources(${qtWebEngineProcessName} PRIVATE support_win.cpp)
+ target_link_libraries(${qtWebEngineProcessName} PRIVATE WebEngineCoreSandbox)
+endif()
+
target_link_libraries(${qtWebEngineProcessName}
PUBLIC
Qt::Gui
diff --git a/src/process/process.exe.manifest b/src/process/QtWebEngineProcess.exe.manifest
index 181a0e13e..181a0e13e 100644
--- a/src/process/process.exe.manifest
+++ b/src/process/QtWebEngineProcess.exe.manifest
diff --git a/src/process/main.cpp b/src/process/main.cpp
index 53596d0ee..7cdc4f4ab 100644
--- a/src/process/main.cpp
+++ b/src/process/main.cpp
@@ -37,8 +37,7 @@
**
****************************************************************************/
-#include "process_main.h"
-
+#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>
#include <QCoreApplication>
#include <stdio.h>
#include <memory>
@@ -88,17 +87,16 @@ struct tm* localtime64_r_proxy(const time_t* timep, struct tm* result)
#endif // defined(OS_LINUX)
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN32)
namespace QtWebEngineProcess {
void initDpiAwareness();
-void initializeStaticCopy(int argc, const char **argv);
-} // namespace
-#endif // defined(Q_OS_WIN)
+}
+#endif // defined(Q_OS_WIN32)
int main(int argc, const char **argv)
{
-#ifdef Q_OS_WIN
- QtWebEngineProcess::initializeStaticCopy(argc, argv);
+#if defined(Q_OS_WIN32)
+ QtWebEngineSandbox::initializeStaticCopy(argc, argv);
QtWebEngineProcess::initDpiAwareness();
#endif
diff --git a/src/process/support_win.cpp b/src/process/support_win.cpp
index b415dc2a5..c2ff2d838 100644
--- a/src/process/support_win.cpp
+++ b/src/process/support_win.cpp
@@ -42,13 +42,6 @@
#include <qsysinfo.h>
#include <qt_windows.h>
#include <TlHelp32.h>
-#include "../3rdparty/chromium/sandbox/win/src/process_mitigations.h"
-#include "../3rdparty/chromium/sandbox/win/src/sandbox_factory.h"
-
-#ifndef NDEBUG
-#include "../3rdparty/chromium/base/command_line.h"
-#include "../3rdparty/chromium/base/logging.h"
-#endif
class User32DLL {
public:
@@ -141,45 +134,8 @@ static DWORD getParentProcessId()
return parentPid;
}
-namespace QtWebEngineCore {
-extern __declspec(dllimport) sandbox::SandboxInterfaceInfo *staticSandboxInterfaceInfo(sandbox::SandboxInterfaceInfo *info = nullptr);
-}
-
namespace QtWebEngineProcess {
-// A duplicate of the function by same name in startup_helper_win.cc
-static void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo *info)
-{
- info->broker_services = sandbox::SandboxFactory::GetBrokerServices();
- if (!info->broker_services) {
- info->target_services = sandbox::SandboxFactory::GetTargetServices();
- } else {
- // Ensure the proper mitigations are enforced for the browser process.
- sandbox::ApplyProcessMitigationsToCurrentProcess(
- sandbox::MITIGATION_DEP | sandbox::MITIGATION_DEP_NO_ATL_THUNK |
- sandbox::MITIGATION_HARDEN_TOKEN_IL_POLICY);
- // Note: these mitigations are "post-startup". Some mitigations that need
- // to be enabled sooner (e.g. MITIGATION_EXTENSION_POINT_DISABLE) are done
- // so in Chrome_ELF.
- }
-}
-
-// Initializes the staticlib copy of //base and //sandbox used for Windows sandboxing
-void initializeStaticCopy(int argc, const char **argv)
-{
-#ifndef NDEBUG
- // Initialize //base for debugging
- base::CommandLine::Init(argc, argv);
- logging::LoggingSettings settings;
- settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
- logging::InitLogging(settings);
-#endif
- sandbox::SandboxInterfaceInfo *info = new sandbox::SandboxInterfaceInfo();
- memset(info, 0, sizeof(sandbox::SandboxInterfaceInfo));
- InitializeSandboxInfo(info);
- QtWebEngineCore::staticSandboxInterfaceInfo(info);
-}
-
void initDpiAwareness()
{
ShcoreDLL shcore;