diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-11-25 19:21:19 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-26 12:01:46 +0100 |
commit | 3c4ccfaa280a3fe4a737b8c585ce441849dfae3b (patch) | |
tree | 8245ec373fd0d57f0503442cf2567dc8dfe037ff | |
parent | 4269f9b3db3cdcb0e7bccf12161a1426cd6654b7 (diff) |
Add build system support for cross compilation
This patch adds support for inheriting target specific cross-compile
settings from Qt.
Change-Id: I964297d776bcc5ac169ce09a52f661d08c5b4b9d
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Reviewed-by: Arvid Nilsson <anilsson@blackberry.com>
-rw-r--r-- | build/build.pro | 33 | ||||
-rwxr-xr-x | build/gyp_qtwebengine | 5 | ||||
-rw-r--r-- | build/qmake/mkspecs/features/functions.prf | 6 | ||||
-rw-r--r-- | build/qmake_extras/target/target.pro | 21 | ||||
-rw-r--r-- | build/qtwebengine_extras.gypi | 30 |
5 files changed, 91 insertions, 4 deletions
diff --git a/build/build.pro b/build/build.pro index 930452e63..9f955a16e 100644 --- a/build/build.pro +++ b/build/build.pro @@ -4,9 +4,38 @@ TEMPLATE = aux +GYP_ARGS = "-D qt_cross_compile=0" +cross_compile { + GYP_ARGS = "-D qt_cross_compile=1 -D os_posix=1" + TOOLCHAIN_SYSROOT = $$[QT_SYSROOT] + !isEmpty(TOOLCHAIN_SYSROOT): GYP_ARGS += "-D sysroot=\"$${TOOLCHAIN_SYSROOT}\"" + + contains(QT_ARCH, "arm") { + # Extract ARM specific compiler options that we have to pass to gyp + MARCH = $$extractCFlag("-march=.*") + MFPU = $$extractCFlag("-mfpu=.*") + MTUNE = $$extractCFlag("-mtune=.*") + MFLOAT = $$extractCFlag("-mfloat-abi=.*") + MARMV = $$replace(MARCH, "armv",) + MARMV = $$split(MARMV,) + MARMV = $$member(MARMV, 0) + MTHUMB = 0 + contains(QMAKE_CFLAGS, "-mthumb"): MTHUMB = 1 + NEON = 0 + contains(MFPU, "neon"): NEON = 1 + + GYP_ARGS += "-D target_arch=arm -D arm_version=\"$$MARMV\" -D arm_arch=\"$$MARCH\"" \ + "-D arm_tune=\"$$MTUNE\" -D arm_fpu=\"$$MFPU\" -D arm_float_abi=\"$$MFLOAT\"" \ + "-D arm_thumb=\"$$MTHUMB\" -D arm_neon=\"$$NEON\"" + } + + # Needed for v8, see chromium/v8/build/toolchain.gypi + GYP_ARGS += "-D CXX=\"$$which($$QMAKE_CXX)\"" +} + !build_pass { - message(Running Gyp...) - !system(python ./gyp_qtwebengine): error("-- running gyp_qtwebengine failed --") + message(Running gyp_qtwebengine $${GYP_ARGS}...) + !system("python ./gyp_qtwebengine $${GYP_ARGS}"): error("-- running gyp_qtwebengine failed --") } ninja.target = invoke_ninja diff --git a/build/gyp_qtwebengine b/build/gyp_qtwebengine index 8a5695ed2..e715cb821 100755 --- a/build/gyp_qtwebengine +++ b/build/gyp_qtwebengine @@ -28,6 +28,7 @@ import gyp # Add paths so that pymod_do_main(...) can import files. sys.path.insert(1, os.path.join(chrome_src, 'tools', 'grit')) +sys.path.insert(1, os.path.join(chrome_src, 'tools', 'generate_shim_headers')) sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit', 'Source', 'core', 'core.gyp', 'scripts')) @@ -135,6 +136,10 @@ if __name__ == '__main__': args.extend(["--depth=" + chrome_src]) args.extend(['-D', 'qtwebengine_src_dir=' + qtwebengine_src]) args.extend(['-D', 'chromium_src_dir=' + chrome_src]) + + if 'qt_cross_compile=1' in sys.argv: + os.environ['GYP_CROSSCOMPILE'] = '1' + # linux_use_gold_binary currently relies on a hardcoded relative path from chromium/src/out/(Release|Debug) # Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system. args.extend(['-D', 'linux_use_gold_binary=0']) diff --git a/build/qmake/mkspecs/features/functions.prf b/build/qmake/mkspecs/features/functions.prf index 78a0272a0..9d90d67bd 100644 --- a/build/qmake/mkspecs/features/functions.prf +++ b/build/qmake/mkspecs/features/functions.prf @@ -18,6 +18,12 @@ defineReplace(getConfigDir) { return("Debug") } +defineReplace(extractCFlag) { + OPTION = $$find(QMAKE_CFLAGS, $$1) + OPTION = $$split(OPTION, =) + return ($$member(OPTION, 1)) +} + defineReplace(findMocables) { input = $$1 for (file, input): \ diff --git a/build/qmake_extras/target/target.pro b/build/qmake_extras/target/target.pro index 39e0b9e32..6d9f414c3 100644 --- a/build/qmake_extras/target/target.pro +++ b/build/qmake_extras/target/target.pro @@ -1,10 +1,29 @@ # Prevent generating a makefile that attempts to create a lib TEMPLATE = aux +TOOLCHAIN_INCLUDES = $${QMAKE_INCDIR_EGL} $${INCLUDEPATH} $${QMAKE_INCDIR} + GYPI_CONTENTS += " ['CC', '$$which($$QMAKE_CC)']," \ " ['CXX', '$$which($$QMAKE_CXX)']," \ " ['LD', '$$which($$QMAKE_LINK)']," -GYPI_CONTENTS += " ]," +GYPI_CONTENTS += " ]," \ + " 'target_defaults': {" \ + " 'target_conditions': [" \ + " ['_toolset==\"target\"', {" \ + " 'include_dirs': [" +for(includes, TOOLCHAIN_INCLUDES) { + GYPI_CONTENTS += " '$$includes'," +} +GYPI_CONTENTS += " ]," \ + " 'cflags': [" +for(cflag, QT_CFLAGS_DBUS) { + GYPI_CONTENTS += " '$$cflag'," +} +GYPI_CONTENTS += " ]," \ + " }]," \ + " ]," \ + " }," + GYPI_CONTENTS += "}" GYPI_FILE = $$absolute_path('build/qmake_extras.gypi', $$QTWEBENGINE_ROOT) diff --git a/build/qtwebengine_extras.gypi b/build/qtwebengine_extras.gypi index dd3d45ac5..2937ee423 100644 --- a/build/qtwebengine_extras.gypi +++ b/build/qtwebengine_extras.gypi @@ -19,5 +19,33 @@ ['exclude', 'browser/renderer_host/render_widget_host_view_qnx\\.(cc|h)$'], ['exclude', 'browser/web_contents/web_contents_view_qnx\\.(cc|h)$'], ], - } + }, + 'conditions': [ + [ 'OS=="linux" and qt_cross_compile==1', { + 'target_defaults': { + 'defines': [ + 'TOOLKIT_QT', + ], + 'target_conditions': [ + ['_toolset=="target"', { + 'ldflags!': ['-L/usr/lib'], # garbage added by icu-config + 'conditions': [ + [ '_target_name=="gl"', { + 'defines': [ + 'GL_GLEXT_PROTOTYPES', + 'EGL_EGLEXT_PROTOTYPES', + ], + }], + ['_type=="shared_library"', { + 'ldflags': [ + # Tell the linker to prefer symbols within the library before looking outside + '-Wl,-shared,-Bsymbolic', + ], + }], + ], + }], + ], + }, + }], + ], } |