d5df4f69b062253f42e86564ef6c32248321b1df
[scm/bb/tizen-distro.git] / meta-qt5 / recipes-qt / qt5 / qtbase / 0003-Add-external-hostbindir-option.patch
1 From e263260c50051327e3f7f2ca8c46e014228e0078 Mon Sep 17 00:00:00 2001
2 From: Martin Jansa <Martin.Jansa@gmail.com>
3 Date: Sat, 6 Apr 2013 13:15:07 +0200
4 Subject: [PATCH 03/13] Add -external-hostbindir option
5
6 * when cross-compiling it's sometimes useful to use existing tools from machine
7   (or in OpenEmbedded built with separate native recipe) when building for target
8
9 * this way we can skip bootstraping tools we already have
10
11 * qt_functions: temporary remove isEmpty check
12 * now we assume that every build will provide QT_EXTERNAL_HOST_BINS value
13 * isEmpty works correctly only with qmake variables (e.g. $$FOO -
14   isEmpty(FOO)), but doesn't work with system properties like $$[FOO].
15
16 * cmake: Use OE_QMAKE_PATH_EXTERNAL_HOST_BINS to determine path to host binaries
17
18 Upstream-Status: Pending
19   is a lot better for upstreaming (and it was already sort of approved by
20   Oswald) but in 5.2.0 I've noticed that he added something similar for
21   android builds
22
23 Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
24 Signed-off-by: Simon Busch <morphis@gravedo.de>
25 Signed-off-by: Jonathan Liu <net147@gmail.com>
26 ---
27  configure                                   | 15 +++++++++++++++
28  mkspecs/features/qt_functions.prf           |  6 +++++-
29  mkspecs/features/qt_tool.prf                |  4 ++--
30  qmake/property.cpp                          |  1 +
31  qtbase.pro                                  | 14 +++++++++++---
32  src/corelib/Qt5CoreConfigExtras.cmake.in    |  6 +++---
33  src/corelib/global/qlibraryinfo.cpp         |  3 ++-
34  src/corelib/global/qlibraryinfo.h           |  1 +
35  src/dbus/Qt5DBusConfigExtras.cmake.in       |  4 ++--
36  src/widgets/Qt5WidgetsConfigExtras.cmake.in |  2 +-
37  tools/configure/configureapp.cpp            |  8 ++++++++
38  11 files changed, 51 insertions(+), 13 deletions(-)
39
40 diff --git a/configure b/configure
41 index 3f7b41b..18d1a0b 100755
42 --- a/configure
43 +++ b/configure
44 @@ -777,6 +777,7 @@ QT_HOST_BINS=
45  QT_HOST_LIBS=
46  QT_HOST_DATA=
47  QT_EXT_PREFIX=
48 +QT_EXTERNAL_HOST_BINS=
49  
50  #flags for SQL drivers
51  QT_CFLAGS_PSQL=
52 @@ -896,6 +897,7 @@ while [ "$#" -gt 0 ]; do
53      -testsdir| \
54      -hostdatadir| \
55      -hostbindir| \
56 +    -external-hostbindir| \
57      -hostlibdir| \
58      -extprefix| \
59      -sysroot| \
60 @@ -1110,6 +1112,9 @@ while [ "$#" -gt 0 ]; do
61      extprefix)
62          QT_EXT_PREFIX="$VAL"
63          ;;
64 +    external-hostbindir)
65 +        QT_EXTERNAL_HOST_BINS="$VAL"
66 +        ;;
67      pkg-config)
68          if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
69              CFG_PKGCONFIG="$VAL"
70 @@ -2248,6 +2253,10 @@ Installation options:
71      -hostdatadir <dir> . Data used by qmake will be installed to <dir>
72                           (default HOSTPREFIX)
73  
74 +    -external-hostbindir <dir> Use external host executables instead of building them
75 +                         (not used by defaut)
76 +
77 +
78  Configure options:
79  
80   The defaults (*) are usually acceptable. A plus (+) denotes a default value
81 @@ -2915,6 +2924,11 @@ fi
82  # command line and environment validation
83  #-------------------------------------------------------------------------------
84  
85 +# default is empty, don't call makeabs if it is empty
86 +if [ ! -z "$QT_EXTERNAL_HOST_BINS" ]; then
87 +    QT_EXTERNAL_HOST_BINS=`"$relpath/config.tests/unix/makeabs" "$QT_EXTERNAL_HOST_BINS"`
88 +fi
89 +
90  # update QT_CONFIG to show our current predefined configuration
91  CFG_QCONFIG_PATH=$relpath/src/corelib/global/qconfig-${CFG_QCONFIG}.h
92  case "$CFG_QCONFIG" in
93 @@ -3595,6 +3609,7 @@ static const char qt_configure_prefix_path_strs[][256 + 12] = {
94      "qt_hbinpath=$QT_HOST_BINS",
95      "qt_hlibpath=$QT_HOST_LIBS",
96      "qt_hdatpath=$QT_HOST_DATA",
97 +    "qt_ebinpath=$QT_EXTERNAL_HOST_BINS",
98      "qt_targspec=$shortxspec",
99      "qt_hostspec=$shortspec",
100  #endif
101 diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
102 index 9a4d80e..dfc1cff 100644
103 --- a/mkspecs/features/qt_functions.prf
104 +++ b/mkspecs/features/qt_functions.prf
105 @@ -193,7 +193,11 @@ defineTest(qtAddRpathLink) {
106  defineTest(qtPrepareTool) {
107      cmd = $$eval(QT_TOOL.$${2}.binary)
108      isEmpty(cmd) {
109 -        cmd = $$[QT_HOST_BINS]/$$2
110 +        QT_EXTERNAL_HOST_BINS = $$[QT_EXTERNAL_HOST_BINS]
111 +        isEmpty(QT_EXTERNAL_HOST_BINS): \
112 +            cmd = $$[QT_HOST_BINS]/$$2
113 +        else: \
114 +            cmd = $$[QT_EXTERNAL_HOST_BINS]/$$2
115          exists($${cmd}.pl) {
116              cmd = perl -w $$system_path($${cmd}.pl)
117          } else: contains(QMAKE_HOST.os, Windows) {
118 diff --git a/mkspecs/features/qt_tool.prf b/mkspecs/features/qt_tool.prf
119 index 1d3e88c..9b26adf 100644
120 --- a/mkspecs/features/qt_tool.prf
121 +++ b/mkspecs/features/qt_tool.prf
122 @@ -12,11 +12,11 @@
123  load(qt_app)
124  
125  CONFIG += console
126 +QT_EXTERNAL_HOST_BINS = $$[QT_EXTERNAL_HOST_BINS]
127  
128  # If we are doing a prefix build, create a "module" pri which enables
129  # qtPrepareTool() to work with the non-installed build.
130 -# Non-bootstrapped tools always need this because of the environment setup.
131 -!build_pass:if(!host_build|!force_bootstrap|force_independent) {
132 +!build_pass:if(!host_build|!force_bootstrap|force_independent):isEmpty(QT_EXTERNAL_HOST_BINS) {
133      isEmpty(MODULE):MODULE = $$TARGET
134  
135      !host_build|!force_bootstrap: MODULE_DEPENDS = $$replace(QT, -private$, _private)
136 diff --git a/qmake/property.cpp b/qmake/property.cpp
137 index e50485c..71291ad 100644
138 --- a/qmake/property.cpp
139 +++ b/qmake/property.cpp
140 @@ -75,6 +75,7 @@ static const struct {
141      { "QT_HOST_DATA", QLibraryInfo::HostDataPath, true },
142      { "QT_HOST_BINS", QLibraryInfo::HostBinariesPath, true },
143      { "QT_HOST_LIBS", QLibraryInfo::HostLibrariesPath, true },
144 +    { "QT_EXTERNAL_HOST_BINS", QLibraryInfo::ExternalHostBinariesPath, true },
145      { "QMAKE_SPEC", QLibraryInfo::HostSpecPath, true },
146      { "QMAKE_XSPEC", QLibraryInfo::TargetSpecPath, true },
147  };
148 diff --git a/qtbase.pro b/qtbase.pro
149 index d6861cf..7fb58a3 100644
150 --- a/qtbase.pro
151 +++ b/qtbase.pro
152 @@ -69,18 +69,26 @@ CONFIG -= qt
153  
154  ### installations ####
155  
156 +QT_EXTERNAL_HOST_BINS = $$[QT_EXTERNAL_HOST_BINS]
157 +
158  #qmake
159  qmake.path = $$[QT_HOST_BINS]
160 +qmake.files = $$OUT_PWD/bin/qmake
161 +!isEmpty(QT_EXTERNAL_HOST_BINS) {
162 +   qmake.files = $$[QT_EXTERNAL_HOST_BINS]/bin/qmake
163 +}
164  equals(QMAKE_HOST.os, Windows) {
165 -   qmake.files = $$OUT_PWD/bin/qmake.exe
166 -} else {
167 -   qmake.files = $$OUT_PWD/bin/qmake
168 +   qmake.files = $${qmake.files}.exe
169  }
170  INSTALLS += qmake
171  
172  #syncqt
173  syncqt.path = $$[QT_HOST_BINS]
174  syncqt.files = $$PWD/bin/syncqt.pl
175 +syncqt.files = $$PWD/bin/syncqt.pl
176 +!isEmpty(QT_EXTERNAL_HOST_BINS) {
177 +   syncqt.files = $$[QT_EXTERNAL_HOST_BINS]/bin/syncqt.pl
178 +}
179  INSTALLS += syncqt
180  
181  # If we are doing a prefix build, create a "module" pri which enables
182 diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
183 index 9bda70e..6e3605a 100644
184 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in
185 +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
186 @@ -5,7 +5,7 @@ if (NOT TARGET Qt5::qmake)
187  !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
188      set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
189  !!ELSE
190 -    set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
191 +    set(imported_location \"${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}/qmake$$CMAKE_BIN_SUFFIX\")
192  !!ENDIF
193      _qt5_Core_check_file_exists(${imported_location})
194  
195 @@ -20,7 +20,7 @@ if (NOT TARGET Qt5::moc)
196  !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
197      set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
198  !!ELSE
199 -    set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
200 +    set(imported_location \"${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}/moc$$CMAKE_BIN_SUFFIX\")
201  !!ENDIF
202      _qt5_Core_check_file_exists(${imported_location})
203  
204 @@ -37,7 +37,7 @@ if (NOT TARGET Qt5::rcc)
205  !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
206      set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
207  !!ELSE
208 -    set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
209 +    set(imported_location \"${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}/rcc$$CMAKE_BIN_SUFFIX\")
210  !!ENDIF
211      _qt5_Core_check_file_exists(${imported_location})
212  
213 diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
214 index 69e614f..a95ca35 100644
215 --- a/src/corelib/global/qlibraryinfo.cpp
216 +++ b/src/corelib/global/qlibraryinfo.cpp
217 @@ -336,7 +336,7 @@ QLibraryInfo::isDebugBuild()
218   */
219  
220  static const struct {
221 -    char key[19], value[13];
222 +    char key[21], value[13];
223  } qtConfEntries[] = {
224      { "Prefix", "." },
225      { "Documentation", "doc" }, // should be ${Data}/doc
226 @@ -362,6 +362,7 @@ static const struct {
227      { "HostBinaries", "bin" },
228      { "HostLibraries", "lib" },
229      { "HostData", "." },
230 +    { "ExternalHostBinaries", "" },
231      { "TargetSpec", "" },
232      { "HostSpec", "" },
233  #endif
234 diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
235 index 0b573c2..b5535ee 100644
236 --- a/src/corelib/global/qlibraryinfo.h
237 +++ b/src/corelib/global/qlibraryinfo.h
238 @@ -88,6 +88,7 @@ public:
239          HostBinariesPath,
240          HostLibrariesPath,
241          HostDataPath,
242 +        ExternalHostBinariesPath,
243          TargetSpecPath,
244          HostSpecPath,
245          LastHostPath = HostSpecPath,
246 diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in
247 index 1d94715..301af8f 100644
248 --- a/src/dbus/Qt5DBusConfigExtras.cmake.in
249 +++ b/src/dbus/Qt5DBusConfigExtras.cmake.in
250 @@ -5,7 +5,7 @@ if (NOT TARGET Qt5::qdbuscpp2xml)
251  !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
252      set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
253  !!ELSE
254 -    set(imported_location \"$${CMAKE_BIN_DIR}qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
255 +    set(imported_location \"${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\")
256  !!ENDIF
257      _qt5_DBus_check_file_exists(${imported_location})
258  
259 @@ -20,7 +20,7 @@ if (NOT TARGET Qt5::qdbusxml2cpp)
260  !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
261      set(imported_location \"${_qt5DBus_install_prefix}/$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
262  !!ELSE
263 -    set(imported_location \"$${CMAKE_BIN_DIR}qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
264 +    set(imported_location \"${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\")
265  !!ENDIF
266      _qt5_DBus_check_file_exists(${imported_location})
267  
268 diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
269 index 99d87e2..5621dc0 100644
270 --- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
271 +++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
272 @@ -5,7 +5,7 @@ if (NOT TARGET Qt5::uic)
273  !!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
274      set(imported_location \"${_qt5Widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
275  !!ELSE
276 -    set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\")
277 +    set(imported_location \"${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}/uic$$CMAKE_BIN_SUFFIX\")
278  !!ENDIF
279      _qt5_Widgets_check_file_exists(${imported_location})
280  
281 diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
282 index 90981f6..7d73882 100644
283 --- a/tools/configure/configureapp.cpp
284 +++ b/tools/configure/configureapp.cpp
285 @@ -1215,6 +1215,13 @@ void Configure::parseCmdLine()
286              dictionary[ "QT_EXT_PREFIX" ] = configCmdLine.at(i);
287          }
288  
289 +        else if (configCmdLine.at(i) == "-external-hostbindir") {
290 +            ++i;
291 +            if (i == argCount)
292 +                break;
293 +            dictionary[ "QT_EXTERNAL_HOST_BINS" ] = configCmdLine.at(i);
294 +        }
295 +
296          else if (configCmdLine.at(i) == "-make-tool") {
297              ++i;
298              if (i == argCount)
299 @@ -4006,6 +4013,7 @@ void Configure::generateQConfigCpp()
300                    << "    \"qt_hbinpath=" << formatPath(dictionary["QT_HOST_BINS"]) << "\"," << endl
301                    << "    \"qt_hlibpath=" << formatPath(dictionary["QT_HOST_LIBS"]) << "\"," << endl
302                    << "    \"qt_hdatpath=" << formatPath(dictionary["QT_HOST_DATA"]) << "\"," << endl
303 +                  << "    \"qt_ebinpath=" << formatPath(dictionary["QT_EXTERNAL_HOST_BINS"]) << "\"," << endl
304                    << "    \"qt_targspec=" << targSpec << "\"," << endl
305                    << "    \"qt_hostspec=" << hostSpec << "\"," << endl
306                    << "#endif" << endl
307 -- 
308 2.1.1
309