summaryrefslogtreecommitdiffstats
path: root/src/buildtools
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-02-09 12:00:15 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-03-01 16:05:00 +0000
commitedd8f2840d85e35bbec905440b0b524d7e0d108e (patch)
tree14f453473b6c1cc0cfec1e1ff8a5b572e4c8de77 /src/buildtools
parent5c42809274288811b386b3cb3cd08000777e37c8 (diff)
Support cross-builds and alternative compilers with GN
Adds GN versions of the gyp_configure targets, to create custom toolchains we can use to override compilers used by GN. Change-Id: Ic3a9cb7e83f845180396faff632f72f9c24f3365 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/buildtools')
-rw-r--r--src/buildtools/buildtools.pro14
-rw-r--r--src/buildtools/configure_host.pro48
-rw-r--r--src/buildtools/configure_target.pro29
-rw-r--r--src/buildtools/gn.pro2
4 files changed, 93 insertions, 0 deletions
diff --git a/src/buildtools/buildtools.pro b/src/buildtools/buildtools.pro
index 4ca21768e..bbf8bd610 100644
--- a/src/buildtools/buildtools.pro
+++ b/src/buildtools/buildtools.pro
@@ -8,3 +8,17 @@ use?(gn) {
gn.depends = ninja
SUBDIRS += gn
}
+
+linux {
+ # configure_host.pro and configure_target.pro are phony pro files that
+ # extract things like compiler and linker from qmake.
+ # Only used on Linux as it is only important for cross-building and alternative compilers.
+ configure_host.file = configure_host.pro
+ configure_target.file = configure_target.pro
+ configure_target.depends = configure_host
+
+ use?(gn) {
+ gn.depends += configure_target
+ }
+ SUBDIRS += configure_host configure_target
+}
diff --git a/src/buildtools/configure_host.pro b/src/buildtools/configure_host.pro
new file mode 100644
index 000000000..217fad775
--- /dev/null
+++ b/src/buildtools/configure_host.pro
@@ -0,0 +1,48 @@
+# Prevent generating a makefile that attempts to create a lib
+TEMPLATE = aux
+
+# Pick up the host toolchain
+option(host_build)
+
+GN_TARGET_CPU = $$gnArch($$QT_ARCH)
+GN_CPU = $$gnArch($$QMAKE_HOST.arch)
+GN_OS = $$gnOS()
+
+clang: GN_CLANG = true
+else: GN_CLANG = false
+
+# We always use the gcc_toolchain, because clang_toolchain is just
+# a broken wrapper around it for Google's custom clang binaries.
+GN_CONTENTS = \
+"import(\"//build/config/sysroot.gni\")" \
+"import(\"//build/toolchain/gcc_toolchain.gni\")" \
+"gcc_toolchain(\"host\") {" \
+" cc = \"$$which($$QMAKE_CC)\" " \
+" cxx = \"$$which($$QMAKE_CXX)\" " \
+" ld = \"$$which($$QMAKE_LINK)\" " \
+" ar = \"$$which(ar)\" " \
+" nm = \"$$which(nm)\" " \
+" toolchain_args = { " \
+" current_os = \"$$GN_OS\" " \
+" current_cpu = \"$$GN_CPU\" " \
+" } " \
+"}" \
+"gcc_toolchain(\"v8_snapshot\") {" \
+" cc = \"$$which($$QMAKE_CC)\" " \
+" cxx = \"$$which($$QMAKE_CXX)\" " \
+" ld = \"$$which($$QMAKE_LINK)\" " \
+" ar = \"$$which(ar)\" " \
+" nm = \"$$which(nm)\" " \
+" toolchain_args = { " \
+" current_os = \"$$GN_OS\" " \
+" current_cpu = \"$$GN_CPU\" " \
+" v8_current_cpu = \"$$GN_TARGET_CPU\" " \
+" } " \
+"}"
+
+
+
+GN_FILE = $$OUT_PWD/../toolchain/BUILD.gn
+!build_pass {
+ write_file($$GN_FILE, GN_CONTENTS)
+}
diff --git a/src/buildtools/configure_target.pro b/src/buildtools/configure_target.pro
new file mode 100644
index 000000000..ab30570e0
--- /dev/null
+++ b/src/buildtools/configure_target.pro
@@ -0,0 +1,29 @@
+# Prevent generating a makefile that attempts to create a lib
+TEMPLATE = aux
+
+GN_CPU = $$gnArch($$QT_ARCH)
+GN_OS = $$gnOS()
+
+clang: GN_CLANG = true
+else: GN_CLANG = false
+
+# We always use the gcc_toolchain, because clang_toolchain is just
+# a broken wrapper around it for Google's custom clang binaries.
+GN_CONTENTS = \
+"gcc_toolchain(\"target\") {" \
+" cc = \"$$which($$QMAKE_CC)\" " \
+" cxx = \"$$which($$QMAKE_CXX)\" " \
+" ld = \"$$which($$QMAKE_LINK)\" " \
+" ar = \"$$which($${CROSS_COMPILE}ar)\" " \
+" nm = \"$$which($${CROSS_COMPILE}nm)\" " \
+" toolchain_args = { " \
+" current_os = \"$$GN_OS\" " \
+" current_cpu = \"$$GN_CPU\" " \
+" is_clang = $$GN_CLANG " \
+" } " \
+"}"
+
+GN_FILE = $$OUT_PWD/../toolchain/BUILD.gn
+!build_pass {
+ write_file($$GN_FILE, GN_CONTENTS, append)
+}
diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro
index e9383bc3f..092888e0e 100644
--- a/src/buildtools/gn.pro
+++ b/src/buildtools/gn.pro
@@ -1,6 +1,8 @@
TEMPLATE = aux
CONFIG += release
+option(host_build)
+
defineReplace(buildGn) {
gn_args = $$1
out = $$gnPath()