From 1c5e30928bd3ec31747276ff60940ec144a2cc16 Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Date: Mon, 18 Nov 2013 14:23:25 +0100
Subject: [PATCH] Moving sources to src part 2: Adjust paths.

NOTE: To build after this you should rerun init-repository.py or run
$> git submodule sync
$> git submodule update
$> git config qtwebengine.chromiumsrcdir src/3rdparty

This makes everything build by adjusting paths.

Other mixed-in changes:
- Rename qtwebengine_src variables in scripts to qtwebengine_root to
  avoid confusion.
- Cleanup the release and debug extra targets that were in lib.pro.
  This file has also been split into src.pro and core.pro.

Change-Id: Ieee9158a65f526b15244eaca59e779b7069d337e
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
---
 .gitignore                                    |  5 +-
 .qmake.conf                                   |  2 +-
 init-repository.py                            | 38 +++++-----
 patches/patch-chromium.sh                     |  1 -
 qtwebengine.pro                               |  1 +
 src/core/core.pro                             | 22 ++++++
 src/core/core_gyp_generator.pro               |  9 ++-
 src/core/core_resources.qrc                   |  2 +-
 src/core/devtools.qrc                         |  4 +-
 src/core/gyp_configure_host.pro               |  2 +-
 src/core/gyp_configure_target.pro             |  4 +-
 src/core/gyp_run.pro                          |  2 +-
 src/core/render_widget_host_view_qt.cpp       |  1 -
 src/core/resources/resources.pro              |  4 +-
 src/process/process.pro                       |  2 +-
 src/src.pro                                   | 76 +++++--------------
 .../plugin/experimental/experimental.pro      |  2 +-
 src/webengine/plugin/plugin.pro               |  2 +-
 src/webengine/webengine.pro                   | 13 ++--
 src/webenginewidgets/webenginewidgets.pro     | 18 ++---
 sync.profile                                  |  7 +-
 tests/auto/quick/tests.pri                    |  4 +-
 tests/auto/widgets/tests.pri                  |  4 +-
 tools/buildscripts/build_resources.py         |  8 +-
 tools/buildscripts/gyp_qtwebengine            | 15 ++--
 tools/qmake/mkspecs/features/default_pre.prf  |  4 +-
 tools/qmake/mkspecs/features/functions.prf    |  6 +-
 .../qmake/mkspecs/features/gyp_generator.prf  |  6 +-
 tools/scripts/take_snapshot.py                |  8 +-
 29 files changed, 122 insertions(+), 150 deletions(-)
 create mode 100644 qtwebengine.pro
 create mode 100644 src/core/core.pro

diff --git a/.gitignore b/.gitignore
index db316a3aa..9570dacd1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,7 @@
 *.o
 Makefile
-process/process
 out/
-lib/lib.gyp
-process/process.gyp
-shared/shared.gyp
+src/core/core.gyp
 *.pro.user*
 .qmake.cache
 *.moc
diff --git a/.qmake.conf b/.qmake.conf
index a094e83ca..66245228b 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
-QMAKEPATH += $$PWD/build/qmake
+QMAKEPATH += $$PWD/tools/qmake
 load(qt_build_config)
 
 # All modules share the same version number. We plan on following Qt's releases for now.
diff --git a/init-repository.py b/init-repository.py
index fa4508b60..2affa196a 100755
--- a/init-repository.py
+++ b/init-repository.py
@@ -48,13 +48,13 @@ import sys
 import string
 import argparse
 
-qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__)))
+qtwebengine_root = os.path.abspath(os.path.join(os.path.dirname(__file__)))
 
-sys.path.append(os.path.join(qtwebengine_src, 'tools'))
+sys.path.append(os.path.join(qtwebengine_root, 'tools', 'scripts'))
 import git_submodule as GitSubmodule
 
 chromium_src = os.environ.get('CHROMIUM_SRC_DIR')
-ninja_src = os.path.join(qtwebengine_src, '3rdparty_upstream/ninja')
+ninja_src = os.path.join(qtwebengine_root, 'src/3rdparty_upstream/ninja')
 use_external_chromium = False
 
 parser = argparse.ArgumentParser(description='Initialize QtWebEngine repository.')
@@ -69,15 +69,15 @@ if chromium_src:
     use_external_chromium = True
 if not chromium_src or not os.path.isdir(chromium_src):
     if args.snapshot:
-        chromium_src = os.path.join(qtwebengine_src, '3rdparty/chromium')
-        ninja_src = os.path.join(qtwebengine_src, '3rdparty/ninja')
+        chromium_src = os.path.join(qtwebengine_root, 'src/3rdparty/chromium')
+        ninja_src = os.path.join(qtwebengine_root, 'src/3rdparty/ninja')
     if args.upstream or not chromium_src:
-        chromium_src = os.path.join(qtwebengine_src, '3rdparty_upstream/chromium')
+        chromium_src = os.path.join(qtwebengine_root, 'src/3rdparty_upstream/chromium')
         args.upstream = True
     print 'CHROMIUM_SRC_DIR not set, using Chromium in' + chromium_src
 
 # Write our chromium sources directory into git config.
-relative_chromium_src = os.path.relpath(chromium_src, qtwebengine_src)
+relative_chromium_src = os.path.relpath(chromium_src, qtwebengine_root)
 subprocess.call(['git', 'config', 'qtwebengine.chromiumsrcdir', relative_chromium_src])
 
 
@@ -100,19 +100,19 @@ def updateLastChange():
     os.chdir(currentDir)
 
 def addGerritRemote():
-    os.chdir(qtwebengine_src)
+    os.chdir(qtwebengine_root)
     remotes = subprocess.check_output(['git', 'remote'])
     if not 'gerrit' in remotes:
         subprocess.call(['git', 'remote', 'add', 'gerrit', 'ssh://codereview.qt-project.org:29418/qt-labs/qtwebengine.git'])
 
 def installGitHooks():
-    os.chdir(qtwebengine_src)
+    os.chdir(qtwebengine_root)
     subprocess.call(['scp', '-p', '-P', '29418', 'codereview.qt-project.org:hooks/commit-msg', '.git/hooks'])
 
 def applyPatches():
     if use_external_chromium:
         return
-    os.chdir(qtwebengine_src)
+    os.chdir(qtwebengine_root)
     subprocess.call(['sh', './patches/patch-chromium.sh'])
 
 def initUpstreamSubmodules():
@@ -124,16 +124,16 @@ def initUpstreamSubmodules():
     # We will turn this on, once we actually switch to using the release branch.
     #chromium_ref = 'refs/branch-heads/1599'
     chromium_ref = ''
-    os.chdir(qtwebengine_src)
+    os.chdir(qtwebengine_root)
 
     current_submodules = subprocess.check_output(['git', 'submodule'])
-    if not '3rdparty_upstream/ninja' in current_submodules:
-        subprocess.call(['git', 'submodule', 'add', ninja_url, '3rdparty_upstream/ninja'])
-    if not use_external_chromium and not '3rdparty_upstream/chromium' in current_submodules:
-        subprocess.call(['git', 'submodule', 'add', chromium_url, '3rdparty_upstream/chromium'])
+    if not 'src/3rdparty_upstream/ninja' in current_submodules:
+        subprocess.call(['git', 'submodule', 'add', ninja_url, 'src/3rdparty_upstream/ninja'])
+    if not use_external_chromium and not 'src/3rdparty_upstream/chromium' in current_submodules:
+        subprocess.call(['git', 'submodule', 'add', chromium_url, 'src/3rdparty_upstream/chromium'])
 
     ninjaSubmodule = GitSubmodule.Submodule()
-    ninjaSubmodule.path = '3rdparty_upstream/ninja'
+    ninjaSubmodule.path = 'src/3rdparty_upstream/ninja'
     ninjaSubmodule.shasum = ninja_shasum
     ninjaSubmodule.url = ninja_url
     ninjaSubmodule.os = 'all'
@@ -141,7 +141,7 @@ def initUpstreamSubmodules():
 
     if not use_external_chromium:
         chromiumSubmodule = GitSubmodule.Submodule()
-        chromiumSubmodule.path = '3rdparty_upstream/chromium'
+        chromiumSubmodule.path = 'src/3rdparty_upstream/chromium'
         chromiumSubmodule.shasum = chromium_shasum
         chromiumSubmodule.ref = chromium_ref
         chromiumSubmodule.url = chromium_url
@@ -152,11 +152,11 @@ def initUpstreamSubmodules():
 
 def initSnapshot():
     snapshot = GitSubmodule.Submodule()
-    snapshot.path = '3rdparty'
+    snapshot.path = 'src/3rdparty'
     snapshot.os = 'all'
     snapshot.initialize()
 
-os.chdir(qtwebengine_src)
+os.chdir(qtwebengine_root)
 addGerritRemote()
 installGitHooks()
 
diff --git a/patches/patch-chromium.sh b/patches/patch-chromium.sh
index 38cc4c126..3c593c741 100755
--- a/patches/patch-chromium.sh
+++ b/patches/patch-chromium.sh
@@ -43,7 +43,6 @@
 # Script used temporarily to invoke gclient and apply our patches
 
 PATCH_DIR="$( cd "$( dirname "$0" )" && pwd )"
-QTWEBENGINE_SRC_DIR="$( cd $PATCH_DIR/../ && pwd )"
 
 if [ -z "$CHROMIUM_SRC_DIR" ]; then
     CHROMIUM_SRC_DIR="$( cd `git config qtwebengine.chromiumsrcdir` && pwd )"
diff --git a/qtwebengine.pro b/qtwebengine.pro
new file mode 100644
index 000000000..58c33f27c
--- /dev/null
+++ b/qtwebengine.pro
@@ -0,0 +1 @@
+load(qt_parts)
diff --git a/src/core/core.pro b/src/core/core.pro
new file mode 100644
index 000000000..b6a856545
--- /dev/null
+++ b/src/core/core.pro
@@ -0,0 +1,22 @@
+TEMPLATE = subdirs
+
+# core_gyp_generator.pro is a dummy .pro file that is used by qmake
+# to generate our main .gyp file
+core_gyp_generator.file = core_gyp_generator.pro
+
+# gyp_configure_host.pro and gyp_configure_target.pro are phony pro files that
+# extract things like compiler and linker from qmake
+gyp_configure_host.file = gyp_configure_host.pro
+gyp_configure_target.file = gyp_configure_target.pro
+gyp_configure_target.depends = gyp_configure_host
+
+# gyp_run.pro calls gyp through gyp_qtwebengine on the qmake step, and ninja on the make step.
+gyp_run.file = gyp_run.pro
+
+gyp_run.depends = resources core_gyp_generator gyp_configure_host gyp_configure_target
+
+SUBDIRS += core_gyp_generator \
+           gyp_configure_host \
+           gyp_configure_target \
+           gyp_run \
+           resources \
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index 76924ecd4..a4128fc72 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -2,8 +2,9 @@
 # We want the gyp generation step to happen after all the other config steps. For that we need to prepend
 # our gyp_generator.prf feature to the CONFIG variable since it is processed backwards
 CONFIG = gyp_generator $$CONFIG
+GYPFILE = $$PWD/core.gyp
 GYPDEPENDENCIES += <(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources
-GYPINCLUDES += ../qtwebengine.gypi
+GYPINCLUDES += qtwebengine.gypi
 
 TEMPLATE = lib
 
@@ -19,7 +20,7 @@ QT_PRIVATE += qml-private quick-private gui-private core-private
 qtHaveModule(v8): QT_PRIVATE += v8-private
 
 COPY_FILES = <(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak
-COPY_DESTINATIONS = ../resources/
+COPY_DESTINATIONS = resources/
 
 # Defining keywords such as 'signal' clashes with the chromium code base.
 DEFINES += QT_NO_KEYWORDS \
@@ -31,9 +32,9 @@ PER_CONFIG_DEFINES = QTWEBENGINEPROCESS_PATH=\\\"$$getOutDir()/%config/$$QTWEBEN
 # Keep Skia happy
 CONFIG(release, debug|release): DEFINES += NDEBUG
 
-RESOURCES += lib_resources.qrc devtools.qrc
+RESOURCES += core_resources.qrc devtools.qrc
 # We need this to find the include files generated for the .pak resource files.
-INCLUDEPATH += $$absolute_path(../resources, $$PWD)
+INCLUDEPATH += $$absolute_path(resources, $$PWD)
 
 # something fishy with qmake in 5.2 ?
 INCLUDEPATH += $$[QT_INSTALL_HEADERS]
diff --git a/src/core/core_resources.qrc b/src/core/core_resources.qrc
index af8448d2b..9dbdf90af 100644
--- a/src/core/core_resources.qrc
+++ b/src/core/core_resources.qrc
@@ -1,5 +1,5 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource prefix="data">
-    <file alias="resources.pak">../resources/net_resources.pak</file>
+    <file alias="resources.pak">resources/net_resources.pak</file>
 </qresource>
 </RCC>
diff --git a/src/core/devtools.qrc b/src/core/devtools.qrc
index 225f88f65..96d24761d 100644
--- a/src/core/devtools.qrc
+++ b/src/core/devtools.qrc
@@ -1,6 +1,6 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource prefix="data">
-    <file alias="devtools.pak">../resources/devtools_resources.pak</file>
-    <file alias="discovery_page.html">../resources/devtools_discovery_page.html</file>
+    <file alias="devtools.pak">resources/devtools_resources.pak</file>
+    <file alias="discovery_page.html">resources/devtools_discovery_page.html</file>
 </qresource>
 </RCC>
diff --git a/src/core/gyp_configure_host.pro b/src/core/gyp_configure_host.pro
index e99d1e7c5..3eb67389f 100644
--- a/src/core/gyp_configure_host.pro
+++ b/src/core/gyp_configure_host.pro
@@ -10,7 +10,7 @@ GYPI_CONTENTS = "{" \
                 "    ['CXX.host', '$$which($$QMAKE_CXX)']," \
                 "    ['LD.host', '$$which($$QMAKE_LINK)'],"
 
-GYPI_FILE = $$absolute_path('build/qmake_extras.gypi', $$QTWEBENGINE_ROOT)
+GYPI_FILE = $$absolute_path('qmake_extras.gypi')
 !build_pass {
     write_file($$GYPI_FILE, GYPI_CONTENTS)
 }
diff --git a/src/core/gyp_configure_target.pro b/src/core/gyp_configure_target.pro
index 6d9f414c3..4d5204407 100644
--- a/src/core/gyp_configure_target.pro
+++ b/src/core/gyp_configure_target.pro
@@ -26,9 +26,9 @@ GYPI_CONTENTS += "        ]," \
 
 GYPI_CONTENTS += "}"
 
-GYPI_FILE = $$absolute_path('build/qmake_extras.gypi', $$QTWEBENGINE_ROOT)
+GYPI_FILE = $$absolute_path('qmake_extras.gypi')
 
-!exists($$GYPI_FILE): error("-- $$GYPI not found --")
+!exists($$GYPI_FILE): error("-- $$GYPI_FILE not found --")
 
 # Append to the file already containing the host settings.
 !build_pass {
diff --git a/src/core/gyp_run.pro b/src/core/gyp_run.pro
index e0c8b4af1..1ee0b1bce 100644
--- a/src/core/gyp_run.pro
+++ b/src/core/gyp_run.pro
@@ -46,7 +46,7 @@ cross_compile {
 
 !build_pass {
   message(Running gyp_qtwebengine $${GYP_ARGS}...)
-  !system("python ./gyp_qtwebengine $${GYP_ARGS}"): error("-- running gyp_qtwebengine failed --")
+  !system("python $$QTWEBENGINE_ROOT/tools/buildscripts/gyp_qtwebengine $${GYP_ARGS}"): error("-- running gyp_qtwebengine failed --")
 }
 
 ninja.target = invoke_ninja
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 91e9ab585..e2df54afe 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -53,7 +53,6 @@
 #include "content/browser/renderer_host/ui_events_helper.h"
 #include "content/common/gpu/gpu_messages.h"
 #include "content/common/view_messages.h"
-#include "lib/type_conversion.h"
 #include "third_party/WebKit/public/web/WebCursorInfo.h"
 #include "ui/base/events/event.h"
 #include "ui/gfx/size_conversions.h"
diff --git a/src/core/resources/resources.pro b/src/core/resources/resources.pro
index a9404f3ec..b0eba1246 100644
--- a/src/core/resources/resources.pro
+++ b/src/core/resources/resources.pro
@@ -2,6 +2,4 @@
 # These files will then be bundled using the Qt Resource System.
 TEMPLATE = aux
 
-system(python ../build/scripts/build_resources.py)
-
-
+system("python $$QTWEBENGINE_ROOT/tools/buildscripts/build_resources.py")
diff --git a/src/process/process.pro b/src/process/process.pro
index 6234d839f..9c02ec70c 100644
--- a/src/process/process.pro
+++ b/src/process/process.pro
@@ -12,7 +12,7 @@ qnx: QMAKE_RPATHLINKDIR += $${QNX_DIR}/$${QNX_CPUDIR}/usr/lib/qt5/lib
 
 DESTDIR = $$getOutDir()/$$getConfigDir()
 
-INCLUDEPATH += ../lib
+INCLUDEPATH += ../core
 
 SOURCES = main.cpp
 
diff --git a/src/src.pro b/src/src.pro
index bc0151536..59fcce66f 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,64 +1,22 @@
 TEMPLATE = subdirs
 
-# The first three subdirs contain dummy .pro files that are used by qmake
-# to generate a corresponding .gyp file
-
-# Phony pro file that extracts things like compiler and linker from qmake
-qmake_extras.subdir = build/qmake_extras
-
-# Phony pro files that generate gyp files. Will be built by ninja.
-lib.depends = qmake_extras
-
-# API libraries
-webengine_lib.subdir = lib/quick
-webengine_lib.target = sub-webengine-lib
-webengine_lib.depends = build
-quick_plugin_lib.subdir = lib/quick/plugin
-quick_plugin_lib.target = sub-quick-plugin-lib
-quick_plugin_lib.depends = webengine_lib
-quick_experimental_plugin_lib.subdir = lib/quick/plugin/experimental
-quick_experimental_plugin_lib.target = sub-quick-experimental-plugin-lib
-quick_experimental_plugin_lib.depends = webengine_lib
-widgets_lib.subdir = lib/widgets
-widgets_lib.target = sub-widgets-lib
-widgets_lib.depends = build
-
-process.depends = build
-sub_examples.depends = quick_plugin_lib quick_experimental_plugin_lib
-sub_tests.depends = quick_plugin_lib quick_experimental_plugin_lib
-
-# This is where we use the generated gypi files and run gyp_qtwebengine
-build.depends = resources lib
-
-SUBDIRS += qmake_extras \
-          resources \
-          lib \
-          process \
-          build \
-          webengine_lib \
-          quick_plugin_lib \
-          quick_experimental_plugin_lib
+process.depends = core
+webengine.depends = core
+webenginewidgets.depends = core
+webengine_plugin.subdir = webengine/plugin
+webengine_plugin.target = sub-webengine-plugin
+webengine_plugin.depends = webengine
+webengine_experimental_plugin.subdir = webengine/plugin/experimental
+webengine_experimental_plugin.target = sub-webengine-experimental-plugin
+webengine_experimental_plugin.depends = webengine
+
+
+SUBDIRS += core \
+           process \
+           webengine \
+           webengine_plugin \
+           webengine_experimental_plugin
 
 qtHaveModule(widgets) {
-    SUBDIRS += widgets_lib
-    sub_examples.depends += widgets_lib
-    sub_tests.depends += widgets_lib
+    SUBDIRS += webenginewidgets
 }
-
-# Ninja executable location needs to be determined early for extra targets. Should be fetched from cache most of the time anyway.
-NINJA_EXECUTABLE = $$findOrBuildNinja()
-
-# Extra targets that invoke ninja on the desired configuration added for convenience
-release.target = release
-release.commands = $$NINJA_EXECUTABLE -C $$getOutDir()/Release
-release.depends: qmake
-
-debug.target = debug
-debug.commands = $$NINJA_EXECUTABLE -C $$getOutDir()/Debug
-debug.depends: qmake
-
-QMAKE_EXTRA_TARGETS += release \
-                       debug
-
-# Move this to the beginning of the project file as soon as we moved to the src layout
-load(qt_parts)
diff --git a/src/webengine/plugin/experimental/experimental.pro b/src/webengine/plugin/experimental/experimental.pro
index ad2e0b8a3..fb396c34e 100644
--- a/src/webengine/plugin/experimental/experimental.pro
+++ b/src/webengine/plugin/experimental/experimental.pro
@@ -8,7 +8,7 @@ QT_PRIVATE += webengine-private qml-private quick-private gui-private core-priva
 
 qtHaveModule(v8): QT_PRIVATE += v8-private
 
-INCLUDEPATH += $$QTWEBENGINE_ROOT/lib $$QTWEBENGINE_ROOT/lib/quick
+INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/webengine/api
 
 SOURCES = plugin.cpp
 
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 93e04f97a..9dca82fe9 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -6,7 +6,7 @@ IMPORT_VERSION = 1.0
 QT += webengine qml quick
 QT_PRIVATE += webengine-private qml-private quick-private gui-private core-private
 
-INCLUDEPATH += $$QTWEBENGINE_ROOT/lib $$QTWEBENGINE_ROOT/lib/quick
+INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/webengine/api
 
 SOURCES = plugin.cpp
 
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 50353066b..ccf874358 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -1,5 +1,4 @@
 TARGET = QtWebEngine
-MODULE = webengine
 
 # For our export macros
 DEFINES += QT_BUILD_WEBENGINE_LIB
@@ -10,7 +9,7 @@ QT_PRIVATE += qml-private quick-private gui-private core-private
 # Remove this as soon as we have a hard-dependency on Qt 5.2
 qtHaveModule(v8): QT_PRIVATE += v8-private
 
-INCLUDEPATH += ../
+INCLUDEPATH += api ../core
 
 # FIXME: all this should eventually be turned into QT += webenginecore
 macx:LIBPATH = $$getOutDir()/$$getConfigDir()
@@ -21,14 +20,14 @@ QMAKE_RPATHDIR += $$LIBPATH
 #DESTDIR = $$LIBPATH
 
 SOURCES = \
-        qquickwebengineview.cpp \
+        api/qquickwebengineview.cpp \
         render_widget_host_view_qt_delegate_quick.cpp
 
 HEADERS = \
-        qtwebengineglobal.h \
-        qtwebengineglobal_p.h \
-        qquickwebengineview_p.h \
-        qquickwebengineview_p_p.h \
+        api/qtwebengineglobal.h \
+        api/qtwebengineglobal_p.h \
+        api/qquickwebengineview_p.h \
+        api/qquickwebengineview_p_p.h \
         render_widget_host_view_qt_delegate_quick.h
 
 load(qt_module)
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 3338e0cf7..a78efaa6c 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -20,20 +20,20 @@ QMAKE_RPATHDIR += $$LIBPATH
 
 DESTDIR = $$LIBPATH
 
-INCLUDEPATH += Api ../
+INCLUDEPATH += api ../core
 
 SOURCES = \
-        Api/qwebenginehistory.cpp \
-        Api/qwebenginepage.cpp \
-        Api/qwebengineview.cpp\
+        api/qwebenginehistory.cpp \
+        api/qwebenginepage.cpp \
+        api/qwebengineview.cpp\
         render_widget_host_view_qt_delegate_widget.cpp
 
 HEADERS = \
-        Api/qtwebenginewidgetsglobal.h \
-        Api/qwebenginehistory.h \
-        Api/qwebenginepage.h \
-        Api/qwebengineview.h \
-        Api/qwebengineview_p.h \
+        api/qtwebenginewidgetsglobal.h \
+        api/qwebenginehistory.h \
+        api/qwebenginepage.h \
+        api/qwebengineview.h \
+        api/qwebengineview_p.h \
         render_widget_host_view_qt_delegate_widget.h
 
 load(qt_module)
diff --git a/sync.profile b/sync.profile
index a08c3d9c5..a1f4dce41 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,9 +1,10 @@
 %modules = ( # path to module name map
-    "QtWebEngine" => "$basedir/lib/quick",
-    "QtWebEngineWidgets" => "$basedir/lib/widgets",
+    "QtWebEngine" => "$basedir/src/webengine",
+    "QtWebEngineWidgets" => "$basedir/src/webenginewidgets",
 );
 %moduleheaders = ( # restrict the module headers to those found in relative path
-    "QtWebEngineWidgets" => "Api",
+    "QtWebEngine" => "api",
+    "QtWebEngineWidgets" => "api",
 );
 %classnames = (
 );
diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri
index bdefa9159..0af8dbd76 100644
--- a/tests/auto/quick/tests.pri
+++ b/tests/auto/quick/tests.pri
@@ -5,9 +5,7 @@ VPATH += $$_PRO_FILE_PWD_
 TARGET = tst_$$TARGET
 
 SOURCES += $${TARGET}.cpp
-INCLUDEPATH += \
-    $$PWD \
-    $$PWD/../Api
+INCLUDEPATH += $$PWD
 
 QT += testlib network quick
 QT_PRIVATE += quick-private gui-private core-private
diff --git a/tests/auto/widgets/tests.pri b/tests/auto/widgets/tests.pri
index 4ca22969f..05636d279 100644
--- a/tests/auto/widgets/tests.pri
+++ b/tests/auto/widgets/tests.pri
@@ -13,9 +13,7 @@ contains(MOBILITY_CONFIG, multimedia) {
 }
 
 SOURCES += $${TARGET}.cpp
-INCLUDEPATH += \
-    $$PWD \
-    $$PWD/../Api
+INCLUDEPATH += $$PWD
 
 QT += testlib network webenginewidgets widgets
 macx: CONFIG -= app_bundle
diff --git a/tools/buildscripts/build_resources.py b/tools/buildscripts/build_resources.py
index 7b20aa9ad..56d8ed404 100755
--- a/tools/buildscripts/build_resources.py
+++ b/tools/buildscripts/build_resources.py
@@ -48,18 +48,18 @@ import sys
 import string
 import time
 
-qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
+qtwebengine_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
 
 
 chrome_src = subprocess.check_output("git config qtwebengine.chromiumsrcdir || true", shell=True).strip()
 if chrome_src:
-  chrome_src = os.path.join(qtwebengine_src, chrome_src)
+  chrome_src = os.path.join(qtwebengine_root, chrome_src)
 if not chrome_src or not os.path.isdir(chrome_src):
-  chrome_src = os.path.join(qtwebengine_src, '3rdparty/chromium')
+  chrome_src = os.path.join(qtwebengine_root, 'src/3rdparty/chromium')
   print 'CHROMIUM_SRC_DIR not set, falling back to ' + chrome_src
 
 grit_tool = os.path.join(chrome_src, 'tools/grit/grit.py')
-resources_subdir = os.path.join(qtwebengine_src, 'resources')
+resources_subdir = os.path.join(qtwebengine_root, 'src/core/resources')
 
 def checkNeedForRebuild(grd_file):
     grit_files = subprocess.check_output(['python', grit_tool, '-i', grd_file, 'buildinfo']).splitlines()
diff --git a/tools/buildscripts/gyp_qtwebengine b/tools/buildscripts/gyp_qtwebengine
index e715cb821..48491e600 100755
--- a/tools/buildscripts/gyp_qtwebengine
+++ b/tools/buildscripts/gyp_qtwebengine
@@ -7,19 +7,20 @@ import sys
 
 print 'using python: ' + sys.executable + ' version: ' + sys.version
 
-qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+qtwebengine_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))
+qtwebengine_src = os.path.join(qtwebengine_root, 'src')
 chrome_src = subprocess.check_output("git config qtwebengine.chromiumsrcdir || true", shell=True).strip()
 if chrome_src:
-  chrome_src = os.path.join(qtwebengine_src, chrome_src)
+  chrome_src = os.path.join(qtwebengine_root, chrome_src)
 if not chrome_src or not os.path.isdir(chrome_src):
-  chrome_src = os.path.join(qtwebengine_src, '3rdparty/chromium')
+  chrome_src = os.path.join(qtwebengine_root, 'src/3rdparty/chromium')
   print 'CHROMIUM_SRC_DIR not set, falling back to ' + chrome_src
 
 script_dir = os.path.abspath(os.path.join(chrome_src, 'build'))
 if not os.path.isdir(script_dir):
   print script_dir + " is not a valid directory"
   sys.exit(1)
-root_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
+root_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir, os.pardir))
 
 sys.path.insert(0, script_dir)
 import gyp_helper
@@ -64,10 +65,10 @@ def additional_include_files(args=[]):
   AddInclude(os.path.join(script_dir, 'common.gypi'))
 
   # Used for additional build tweaks such as file exclusions
-  AddInclude(os.path.join(qtwebengine_src, 'build', 'qtwebengine_extras.gypi'))
+  AddInclude(os.path.join(qtwebengine_root, 'src', 'core', 'qtwebengine_extras.gypi'))
 
   # Common stuff we generate and extract from qmake
-  AddInclude(os.path.join(qtwebengine_src, 'build', 'qmake_extras.gypi'))
+  AddInclude(os.path.join(qtwebengine_root, 'src', 'core', 'qmake_extras.gypi'))
 
   # Optionally add supplemental .gypi files if present.
   supplements = glob.glob(os.path.join(chrome_src, '*', 'supplement.gypi'))
@@ -104,7 +105,7 @@ if __name__ == '__main__':
       break
 
   if not gyp_file_specified:
-      args.append(os.path.join(root_dir, 'qtwebengine.gyp'))
+      args.append(os.path.join(root_dir, 'src/core/core.gyp'))
 
   args.extend(['-I' + i for i in additional_include_files(args)])
 
diff --git a/tools/qmake/mkspecs/features/default_pre.prf b/tools/qmake/mkspecs/features/default_pre.prf
index 1e751b740..cec9be1bd 100644
--- a/tools/qmake/mkspecs/features/default_pre.prf
+++ b/tools/qmake/mkspecs/features/default_pre.prf
@@ -1,12 +1,12 @@
 # Resolve root directories for sources
-QTWEBENGINE_ROOT = $$replace(PWD, /build/qmake/mkspecs/features$,)
+QTWEBENGINE_ROOT = $$replace(PWD, /tools/qmake/mkspecs/features$,)
 
 QTWEBENGINEPROCESS_NAME = QtWebEngineProcess
 
 git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
 
 # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
-isEmpty(git_chromium_src_dir): git_chromium_src_dir = "3rdparty/chromium"
+isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
 
 CHROMIUM_SRC_DIR = $$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir")
 
diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index 9d90d67bd..0d0d37954 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -28,7 +28,7 @@ defineReplace(findMocables) {
   input = $$1
   for (file, input): \
       infiles += $$absolute_path($$file, $$_PRO_FILE_PWD_)
-  mocables = $$system("python $$QTWEBENGINE_ROOT/build/scripts/find-mocables $$infiles")
+  mocables = $$system("python $$QTWEBENGINE_ROOT/tools/buildscripts/find-mocables $$infiles")
   mocables = $$replace(mocables, $$_PRO_FILE_PWD_$${QMAKE_DIR_SEP}, '')
   return($$mocables)
 }
@@ -37,7 +37,7 @@ defineReplace(findIncludedMocFiles) {
   input = $$1
   for (file, input): \
       infiles += $$absolute_path($$file, $$_PRO_FILE_PWD_)
-  return($$system("python $$QTWEBENGINE_ROOT/build/scripts/find-included-moc-files $$infiles"))
+  return($$system("python $$QTWEBENGINE_ROOT/tools/buildscripts/find-included-moc-files $$infiles"))
 }
 
 defineReplace(mocOutput) {
@@ -93,7 +93,7 @@ defineReplace(findOrBuildNinja) {
   !exists($$out) {
     git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
     # Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
-    isEmpty(git_chromium_src_dir): git_chromium_src_dir = "3rdparty/chromium"
+    isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
     win32: out = $$system_path($$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir/../ninja/ninja.exe"))
     else: out = $$absolute_path("$$QTWEBENGINE_ROOT/$$git_chromium_src_dir/../ninja/ninja")
     # If we still did not find ninja, then we bootstrap it.
diff --git a/tools/qmake/mkspecs/features/gyp_generator.prf b/tools/qmake/mkspecs/features/gyp_generator.prf
index d15b864c9..ad87f5673 100644
--- a/tools/qmake/mkspecs/features/gyp_generator.prf
+++ b/tools/qmake/mkspecs/features/gyp_generator.prf
@@ -55,7 +55,7 @@ defineReplace(rccAction) {
     return($$contents)
 }
 
-GYPI_FILE = $$replace(_PRO_FILE_, .pro$, .gyp)
+isEmpty(GYPFILE): GYPFILE = $$replace(_PRO_FILE_, .pro$, .gyp)
 
 TARGET_TYPE = $$toGypTargetType()
 MOCABLE_HEADERS = $$findMocables($$HEADERS)
@@ -196,10 +196,10 @@ GYP_CONTENTS += "    ]," \
 GYP_CONTENTS += "  ]," \
                 "}"
 
-!build_pass: write_file($$GYPI_FILE, GYP_CONTENTS)
+!build_pass: write_file($$GYPFILE, GYP_CONTENTS)
 
 # Overwriting the generated gyp file seems like a good reason to re-gyp
-unix: phony_variable_name_for_qmake_to_be_happy=$$system("touch $$QTWEBENGINE_ROOT/build/build.pro")
+unix: phony_variable_name_for_qmake_to_be_happy=$$system("touch $$QTWEBENGINE_ROOT/src/core/gyp_run.pro")
 
 # The generated Makefile shouldn't build anything by itself, just re-run qmake if necessary
 TEMPLATE = aux
diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py
index 1a6976902..2a91923ca 100755
--- a/tools/scripts/take_snapshot.py
+++ b/tools/scripts/take_snapshot.py
@@ -51,8 +51,8 @@ import shutil
 
 import git_submodule as GitSubmodule
 
-qtwebengine_src = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
-os.chdir(qtwebengine_src)
+qtwebengine_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+os.chdir(qtwebengine_root)
 
 def isInGitBlacklist(file_path):
     # We do need all the gyp files.
@@ -129,8 +129,8 @@ def createHardLinkForFile(src, dst):
             raise
 
 
-third_party_upstream = os.path.join(qtwebengine_src, '3rdparty_upstream')
-third_party = os.path.join(qtwebengine_src, '3rdparty')
+third_party_upstream = os.path.join(qtwebengine_root, 'src/3rdparty_upstream')
+third_party = os.path.join(qtwebengine_root, 'src/3rdparty')
 
 def clearDirectory(directory):
     currentDir = os.getcwd()
-- 
GitLab