From 7f2ea5ab3311441737bd02969fd3fd9b559dde87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Fri, 14 Dec 2018 17:14:05 +0100 Subject: [PATCH] Furher work on instant sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- README | 2 +- appends/meta-qt5/qtbase_%.bbappend | 19 ++++----- classes/instant-paths.bbclass | 4 +- ...bbclass => instant-sysroot-target.bbclass} | 40 +++++++++---------- classes/instant-toolchain-target.bbclass | 28 +++++++++++++ qt5-sdk-recipes/qtcreator-sdk-prepare.bb | 10 ++--- 6 files changed, 66 insertions(+), 37 deletions(-) rename classes/{instant-sysroot-cross.bbclass => instant-sysroot-target.bbclass} (82%) create mode 100644 classes/instant-toolchain-target.bbclass diff --git a/README b/README index a13afc0..91482f8 100644 --- a/README +++ b/README @@ -57,7 +57,7 @@ appends: for the layer is ignored (see conf/layer.conf). classes: - * instant-sysroot-cross.bbclass: Create a sysroot for remote + * instant-sysroot-target.bbclass: Create a sysroot for target remote building/debugging - Yocto's suggested workflows are cumbersome for ad-hoc usage. * instant-sysroot-native.bbclass: Native recipes inheriting this class diff --git a/appends/meta-qt5/qtbase_%.bbappend b/appends/meta-qt5/qtbase_%.bbappend index fbe5572..c7f78aa 100644 --- a/appends/meta-qt5/qtbase_%.bbappend +++ b/appends/meta-qt5/qtbase_%.bbappend @@ -7,30 +7,31 @@ PACKAGECONFIG_DISTRO += " \ inherit instant-paths -do_copy_to_cross_sysroot_append() { +do_copy_to_target_sysroot_append() { # ---------- qt.conf ---------- # create generate_qt_config_file_paths - # copy to cross sysroot + # move to target sysroot qtconf=`basename ${OE_QMAKE_QTCONF_PATH}` - targetpath=${INSTANT_CROSS_PATH}${OE_QMAKE_PATH_HOST_BINS} - cp -f "${OE_QMAKE_QTCONF_PATH}" "$targetpath" + targetpath=${INSTANT_TARGET_PATH}${OE_QMAKE_PATH_HOST_BINS} + rm -f "$targetpath/$qtconf" + mv "${OE_QMAKE_QTCONF_PATH}" "$targetpath" echo "${OE_QMAKE_PATH_HOST_BINS}/$qtconf" >> ${INSTANT_MANIFEST} # adjust to instant sysroot sed -i \ -e 's:${STAGING_DIR_NATIVE}:${INSTANT_NATIVE_PATH}:g' \ - -e 's:${STAGING_DIR_HOST}:${INSTANT_CROSS_PATH}:g' \ + -e 's:${STAGING_DIR_HOST}:${INSTANT_TARGET_PATH}:g' \ -e 's:^HostBinaries =.*:HostBinaries = ${INSTANT_NATIVE_PATH}${bindir}${QT_DIR_NAME}:g' \ "$targetpath/$qtconf" # ---------- mkspecs qmake.conf ---------- - rm ${INSTANT_CROSS_PATH}${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/qmake.conf + rm ${INSTANT_TARGET_PATH}${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/qmake.conf cp -f "${WORKDIR}/packages-split/${PN}-mkspecs${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/qmake.conf" \ - "${INSTANT_CROSS_PATH}${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/" + "${INSTANT_TARGET_PATH}${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/" sed -i \ - -e 's:${DEBUG_PREFIX_MAP}:-fdebug-prefix-map=${INSTANT_CROSS_PATH}= -fdebug-prefix-map=${INSTANT_NATIVE_PATH}=:g' \ - "${INSTANT_CROSS_PATH}${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/qmake.conf" + -e 's:${DEBUG_PREFIX_MAP}:-fdebug-prefix-map=${INSTANT_TARGET_PATH}= -fdebug-prefix-map=${INSTANT_NATIVE_PATH}=:g' \ + "${INSTANT_TARGET_PATH}${libdir}${QT_DIR_NAME}/mkspecs/${XPLATFORM}/qmake.conf" } diff --git a/classes/instant-paths.bbclass b/classes/instant-paths.bbclass index 14de5f0..2645fb2 100644 --- a/classes/instant-paths.bbclass +++ b/classes/instant-paths.bbclass @@ -1,5 +1,5 @@ # This is where instant native sysroot is installed to INSTANT_NATIVE_PATH = "${TMPDIR}/sysroot-instant-native" -# This is where instant cross sysroot is installed to -INSTANT_CROSS_PATH = "${TMPDIR}/sysroot-instant-cross-${MACHINE_ARCH}" +# This is where instant target sysroot is installed to +INSTANT_TARGET_PATH = "${TMPDIR}/sysroot-instant-target-${MACHINE_ARCH}" diff --git a/classes/instant-sysroot-cross.bbclass b/classes/instant-sysroot-target.bbclass similarity index 82% rename from classes/instant-sysroot-cross.bbclass rename to classes/instant-sysroot-target.bbclass index 3fd23d5..a81b96b 100644 --- a/classes/instant-sysroot-cross.bbclass +++ b/classes/instant-sysroot-target.bbclass @@ -9,10 +9,10 @@ # To achieve, a debug sysroot is build with low cost: # # * All files are hard-linked to recipe's ${WORKDIR}/package -# * Additional build time for task do_copy_to_cross_sysroot for most recipes is < 1s +# * Additional build time for task do_copy_to_target_sysroot for most recipes is < 1s # # to enable debug sysroot build set: -# 'INHERIT += "instant-sysroot-cross"' +# 'INHERIT += "instant-sysroot-target"' # in your local.conf # # to debug by remote do: @@ -24,7 +24,7 @@ # 'gdbserver :5000 /usr/bin/thunar' # # ON BUILD HOST (suggested IDE: QtCreator) -# * build gdb-cross- (done automatically on images if this class +# * build gdb-target- (done automatically on images if this class # enabled - see EXTRA_IMAGEDEPENDS below) # * in QtCreator select Menu Debug/Start Debugging/Attach to Running Debug Server # -> Dialog 'Start Debugger' opens @@ -32,8 +32,8 @@ # The settings are kept so 1.-6. have to be done once only. # 1. Create a Kit by 'Add' -> further dialog opens # 2. Select an name for the Kit e.g 'OE' -# 3. Set sysroot (see INSTANT_CROSS_PATH in instant-path.bbclass): -# ${TMPDIR}/sysroot-instant-cross-${MACHINE_ARCH} +# 3. Set sysroot (see INSTANT_TARGET_PATH in instant-path.bbclass): +# ${TMPDIR}/sysroot-instant-target-${MACHINE_ARCH} # 4. Select compilers (it is not necessary for debug but without QTCreator won't enable Kit) for C and C++ e.g: # C: '/sysroot-instant-native/usr/bin/arm-mortsgna-linux-gnueabi/arm-mortsgna-linux-gnueabi-gcc' # C++: '/sysroot-instant-native/usr/bin/arm-mortsgna-linux-gnueabi/arm-mortsgna-linux-gnueabi-g++' @@ -41,7 +41,7 @@ # GDB: '/sysroot-instant-native/usr/bin/arm-mortsgna-linux-gnueabi/arm-mortsgna-linux-gnueabi-gdb' # 6. Select 'OK' in Options dialog -> 'Start Debugger' should be back on top # * Make sure 'OE' Kit is selected -# * Browse for executable e.g '/sysroot-instant-cross/usr/bin/thunar' +# * Browse for executable e.g '/sysroot-instant-target/usr/bin/thunar' # * Set IP:Port of target machine e.g '192.168.2.108:5000' # * Select 'OK' # @@ -56,27 +56,27 @@ EXTRA_IMAGEDEPENDS += "gdb-cross-${TARGET_ARCH} gdb" python __anonymous () { if d.getVar('CLASSOVERRIDE') != 'class-target': - bb.build.deltask('do_copy_to_cross_sysroot', d) + bb.build.deltask('do_copy_to_target_sysroot', d) } -INSTANT_MANIFEST = "${INSTANT_CROSS_PATH}/manifests/${PN}" +INSTANT_MANIFEST = "${INSTANT_TARGET_PATH}/manifests/${PN}" -do_copy_to_cross_sysroot() { +do_copy_to_target_sysroot() { # ---------- bail out on package-less recipes ---------- if [ ! -d "${WORKDIR}/packages-split" -o ! -d ${WORKDIR}/package ]; then exit 0 fi # ---------- remove old sources ---------- - rm -rf ${INSTANT_CROSS_PATH}/usr/src/debug/${PN} + rm -rf ${INSTANT_TARGET_PATH}/usr/src/debug/${PN} # ---------- remove old files in manifest and manifest ---------- if [ -f ${INSTANT_MANIFEST} ] ; then echo "Old manifest ${INSTANT_MANIFEST} found - remove files..." # remove old files from sysroot for file in `cat ${INSTANT_MANIFEST}` ; do - if ! rm "${INSTANT_CROSS_PATH}/$file" 2> /dev/null; then - echo "Tried to delete '${INSTANT_CROSS_PATH}/$file' but it is not there! A look into mainfest creation at '${INSTANT_MANIFEST}' might help." + if ! rm "${INSTANT_TARGET_PATH}/$file" 2> /dev/null; then + echo "Tried to delete '${INSTANT_TARGET_PATH}/$file' but it is not there! A look into mainfest creation at '${INSTANT_MANIFEST}' might help." fi done # remove old manifest @@ -85,12 +85,12 @@ do_copy_to_cross_sysroot() { # ---------- hard link source code files ---------- if [ -d ${WORKDIR}/package/usr/src/debug/${PN} ] ; then - mkdir -p ${INSTANT_CROSS_PATH}/usr/src/debug/${PN} - hardlinkdir ${WORKDIR}/package/usr/src/debug/${PN} ${INSTANT_CROSS_PATH}/usr/src/debug/${PN} + mkdir -p ${INSTANT_TARGET_PATH}/usr/src/debug/${PN} + hardlinkdir ${WORKDIR}/package/usr/src/debug/${PN} ${INSTANT_TARGET_PATH}/usr/src/debug/${PN} fi # ---------- names of binaries and debuginfo -> manifest ---------- - mkdir -p ${INSTANT_CROSS_PATH}/manifests + mkdir -p ${INSTANT_TARGET_PATH}/manifests # get path to library-link once only if [ "${PN}" = "glibc-locale" ] ; then PACK_SPLIT_LIB_LINK_SEARCH_PATH=`find ${WORKDIR}/packages-split -mindepth 1 -maxdepth 1 -type d ! -name '*-dbg' ! -name '*-dev' ! -name '*-staticdev' ! -name '*-doc' ! -name 'glibc*-localedata-*' ! -name 'glibc-charmap-*' ! -name 'locale-base-*'` @@ -159,17 +159,17 @@ do_copy_to_cross_sysroot() { for file in `cat ${INSTANT_MANIFEST}` ; do file=`echo $file | cut -c 2-` if [ -e $file ] ; then - echo -n $file | cpio --null -pdlu ${INSTANT_CROSS_PATH} > /dev/null 2>&1 + echo -n $file | cpio --null -pdlu ${INSTANT_TARGET_PATH} > /dev/null 2>&1 fi done fi } -addtask copy_to_cross_sysroot after do_package before do_build +addtask copy_to_target_sysroot after do_package before do_build # same as do package -do_copy_to_cross_sysroot[vardeps] = "${PACKAGEBUILDPKGD} ${PACKAGESPLITFUNCS} ${PACKAGEFUNCS} ${@gen_packagevar(d)}" +do_copy_to_target_sysroot[vardeps] = "${PACKAGEBUILDPKGD} ${PACKAGESPLITFUNCS} ${PACKAGEFUNCS} ${@gen_packagevar(d)}" -do_copy_to_cross_sysroot[stamp-extra-info] = "${MACHINE_ARCH}" +do_copy_to_target_sysroot[stamp-extra-info] = "${MACHINE_ARCH}" -do_build[recrdeptask] += "do_copy_to_cross_sysroot" +do_build[recrdeptask] += "do_copy_to_target_sysroot" diff --git a/classes/instant-toolchain-target.bbclass b/classes/instant-toolchain-target.bbclass new file mode 100644 index 0000000..de30396 --- /dev/null +++ b/classes/instant-toolchain-target.bbclass @@ -0,0 +1,28 @@ +#------------------------------------------------------------------------------ +# class for instant toolchain +#------------------------------------------------------------------------------ + +inherit instant-paths + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +do_compile[postfuncs] += "${COMPILE_POST_TARGET}" +COMPILE_POST_TARGET = "" +COMPILE_POST_TARGET_class-target = "instant_compile_target" + +INSTANTPOPULATE_TOOLCHAIN_VARS = " \ + CC \ + CFLAGS \ +" + +python instant_compile_target () { + # create sourceable script that exports variables necessary + for envvar in d.getVar('INSTANTPOPULATE_TOOLCHAIN_VARS').split(): + content = d.getVar(envvar).strip() + line = 'export %s="%s"' % (envvar, content) + line = line.replace(d.getVar('DEBUG_PREFIX_MAP'),'-fdebug-prefix-map=%s= -fdebug-prefix-map=%s=' % (d.getVar('INSTANT_TARGET_PATH'), d.getVar('INSTANT_NATIVE_PATH') )) + line = line.replace(d.getVar('STAGING_DIR_NATIVE'),d.getVar('INSTANT_NATIVE_PATH')) + line = line.replace(d.getVar('STAGING_DIR_HOST'),d.getVar('INSTANT_TARGET_PATH')) + print(line) + print(d.getVar('DEBUG_PREFIX_MAP')) +} diff --git a/qt5-sdk-recipes/qtcreator-sdk-prepare.bb b/qt5-sdk-recipes/qtcreator-sdk-prepare.bb index 6141c51..0d7ffc0 100644 --- a/qt5-sdk-recipes/qtcreator-sdk-prepare.bb +++ b/qt5-sdk-recipes/qtcreator-sdk-prepare.bb @@ -2,21 +2,19 @@ SUMMARY = "Prepare environment for cross building/debugging with QtCreator" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -PACKAGE_ARCH = "${MACHINE_ARCH}" - -inherit qmake5_base instant-paths +inherit qmake5_base instant-toolchain-target DEPENDS = "qtbase" deltask do_prepare_recipe_sysroot -do_install[depends] = "qtbase:do_copy_to_cross_sysroot" +do_install[depends] = "qtbase:do_copy_to_target_sysroot" do_install[nostamp] = "1" do_install() { # inject qt.conf into native sysroot qtconf=`basename ${OE_QMAKE_QTCONF_PATH}` - sourcepath=${INSTANT_CROSS_PATH}${OE_QMAKE_PATH_HOST_BINS} + sourcepath=${INSTANT_TARGET_PATH}${OE_QMAKE_PATH_HOST_BINS} targetpath=${INSTANT_NATIVE_PATH}${OE_QMAKE_PATH_HOST_BINS} # be sure we remove old link (if any...) rm -f $targetpath/$qtconf @@ -25,6 +23,8 @@ do_install() { ALLOW_EMPTY_${PN} = "1" +# An image installing this requires the following packages at least for working +# instant sdk support RDEPENDS_${PN} = " \ qtbase \ gdbserver \