From 3cb10b94c8dff9a7ea48ea2a681426203327db50 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Mon, 13 Oct 2014 16:25:43 +0300 Subject: Enable to use sources from Qt SDK This enables sources to be fetched from the Qt SDK, if available, instead of internal git repositories. Required for BYOS customers to build B2Qt things. Git repositories in SRC_URI are configured with 'local-uri' parameter, that defines the path to the source code directory inside the Qt SDK. The base path to Qt SDK is set in local.conf when setup-environment.sh in run. Change-Id: I7f5e96fb6b9e9e55cac9d50cefb17830618193b8 Reviewed-by: Eirik Aavitsland Reviewed-by: Andy Nichols --- classes/local-sources.bbclass | 81 +++++++++++++++++++++++++++++++++++++++++++ conf/local.conf.sample | 1 + scripts/setup-environment.sh | 8 +++++ 3 files changed, 90 insertions(+) create mode 100644 classes/local-sources.bbclass diff --git a/classes/local-sources.bbclass b/classes/local-sources.bbclass new file mode 100644 index 0000000..adb484d --- /dev/null +++ b/classes/local-sources.bbclass @@ -0,0 +1,81 @@ +############################################################################# +## +## 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://qt.digia.com/contact-us. +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +python do_fetch () { + src_uri = (d.getVar('SRC_URI', True) or "").split() + if len(src_uri) == 0: + return + + sdk_path = d.getVar('QT_SDK_PATH', True) or "" + if len(sdk_path) != 0: + uris = list(src_uri); + for url in uris: + ud = list(bb.fetch2.decodeurl(url)) + if ("local-uri" in ud[5]): + src_uri.remove(url) + + try: + fetcher = bb.fetch2.Fetch(src_uri, d) + fetcher.download() + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) +} + +python do_unpack () { + src_uri = (d.getVar('SRC_URI', True) or "").split() + if len(src_uri) == 0: + return + + rootdir = d.getVar('WORKDIR', True) + + sdk_path = d.getVar('QT_SDK_PATH', True) or "" + if len(sdk_path) != 0: + uris = list(src_uri); + for url in uris: + ud = list(bb.fetch2.decodeurl(url)) + if ("local-uri" in ud[5]): + unpack_local_uri(ud, d) + src_uri.remove(url) + + try: + fetcher = bb.fetch2.Fetch(src_uri, d) + fetcher.unpack(rootdir) + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) +} + +def unpack_local_uri(ud, d): + import subprocess + rootdir = d.getVar('WORKDIR', True) + sdk_path = d.getVar('QT_SDK_PATH', True) + + destdir = os.path.join(rootdir, ud[5].get("destsuffix", "git")) + srcdir = os.path.join(sdk_path, ud[5].get("local-uri")) + cmd = "cp -vrf %s %s" % (srcdir, destdir) + + if os.path.exists(destdir): + bb.utils.prunedir(destdir) + + ret = subprocess.call(cmd, shell=True) + + if ret != 0: + raise bb.fetch.UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), ud) diff --git a/conf/local.conf.sample b/conf/local.conf.sample index b5986c4..8ceb5cc 100644 --- a/conf/local.conf.sample +++ b/conf/local.conf.sample @@ -280,3 +280,4 @@ INHERIT += "rm_work" ACCEPT_FSL_EULA = "1" LICENSE_FLAGS_WHITELIST = "commercial" +QT_SDK_PATH = "" diff --git a/scripts/setup-environment.sh b/scripts/setup-environment.sh index 92e75aa..cc15776 100755 --- a/scripts/setup-environment.sh +++ b/scripts/setup-environment.sh @@ -75,11 +75,19 @@ if [ ! -f ${PWD}/${BUILDDIR}/conf/bblayers.conf ]; then mkdir -p ${PWD}/${BUILDDIR}/conf cp ${PWD}/sources/meta-b2qt/conf/${LAYERSCONF} ${PWD}/${BUILDDIR}/conf/bblayers.conf + + if [ ! -d ${PWD}/sources/meta-b2qt/.git ]; then + QT_SDK_PATH=$(readlink -f ${PWD}/sources/meta-b2qt/../../) + fi fi export TEMPLATECONF="${PWD}/sources/meta-b2qt/conf" . sources/poky/oe-init-build-env ${BUILDDIR} +# use sources from Qt SDK if that is available +sed -i -e "/QT_SDK_PATH/s:\"\":\"${QT_SDK_PATH}\":" conf/local.conf + +unset QT_SDK_PATH unset BUILDDIR unset TEMPLATECONF unset LAYERSCONF -- cgit v1.2.3-54-g00ecf