From e8067960ac419c9a47824fa996283d31faa9c309 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 13 May 2015 15:44:02 +0200 Subject: Toolchain: add static device mkspec, suitable for Qt Creator The linux-oe-g++ mkspec used by meta-qt5 depends on the user sourcing the toolchain environment-setup script, which modifies the PATH and sets a long range of environment variables. That is not a "best practice" way of use Qt, and does not allow smooth integration of the toolchain into Qt Creator. Here, we instead create a static mkspec for the toolchain: devices/linux-oe-generic-g++. The toolchain recipe will will the qdevice.pri file with the required compiler flags etc. for the target. Additionally, we introduce an extra .pri file for device-specific settings, so they can be shared between the two mkspecs. Change-Id: Ie5a019524ba6cdddffb71b0c7c28861ddba17fbd Reviewed-by: Samuli Piippo --- meta-fsl-extras/recipes/qt5/qtbase_%.bbappend | 38 ------- .../recipes/qt5/qtbase_%.bbappend | 42 -------- meta-ti-extras/recipes/qt5/qtbase_%.bbappend | 33 ------ .../meta/meta-toolchain-b2qt-embedded-qt5-sdk.bb | 39 ++++++- .../qmake.conf | 14 +++ .../qplatformdefs.h | 2 + recipes-qt/qt5/qtbase/emulator/oe-device-extra.pri | 2 + recipes-qt/qt5/qtbase/mx6/oe-device-extra.pri | 8 ++ recipes-qt/qt5/qtbase/oe-device-extra.pri | 1 + recipes-qt/qt5/qtbase/rpi/oe-device-extra.pri | 10 ++ recipes-qt/qt5/qtbase/ti33x/oe-device-extra.pri | 3 + recipes-qt/qt5/qtbase_%.bbappend | 16 +-- scripts/configure-qtcreator.sh | 118 +++++++++++++++++++++ 13 files changed, 204 insertions(+), 122 deletions(-) delete mode 100644 meta-fsl-extras/recipes/qt5/qtbase_%.bbappend delete mode 100644 meta-raspberrypi-extras/recipes/qt5/qtbase_%.bbappend delete mode 100644 meta-ti-extras/recipes/qt5/qtbase_%.bbappend create mode 100644 recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qmake.conf create mode 100644 recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qplatformdefs.h create mode 100644 recipes-qt/qt5/qtbase/emulator/oe-device-extra.pri create mode 100644 recipes-qt/qt5/qtbase/mx6/oe-device-extra.pri create mode 100644 recipes-qt/qt5/qtbase/oe-device-extra.pri create mode 100644 recipes-qt/qt5/qtbase/rpi/oe-device-extra.pri create mode 100644 recipes-qt/qt5/qtbase/ti33x/oe-device-extra.pri create mode 100755 scripts/configure-qtcreator.sh diff --git a/meta-fsl-extras/recipes/qt5/qtbase_%.bbappend b/meta-fsl-extras/recipes/qt5/qtbase_%.bbappend deleted file mode 100644 index 11fbab1..0000000 --- a/meta-fsl-extras/recipes/qt5/qtbase_%.bbappend +++ /dev/null @@ -1,38 +0,0 @@ -############################################################################# -## -## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -## -## This file is part of the Qt Enterprise Embedded Scripts of the Qt -## framework. -## -## $QT_BEGIN_LICENSE$ -## Commercial License Usage Only -## Licensees holding valid commercial Qt license agreements with Digia -## with an appropriate addendum covering the Qt Enterprise Embedded Scripts, -## may use this file in accordance with the terms contained in said license -## agreement. -## -## For further information use the contact form at -## http://www.qt.io/contact-us. -## -## -## $QT_END_LICENSE$ -## -############################################################################# - -do_configure_prepend_mx6() { - sed -i 's!load(qt_config)!!' ${S}/mkspecs/linux-oe-g++/qmake.conf - cat >> ${S}/mkspecs/linux-oe-g++/qmake.conf <> ${S}/mkspecs/linux-oe-g++/qmake.conf <> ${S}/mkspecs/linux-oe-g++/qmake.conf < ${SDK_DEVICE_PRI} + echo "CROSS_COMPILE = ${SDKPATHNATIVE}${bindir_nativesdk}/${TARGET_SYS}/${TARGET_PREFIX}" >> ${SDK_DEVICE_PRI} + echo "QMAKE_CFLAGS *= ${TARGET_CC_ARCH} --sysroot=${SDKTARGETSYSROOT} ${static_cflags}" >> ${SDK_DEVICE_PRI} + echo "QMAKE_CXXFLAGS *= ${TARGET_CC_ARCH} --sysroot=${SDKTARGETSYSROOT} ${static_cxxflags}" >> ${SDK_DEVICE_PRI} + echo "QMAKE_LFLAGS *= ${TARGET_CC_ARCH} --sysroot=${SDKTARGETSYSROOT} ${TARGET_LDFLAGS}" >> ${SDK_DEVICE_PRI} + + # Setup qt.conf to point at the device mkspec by default + qtconf=${SDK_OUTPUT}/${SDKPATHNATIVE}${OE_QMAKE_PATH_HOST_BINS}/qt.conf + echo 'HostSpec = linux-g++' >> $qtconf + echo 'TargetSpec = devices/linux-oe-generic-g++' >> $qtconf +} + +SDK_POST_INSTALL_COMMAND += "$SUDO_EXEC sed -i -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" $native_sysroot/mkspecs/qdevice.pri ;" diff --git a/recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qmake.conf b/recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qmake.conf new file mode 100644 index 0000000..dadea00 --- /dev/null +++ b/recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qmake.conf @@ -0,0 +1,14 @@ +# +# qmake configuration for using yocto-built b2qt toolchain +# + +include(../common/linux_device_pre.conf) + +QMAKE_PLATFORM += boot2qt + +# Load device-specific qmake.conf part, if any +exists(../../oe-device-extra.pri):include(../../oe-device-extra.pri) + +include(../common/linux_device_post.conf) + +load(qt_config) diff --git a/recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qplatformdefs.h b/recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qplatformdefs.h new file mode 100644 index 0000000..e10ebcf --- /dev/null +++ b/recipes-qt/meta/meta-toolchain-b2qt-embedded-qt5-sdk/qplatformdefs.h @@ -0,0 +1,2 @@ + +#include "../../linux-g++/qplatformdefs.h" diff --git a/recipes-qt/qt5/qtbase/emulator/oe-device-extra.pri b/recipes-qt/qt5/qtbase/emulator/oe-device-extra.pri new file mode 100644 index 0000000..3c0971c --- /dev/null +++ b/recipes-qt/qt5/qtbase/emulator/oe-device-extra.pri @@ -0,0 +1,2 @@ +QMAKE_LIBS_EGL = -lQtGlesStreamClient +QMAKE_LIBS_OPENGL_ES2 = -lQtGlesStreamClient diff --git a/recipes-qt/qt5/qtbase/mx6/oe-device-extra.pri b/recipes-qt/qt5/qtbase/mx6/oe-device-extra.pri new file mode 100644 index 0000000..cf89ae6 --- /dev/null +++ b/recipes-qt/qt5/qtbase/mx6/oe-device-extra.pri @@ -0,0 +1,8 @@ +IMX6_CFLAGS = -DLINUX=1 -DEGL_API_FB=1 +QMAKE_LIBS_EGL += -lEGL +QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL +QMAKE_LIBS_OPENVG += -lOpenVG -lEGL -lGAL +QMAKE_CFLAGS += $$IMX6_CFLAGS +QMAKE_CXXFLAGS += $$IMX6_CFLAGS + +EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/devices/linux-imx6-g++/qeglfshooks_imx6.cpp diff --git a/recipes-qt/qt5/qtbase/oe-device-extra.pri b/recipes-qt/qt5/qtbase/oe-device-extra.pri new file mode 100644 index 0000000..6c4bdd9 --- /dev/null +++ b/recipes-qt/qt5/qtbase/oe-device-extra.pri @@ -0,0 +1 @@ +# This file contains device-specific qmake.conf settings diff --git a/recipes-qt/qt5/qtbase/rpi/oe-device-extra.pri b/recipes-qt/qt5/qtbase/rpi/oe-device-extra.pri new file mode 100644 index 0000000..bddd245 --- /dev/null +++ b/recipes-qt/qt5/qtbase/rpi/oe-device-extra.pri @@ -0,0 +1,10 @@ +QMAKE_INCDIR_EGL = $$[QT_SYSROOT]/usr/include/interface/vcos/pthreads \ + $$[QT_SYSROOT]/usr/include/interface/vmcs_host/linux +QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL} + +QMAKE_LIBS_EGL = -lEGL -lGLESv2 +QMAKE_CFLAGS += $$RPI_CFLAGS +QMAKE_CXXFLAGS += $$RPI_CFLAGS + +EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp +EGLFS_PLATFORM_HOOKS_LIBS = -lbcm_host diff --git a/recipes-qt/qt5/qtbase/ti33x/oe-device-extra.pri b/recipes-qt/qt5/qtbase/ti33x/oe-device-extra.pri new file mode 100644 index 0000000..6a5edd9 --- /dev/null +++ b/recipes-qt/qt5/qtbase/ti33x/oe-device-extra.pri @@ -0,0 +1,3 @@ +QMAKE_LIBS_EGL = -lEGL -lIMGegl -lsrv_um +QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 $${QMAKE_LIBS_EGL} +QMAKE_LIBS_OPENVG = -lOpenVG $${QMAKE_LIBS_EGL} diff --git a/recipes-qt/qt5/qtbase_%.bbappend b/recipes-qt/qt5/qtbase_%.bbappend index 27b476b..340d308 100644 --- a/recipes-qt/qt5/qtbase_%.bbappend +++ b/recipes-qt/qt5/qtbase_%.bbappend @@ -34,20 +34,20 @@ PACKAGECONFIG += " \ tslib \ " +FILESEXTRAPATHS_append := "${THISDIR}/${PN}:" + +SRC_URI += " \ + file://oe-device-extra.pri \ + " + do_configure_prepend() { + install -m 0644 ${WORKDIR}/oe-device-extra.pri ${S}/mkspecs sed -i 's!load(qt_config)!!' ${S}/mkspecs/linux-oe-g++/qmake.conf cat >> ${S}/mkspecs/linux-oe-g++/qmake.conf <> ${S}/mkspecs/linux-oe-g++/qmake.conf < [--remove]" +} + +while test -n "$1"; do + case "$1" in + "--help" | "-h") + printUsage + exit 0 + shift + ;; + "--remove") + REMOVEONLY=1 + shift + ;; + *) + CONFIG=$1 + shift + ;; + esac +done + +if [ ! -f "$CONFIG" ]; then + printUsage + exit 1 +fi + +if [ -z "${SDKTOOL}" ]; then + SDKTOOL="${HOME}/Qt/Tools/QtCreator/bin/sdktool" +fi +if [ ! -x ${SDKTOOL} ]; then + echo "Cannot find 'sdktool'" + exit 1 +fi + +source $CONFIG + +if [ ! -d "${OECORE_NATIVE_SYSROOT}/mkspecs/${MKSPEC}" ]; then + echo Error: $CONFIG is invalid. + exit 1 +fi + +MACHINE=$(grep '^MACHINE' ${OECORE_NATIVE_SYSROOT}/mkspecs/qdevice.pri | cut -d'=' -f2 | tr -d ' ') + +RELEASE=$(qmake -query QT_VERSION) + +BASEID="byos.${RELEASE}.${MACHINE}" + +BASENAME="Custom Qt Embedded" +TOOLCHAINNAME="GCC (${BASENAME} ${RELEASE} ${MACHINE})" +QTNAME="${BASENAME} ${RELEASE} ${MACHINE}" +KITNAME="${BASENAME} ${RELEASE} ${MACHINE} Kit" + +${SDKTOOL} rmKit --id ${BASEID}.kit 2>/dev/null || true +${SDKTOOL} rmQt --id ${BASEID}.qt || true +${SDKTOOL} rmTC --id ProjectExplorer.ToolChain.Gcc:${BASEID}.tc || true + +if [ -n "${REMOVEONLY}" ]; then + echo "Kit removed: ${KITNAME}" + exit 0 +fi + +${SDKTOOL} addTC \ + --id "ProjectExplorer.ToolChain.Gcc:${BASEID}.tc" \ + --name "${TOOLCHAINNAME}" \ + --path "$(type -p ${OE_QMAKE_CXX})" \ + --abi "${ABI}" + +${SDKTOOL} addQt \ + --id "${BASEID}.qt" \ + --name "${QTNAME}" \ + --type "Boot2Qt.QtVersionType" \ + --qmake "$(type -p qmake)" + +${SDKTOOL} addKit \ + --id "${BASEID}.kit" \ + --name "${KITNAME}" \ + --qt "${BASEID}.qt" \ + --debuggerengine "1" \ + --debugger "$(type -p ${GDB})" \ + --sysroot "${SDKTARGETSYSROOT}" \ + --devicetype "Boot2Qt.HwDevice" \ + --toolchain "ProjectExplorer.ToolChain.Gcc:${BASEID}.tc" \ + --icon ":/boot2qt/images/B2Qt_QtC_icon.png" \ + --mkspec "${MKSPEC}" + +echo "Configured Qt Creator with new kit:" +echo " ${KITNAME}" -- cgit v1.2.3-54-g00ecf