xref: /OK3568_Linux_fs/buildroot/package/qt5/qt5webengine/0002-Add-python3-build-support.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 1e299a6c9eeb08555208b76623e453d8ab96b6e3 Mon Sep 17 00:00:00 2001
2From: James Hilliard <james.hilliard1@gmail.com>
3Date: Fri, 4 Feb 2022 16:16:35 -0700
4Subject: [PATCH] Add python3 build support
5
6Adapted from:
7https://github.com/archlinux/svntogit-packages/blob/6edf5f1aaea952d046aff89a2e0175258fe77361/trunk/qt5-webengine-python3.patch
8
9Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
10---
11 configure.pri                     | 13 ++++++-------
12 mkspecs/features/functions.prf    |  6 +++---
13 src/buildtools/config/support.pri | 10 +++++-----
14 src/buildtools/configure.json     | 18 +++++++++---------
15 4 files changed, 23 insertions(+), 24 deletions(-)
16
17diff --git a/configure.pri b/configure.pri
18index e072961f..6fec7b20 100644
19--- a/configure.pri
20+++ b/configure.pri
21@@ -13,8 +13,7 @@ defineTest(isPythonVersionSupported) {
22     python_version = $$split(python_version, ',')
23     python_major_version = $$first(python_version)
24     greaterThan(python_major_version, 2) {
25-        qtLog("Python version 3 is not supported by Chromium.")
26-        return(false)
27+        return(true)
28     }
29     python_minor_version = $$member(python_version, 1)
30     python_patch_version = $$member(python_version, 2)
31@@ -52,10 +51,10 @@ defineTest(qtConfReport_jumboBuild) {
32     qtConfReportPadded($${1}, $$mergeLimit)
33 }
34
35-defineTest(qtConfTest_detectPython2) {
36-    python = $$qtConfFindInPath("python2$$EXE_SUFFIX")
37+defineTest(qtConfTest_detectPython) {
38+    python = $$qtConfFindInPath("python$$EXE_SUFFIX")
39     isEmpty(python) {
40-        qtLog("'python2$$EXE_SUFFIX' not found in PATH. Checking for 'python$$EXE_SUFFIX'.")
41+        qtLog("'python$$EXE_SUFFIX' not found in PATH. Checking for 'python$$EXE_SUFFIX'.")
42         python = $$qtConfFindInPath("python$$EXE_SUFFIX")
43     }
44     isEmpty(python) {
45@@ -63,11 +62,11 @@ defineTest(qtConfTest_detectPython2) {
46         return(false)
47     }
48     !isPythonVersionSupported($$python) {
49-        qtLog("A suitable Python 2 executable could not be located.")
50+        qtLog("A suitable Python executable could not be located.")
51         return(false)
52     }
53
54-    # Make tests.python2.location available in configure.json.
55+    # Make tests.python.location available in configure.json.
56     $${1}.location = $$clean_path($$python)
57     export($${1}.location)
58     $${1}.cache += location
59diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf
60index 2750d707..9fda13d0 100644
61--- a/mkspecs/features/functions.prf
62+++ b/mkspecs/features/functions.prf
63@@ -39,11 +39,11 @@ defineReplace(which) {
64
65 # Returns the unquoted path to the python executable.
66 defineReplace(pythonPath) {
67-    isEmpty(QMAKE_PYTHON2) {
68+    isEmpty(QMAKE_PYTHON) {
69         # Fallback for building QtWebEngine with Qt < 5.8
70-        QMAKE_PYTHON2 = python
71+        QMAKE_PYTHON = python
72     }
73-    return($$QMAKE_PYTHON2)
74+    return($$QMAKE_PYTHON)
75 }
76
77 # Returns the python executable for use with shell / make targets.
78diff --git a/src/buildtools/config/support.pri b/src/buildtools/config/support.pri
79index e7f869a1..1bf2c5d7 100644
80--- a/src/buildtools/config/support.pri
81+++ b/src/buildtools/config/support.pri
82@@ -21,7 +21,7 @@ defineReplace(qtwebengine_checkWebEngineCoreError) {
83     !qtwebengine_checkForGperf(QtWebEngine):return(false)
84     !qtwebengine_checkForBison(QtWebEngine):return(false)
85     !qtwebengine_checkForFlex(QtWebEngine):return(false)
86-    !qtwebengine_checkForPython2(QtWebEngine):return(false)
87+    !qtwebengine_checkForPython(QtWebEngine):return(false)
88     !qtwebengine_checkForNodejs(QtWebEngine):return(false)
89     !qtwebengine_checkForSanitizer(QtWebEngine):return(false)
90     linux:!qtwebengine_checkForPkgCfg(QtWebEngine):return(false)
91@@ -51,7 +51,7 @@ defineReplace(qtwebengine_checkPdfError) {
92     !qtwebengine_checkForGperf(QtPdf):return(false)
93     !qtwebengine_checkForBison(QtPdf):return(false)
94     !qtwebengine_checkForFlex(QtPdf):return(false)
95-    !qtwebengine_checkForPython2(QtPdf):return(false)
96+    !qtwebengine_checkForPython(QtPdf):return(false)
97     !qtwebengine_checkForSanitizer(QtPdf):return(false)
98     linux:!qtwebengine_checkForPkgCfg(QtPdf):return(false)
99     linux:!qtwebengine_checkForHostPkgCfg(QtPdf):return(false)
100@@ -143,10 +143,10 @@ defineTest(qtwebengine_checkForFlex) {
101     return(true)
102 }
103
104-defineTest(qtwebengine_checkForPython2) {
105+defineTest(qtwebengine_checkForPython) {
106     module = $$1
107-    !qtConfig(webengine-python2) {
108-        qtwebengine_skipBuild("Python version 2 (2.7.5 or later) is required to build $${module}.")
109+    !qtConfig(webengine-python) {
110+        qtwebengine_skipBuild("Python is required to build $${module}.")
111         return(false)
112     }
113     return(true)
114diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json
115index 88d1790c..032aa665 100644
116--- a/src/buildtools/configure.json
117+++ b/src/buildtools/configure.json
118@@ -295,9 +295,9 @@
119             "label": "system ninja",
120             "type": "detectNinja"
121         },
122-        "webengine-python2": {
123-            "label": "python2",
124-            "type": "detectPython2",
125+        "webengine-python": {
126+            "label": "python",
127+            "type": "detectPython",
128             "log": "location"
129         },
130         "webengine-winversion": {
131@@ -374,7 +374,7 @@
132                          && features.webengine-gperf
133                          && features.webengine-bison
134                          && features.webengine-flex
135-                         && features.webengine-python2
136+                         && features.webengine-python
137                          && features.webengine-nodejs
138                          && (!config.sanitizer || features.webengine-sanitizer)
139                          && (!config.linux || features.pkg-config)
140@@ -400,7 +400,7 @@
141                          && features.webengine-gperf
142                          && features.webengine-bison
143                          && features.webengine-flex
144-                         && features.webengine-python2
145+                         && features.webengine-python
146                          && (!config.sanitizer || features.webengine-sanitizer)
147                          && (!config.linux || features.pkg-config)
148                          && (!config.linux || features.webengine-host-pkg-config)
149@@ -423,12 +423,12 @@
150             "autoDetect": "features.private_tests",
151             "output": [ "privateFeature" ]
152         },
153-        "webengine-python2": {
154-            "label": "python2",
155-            "condition": "tests.webengine-python2",
156+        "webengine-python": {
157+            "label": "python",
158+            "condition": "tests.webengine-python",
159             "output": [
160                 "privateFeature",
161-                { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python2.location" }
162+                { "type": "varAssign", "name": "QMAKE_PYTHON", "value": "tests.webengine-python.location" }
163             ]
164         },
165         "webengine-gperf": {
166--
1672.25.1
168
169