Merge "Generate patch files for the git PATCH CLs." into emu-master-dev
diff --git a/patches/Add-custom-chromium-dependencies-pat.patch b/patches/Add-custom-chromium-dependencies-pat.patch
new file mode 100644
index 0000000..90dde95
--- /dev/null
+++ b/patches/Add-custom-chromium-dependencies-pat.patch
@@ -0,0 +1,66 @@
+From 2aa16632ef438e31722b5e9731ead0b5734a54df Mon Sep 17 00:00:00 2001
+From: Joshua Duong <joshuaduong@google.com>
+Date: Wed, 13 Feb 2019 11:13:40 -0800
+Subject: [PATCH] PATCH (Qt 5.12.1): Add custom chromium dependencies path.
+
+We have all of the dependencies to build chromium for linux in our
+prebuilts/android-emulator-build/common/qtwebengine-deps folder, but
+chromium assumes that we have it install in /usr/lib. So this adds
+an environment variable, QTWEBENGINE_DEPS_DIR, that lets you customize
+the location of the dependencies.
+
+Whenever updating the Qt source, please apply this patch.
+
+Change-Id: Ie94cb261747da30522b822640784f73fad4807da
+---
+ .../chromium/build/config/compiler/BUILD.gn      | 16 ++++++++++++----
+ .../chromium/build/config/compiler/compiler.gni  |  6 ++++++
+ 2 files changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/BUILD.gn b/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+index d223a4f6fd..f78031e75a 100644
+--- a/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/BUILD.gn
++++ b/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/BUILD.gn
+@@ -183,10 +183,18 @@ if (use_debug_fission == "default") {
+ # source root and might have conflicting versions of some headers) can remove
+ # this and specify their own include paths.
+ config("default_include_dirs") {
+-  include_dirs = [
+-    root_gen_dir,
+-    "//",
+-  ]
++  if (is_linux) {
++    include_dirs = [
++      root_gen_dir,
++      "//",
++      qtwebengine_deps_dir,
++    ]
++  } else {
++    include_dirs = [
++      root_gen_dir,
++      "//",
++    ]
++  }
+ }
+ 
+ # compiler ---------------------------------------------------------------------
+diff --git a/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/compiler.gni b/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/compiler.gni
+index 431fc3d1fc..7e7020330a 100644
+--- a/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/compiler.gni
++++ b/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/config/compiler/compiler.gni
+@@ -224,6 +224,12 @@ if (symbol_level == -1) {
+   }
+ }
+ 
++# A hack to include our custom toolchain includes for
++# qtwebengine dependencies, because it seems that the chromium toolchain assumes that some of the libraries are in the /usr/lib directory.
++if (is_linux) {
++  qtwebengine_deps_dir = getenv("QTWEBENGINE_DEPS_DIR") + "/include"
++}
++
+ # Assert that the configuration isn't going to hit https://crbug.com/648948.
+ # An exception is made when target_os == "chromeos" as we only use the Android
+ # toolchain there to build relatively small binaries.
+-- 
+2.23.0.rc1.153.gdeed80330f-goog
+
diff --git a/patches/Build-without-using-hermetic-version.patch b/patches/Build-without-using-hermetic-version.patch
new file mode 100644
index 0000000..a6fa78c
--- /dev/null
+++ b/patches/Build-without-using-hermetic-version.patch
@@ -0,0 +1,34 @@
+From 77d317c032d88322635a68df3fd7f8c47b56f955 Mon Sep 17 00:00:00 2001
+From: Joshua Duong <joshuaduong@google.com>
+Date: Wed, 13 Feb 2019 11:24:48 -0800
+Subject: [PATCH] PATCH (Qt 5.12.1): Build without using hermetic version of
+ xcode.
+
+If on a google corp machine, chromium has strict requirements on which
+version of xcode you can use to build chromium. Let's just try to build
+with whatever version we have installed and see what happens ;).
+
+Whenever updating the Qt source, please apply this patch.
+
+Change-Id: I4b5e98f242ea9bedd261fb266713231114b62367
+---
+ .../3rdparty/chromium/build/mac/should_use_hermetic_xcode.py   | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/mac/should_use_hermetic_xcode.py b/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/mac/should_use_hermetic_xcode.py
+index 124cf543d4..289a2bc3ff 100755
+--- a/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/mac/should_use_hermetic_xcode.py
++++ b/qt-everywhere-src-5.12.1/qtwebengine/src/3rdparty/chromium/build/mac/should_use_hermetic_xcode.py
+@@ -32,7 +32,8 @@ def main():
+   if os.environ.get('FORCE_MAC_TOOLCHAIN') or allow_corp:
+     if not mac_toolchain.PlatformMeetsHermeticXcodeRequirements():
+       return "2"
+-    return "1"
++    """ See https://github.com/Homebrew/homebrew-core/issues/21809 """
++    return "0"
+   else:
+     return "0"
+ 
+-- 
+2.23.0.rc1.153.gdeed80330f-goog
+
diff --git a/patches/Comment-out-syncqt-in-qtbase.patch b/patches/Comment-out-syncqt-in-qtbase.patch
new file mode 100644
index 0000000..3ee430f
--- /dev/null
+++ b/patches/Comment-out-syncqt-in-qtbase.patch
@@ -0,0 +1,27 @@
+From a79aa658c153514c867a540f6b3bf8de60996731 Mon Sep 17 00:00:00 2001
+From: Joshua Duong <joshuaduong@google.com>
+Date: Tue, 12 Feb 2019 16:20:17 -0800
+Subject: [PATCH] PATCH (Qt 5.12.1): Comment out syncqt in qtbase.
+
+Whenever updating the Qt source, please apply this patch.
+Change-Id: Ibae2aa1e6ea8df43b585399809cf358326e8dec8
+---
+ qt-everywhere-src-5.12.1/qtbase/qtbase.pro | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/qt-everywhere-src-5.12.1/qtbase/qtbase.pro b/qt-everywhere-src-5.12.1/qtbase/qtbase.pro
+index c0ce0972ef..7986dbea3f 100644
+--- a/qt-everywhere-src-5.12.1/qtbase/qtbase.pro
++++ b/qt-everywhere-src-5.12.1/qtbase/qtbase.pro
+@@ -51,7 +51,7 @@ INSTALLS += fixqt4headers
+ #syncqt
+ syncqt.path = $$[QT_HOST_BINS]
+ syncqt.files = $$PWD/bin/syncqt.pl
+-INSTALLS += syncqt
++#INSTALLS += syncqt
+ 
+ # If we are doing a prefix build, create a "module" pri which enables
+ # qtPrepareTool() to find the non-installed syncqt.
+-- 
+2.23.0.rc1.153.gdeed80330f-goog
+
diff --git a/patches/Don-t-build-GN-with-static-libc.patch b/patches/Don-t-build-GN-with-static-libc.patch
new file mode 100644
index 0000000..b19d6ae
--- /dev/null
+++ b/patches/Don-t-build-GN-with-static-libc.patch
@@ -0,0 +1,34 @@
+From a742c9db6d9923c04d7035bafb54888e87c33cbf Mon Sep 17 00:00:00 2001
+From: Joshua Duong <joshuaduong@google.com>
+Date: Fri, 15 Feb 2019 15:02:37 -0800
+Subject: [PATCH] PATCH (Qt 5.12.1): Don't build GN with static libc++.
+
+We simply don't have the static version in our toolchain, only the
+shared version.
+
+Whenever updating the Qt source, please apply this patch.
+
+Change-Id: I41b365cc03f50455061f4c94956e41bf3489e9cc
+---
+ 5.12.1/qtwebengine/src/3rdparty/gn/build/gen.py | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/5.12.1/qtwebengine/src/3rdparty/gn/build/gen.py b/5.12.1/qtwebengine/src/3rdparty/gn/build/gen.py
+index 87db4c26bc..3e28ff08f6 100755
+--- a/5.12.1/qtwebengine/src/3rdparty/gn/build/gen.py
++++ b/5.12.1/qtwebengine/src/3rdparty/gn/build/gen.py
+@@ -373,7 +373,10 @@ def WriteGNNinja(path, platform, host, options, linux_sysroot):
+         cflags.append('--sysroot=' + linux_sysroot)
+         ldflags.append('--sysroot=' + linux_sysroot)
+       ldflags.extend([
+-          '-static-libstdc++',
++          # When building with clang, this will default to trying to link to a
++          # static version of libc++, which we don't have in our toolchain. We
++          # only have the shared version, so let's not use the static version.
++          #'-static-libstdc++',
+           '-Wl,--as-needed',
+       ])
+       libs.extend([
+-- 
+2.23.0.rc1.153.gdeed80330f-goog
+
diff --git a/patches/Filter-dlls-for-plugin-loading.patch b/patches/Filter-dlls-for-plugin-loading.patch
new file mode 100644
index 0000000..17927d3
--- /dev/null
+++ b/patches/Filter-dlls-for-plugin-loading.patch
@@ -0,0 +1,35 @@
+From b8d6562d19ff281b123360675b84b4dee40c6b08 Mon Sep 17 00:00:00 2001
+From: Joshua Duong <joshuaduong@google.com>
+Date: Thu, 14 Feb 2019 11:53:35 -0800
+Subject: [PATCH] PATCH (Qt 5.12.1): Filter dlls for plugin loading.
+
+Whenever updating the Qt source, please apply this patch.
+
+Change-Id: Ife1ee6b2bc4bc8d8120e503040f5508440bd162f
+---
+ 5.12.1/qtbase/src/corelib/plugin/qfactoryloader.cpp | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/5.12.1/qtbase/src/corelib/plugin/qfactoryloader.cpp b/5.12.1/qtbase/src/corelib/plugin/qfactoryloader.cpp
+index 35c64180d4..9bc1908193 100644
+--- a/5.12.1/qtbase/src/corelib/plugin/qfactoryloader.cpp
++++ b/5.12.1/qtbase/src/corelib/plugin/qfactoryloader.cpp
+@@ -202,8 +202,14 @@ void QFactoryLoader::update()
+             continue;
+ 
+         QStringList plugins = QDir(path).entryList(
+-#ifdef Q_OS_WIN
++#if defined(Q_OS_WIN)
+                     QStringList(QStringLiteral("*.dll")),
++#elif defined(Q_OS_MAC)
++                    QStringList(QStringLiteral("*.dylib*")),
++#elif defined(Q_OS_LIN)
++                    QStringList(QStringLiteral("*.so*")),
++#else
++                    QStringList(QStringLiteral("*")),
+ #endif
+                     QDir::Files);
+         QLibraryPrivate *library = 0;
+-- 
+2.23.0.rc1.153.gdeed80330f-goog
+
diff --git a/patches/Fix-potential-null-pointer-dereferen.patch b/patches/Fix-potential-null-pointer-dereferen.patch
new file mode 100644
index 0000000..25963b0
--- /dev/null
+++ b/patches/Fix-potential-null-pointer-dereferen.patch
@@ -0,0 +1,29 @@
+From 3eb9c3a5f5e821e719e5289041cd9dd8713beca9 Mon Sep 17 00:00:00 2001
+From: Joshua Duong <joshuaduong@google.com>
+Date: Tue, 12 Feb 2019 16:45:33 -0800
+Subject: [PATCH] PATCH (Qt 5.12.1): Fix potential null pointer dereference
+
+Whenever updating the Qt source, please apply this patch.
+
+Change-Id: I52c6dcf7321c97608628fb9b6f4aa8d7b3e2f678
+---
+ qt-everywhere-src-5.12.1/qtbase/src/gui/image/qimage.cpp | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/qt-everywhere-src-5.12.1/qtbase/src/gui/image/qimage.cpp b/qt-everywhere-src-5.12.1/qtbase/src/gui/image/qimage.cpp
+index 830a110d68..f32a93190e 100644
+--- a/qt-everywhere-src-5.12.1/qtbase/src/gui/image/qimage.cpp
++++ b/qt-everywhere-src-5.12.1/qtbase/src/gui/image/qimage.cpp
+@@ -4620,6 +4620,9 @@ int QImage::bitPlaneCount() const
+ */
+ QImage QImage::smoothScaled(int w, int h) const {
+     QImage src = *this;
++    if (src.isNull()) {
++        return QImage();
++    }
+     switch (src.format()) {
+     case QImage::Format_RGB32:
+     case QImage::Format_ARGB32_Premultiplied:
+-- 
+2.23.0.rc1.153.gdeed80330f-goog
+