From 20dccb84e3518561d32237fee4ad11500c9bbe0f Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Wed, 25 Jan 2017 13:43:44 +0100
Subject: [PATCH] Fix build with 5.8 and make embedded configurable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Avoid checking features only available in 5.9 directly. This also
changes the embedded-build configuration to being a feature that can be
set at configure time.

Change-Id: I9b42dcf696734a83e5c8d6e1cc07562cbeb3f993
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
---
 configure.json                             | 17 +++++++++++++++--
 configure.pri                              |  9 +++++++++
 src/core/gyp_run.pro                       |  2 +-
 tools/qmake/mkspecs/features/configure.prf | 11 ++++++++---
 4 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/configure.json b/configure.json
index 5799dafa3..fd89230b6 100644
--- a/configure.json
+++ b/configure.json
@@ -9,6 +9,7 @@
     "commandline": {
         "options": {
             "alsa": "boolean",
+            "embedded": "boolean",
             "pepper-plugins": "boolean",
             "printing-and-pdf": "boolean",
             "proprietary-codecs": "boolean",
@@ -41,10 +42,21 @@
         "gn": {
             "label": "system gn",
             "type": "detectGn"
+        },
+        "embedded": {
+            "label": "embedded",
+            "type": "embedded"
         }
     },
 
     "features": {
+        "embedded": {
+            "label": "Embedded build",
+            "condition": "config.unix",
+            "autoDetect": "tests.embedded",
+            "purpose": "Enables the embedded build configuration",
+            "output": [ "privateFeature" ]
+        },
         "alsa": {
             "label": "ALSA",
             "condition": "config.unix && libs.alsa",
@@ -58,14 +70,14 @@
         },
         "pepper-plugins": {
             "label": "Pepper Plugins",
-            "autoDetect": "!features.cross_compile",
+            "autoDetect": "!features.embedded",
             "purpose": "Enables use of Pepper Flash and Widevine plugins",
             "output": [ "privateFeature" ]
         },
         "printing-and-pdf": {
             "label": "Printing and PDF",
             "condition": "module.printsupport && features.printer",
-            "autoDetect": "!features.cross_compile",
+            "autoDetect": "!features.embedded",
             "purpose": "Enables printing and output to PDF",
             "output": [ "privateFeature" ]
         },
@@ -97,6 +109,7 @@
         {
             "section": "Qt WebEngine",
             "entries": [
+                "embedded",
                 "pepper-plugins",
                 "printing-and-pdf",
                 "proprietary-codecs",
diff --git a/configure.pri b/configure.pri
index b6693aecf..23f31686e 100644
--- a/configure.pri
+++ b/configure.pri
@@ -23,3 +23,12 @@ defineTest(qtConfTest_detectGn) {
     qtLog("Building own gn")
     return(false)
 }
+
+defineTest(qtConfTest_embedded) {
+    lessThan(QT_MINOR_VERSION, 9) {
+        cross_compile: return(true)
+        return(false)
+    }
+    $$qtConfEvaluate("features.cross_compile"): return(true)
+    return(false)
+}
diff --git a/src/core/gyp_run.pro b/src/core/gyp_run.pro
index c583845e9..fa8f73de4 100644
--- a/src/core/gyp_run.pro
+++ b/src/core/gyp_run.pro
@@ -9,7 +9,7 @@ isQtMinimum(5, 8) {
 
 TEMPLATE = aux
 
-cross_compile {
+contains(WEBENGINE_CONFIG, embedded_build) {
     GYP_ARGS = "-D qt_cross_compile=1"
     posix: GYP_ARGS += "-D os_posix=1"
     qnx: include(config/embedded_qnx.pri)
diff --git a/tools/qmake/mkspecs/features/configure.prf b/tools/qmake/mkspecs/features/configure.prf
index 759638877..c0eead57c 100644
--- a/tools/qmake/mkspecs/features/configure.prf
+++ b/tools/qmake/mkspecs/features/configure.prf
@@ -28,6 +28,11 @@ defineTest(runConfigure) {
         qtConfig(printing-and-pdf): WEBENGINE_CONFIG += use_printing use_pdf
         qtConfig(proprietary-codecs): WEBENGINE_CONFIG += use_proprietary_codecs
         qtConfig(spellchecker): WEBENGINE_CONFIG += use_spellchecker
+        qtConfig(embedded): WEBENGINE_CONFIG += embedded_build
+    } else {
+        cross_compile: WEBENGINE_CONFIG += embedded_build
+    }
+    isQtMinimum(5, 9) {
         qtConfig(appstore-compliant): WEBENGINE_CONFIG += use_appstore_compliant_code
     }
 
@@ -36,14 +41,14 @@ defineTest(runConfigure) {
         !config_khr:skipBuild("khronos development headers appear to be missing (mesa/libegl1-mesa-dev)")
 
         REQUIRED_PACKAGES = dbus-1 fontconfig
-        !cross_compile: qtConfig(xcb): REQUIRED_PACKAGES += libdrm xcomposite xcursor xi xrandr xscrnsaver xtst
+        !contains(WEBENGINE_CONFIG, embedded_build): qtConfig(xcb): REQUIRED_PACKAGES += libdrm xcomposite xcursor xi xrandr xscrnsaver xtst
         qtConfig(pulseaudio): REQUIRED_PACKAGES += libpulse
         qtConfig(system-png): REQUIRED_PACKAGES += libpng
         qtConfig(system-harfbuzz) {
              packagesExist("\'harfbuzz >= 1.2.0\'"): WEBENGINE_CONFIG += use_system_harfbuzz
              else: log("System harfbuzz is too old (min. version 1.2). Using Chromium's copy.$${EOL}")
         }
-        !cross_compile: REQUIRED_PACKAGES += libpci
+        !contains(WEBENGINE_CONFIG, embedded_build): REQUIRED_PACKAGES += libpci
 
         for(package, $$list($$REQUIRED_PACKAGES)) {
             !packagesExist($$package):skipBuild("Unmet dependency: $$package")
@@ -84,7 +89,7 @@ defineTest(runConfigure) {
             WEBENGINE_CONFIG += use_bundled_snappy
         }
 
-        !cross_compile {
+        !contains(WEBENGINE_CONFIG, embedded_build) {
             packagesExist(nss): WEBENGINE_CONFIG += use_nss
             else: log("System NSS not found, BoringSSL will be used.$${EOL}")
         }
-- 
GitLab