[oe] [meta-qt5][PATCH 1/2] qtbase: mkspecs: add default toolchain options

Jeroen Hofstee jhofstee at victronenergy.com
Tue Nov 21 09:51:23 UTC 2017


While most mkspecs use hardcoded compiler names / options, qmake in
meta-qt5 is setup to get them from the environment. While this works
fine with openembedded, it does break normal workflows outside of it.
For example to get the SDK working with Qt Creator either the environmental
script most be sourced first, making it impossible to switch between
different Qt versions or the OE_QMAKE must be set for every project,
otherwise you get cryptic errors like 'make: c: Command not found',
since the compiler name is not set and hence an attempt is made to
execute only the arguments.

Likewise on the target itself, qmake doesn't work without first setting
the OE_QMAKE variables.

This patch adds default toolchains options, so it is no longer required
to set them, but keeps the flexibility to alter them from the environment.

Signed-off-by: Jeroen Hofstee <jhofstee at victronenergy.com>
---
 recipes-qt/qt5/qtbase_git.bb | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/recipes-qt/qt5/qtbase_git.bb b/recipes-qt/qt5/qtbase_git.bb
index 3ac6b21..318c9f7 100644
--- a/recipes-qt/qt5/qtbase_git.bb
+++ b/recipes-qt/qt5/qtbase_git.bb
@@ -221,6 +221,29 @@ do_install_append() {
     # Fix up absolute paths in scripts
     grep -lr /usr/bin/perl ${D}${OE_QMAKE_PATH_QT_ARCHDATA}/ | \
         xargs -r sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,'
+
+
+    # Update the mkspecs to include the default OE toolchain config for the target
+    conf=${D}/${OE_QMAKE_PATH_QT_ARCHDATA}/mkspecs/${XPLATFORM}/qmake.conf
+
+    # qmake already knows the sysroot, see above $$[QT_SYSROOT], so remove the hardcoded sysroot
+    OE_QMAKE_CC_NO_SYSROOT=$(echo ${OE_QMAKE_CC} | sed -e 's!--sysroot=[^ ]*!!g')
+    OE_QMAKE_CXX_NO_SYSROOT=$(echo ${OE_QMAKE_CXX} | sed -e 's!--sysroot=[^ ]*!!g')
+    OE_QMAKE_LINK_NO_SYSROOT=$(echo ${OE_QMAKE_LINK} | sed -e 's!--sysroot=[^ ]*!!g')
+
+    echo "" >> $conf
+    echo "# default compiler options which can be overwritten from the environment" >> $conf
+    echo "isEmpty(QMAKE_AR): QMAKE_AR = ${OE_QMAKE_AR} cqs" >> $conf
+    echo "isEmpty(QMAKE_CC): QMAKE_CC = $OE_QMAKE_CC_NO_SYSROOT" >> $conf
+    echo "isEmpty(QMAKE_CFLAGS): QMAKE_CFLAGS = ${OE_QMAKE_CFLAGS}" >> $conf
+    echo "isEmpty(QMAKE_CXX): QMAKE_CXX = $OE_QMAKE_CXX_NO_SYSROOT" >> $conf
+    echo "isEmpty(QMAKE_CXXFLAGS): QMAKE_CXXFLAGS = ${OE_QMAKE_CXXFLAGS}" >> $conf
+    echo "isEmpty(QMAKE_LINK): QMAKE_LINK = $OE_QMAKE_LINK_NO_SYSROOT" >> $conf
+    echo "isEmpty(QMAKE_LINK_SHLIB): QMAKE_LINK_SHLIB = $OE_QMAKE_LINK_NO_SYSROOT" >> $conf
+    echo "isEmpty(QMAKE_LINK_C): QMAKE_LINK_C = $OE_QMAKE_LINK_NO_SYSROOT" >> $conf
+    echo "isEmpty(QMAKE_LINK_C_SHLIB): QMAKE_LINK_C_SHLIB = $OE_QMAKE_LINK_NO_SYSROOT" >> $conf
+    echo "isEmpty(QMAKE_LFLAGS): QMAKE_LFLAGS = ${OE_QMAKE_LDFLAGS}" >> $conf
+    echo "isEmpty(QMAKE_STRIP): QMAKE_STRIP = ${TARGET_PREFIX}strip" >> $conf
 }
 
 # mkspecs have mac specific scripts that depend on perl and bash
-- 
2.7.4




More information about the Openembedded-devel mailing list