oe.external: move common functions here

Also provide external-common.bbclass to wrap its inclusion and setup
associated metadata. This will make easier to search sysroots for files
without pulling in the rest of the external toolchain class.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
This commit is contained in:
Christopher Larson
2015-07-28 13:21:43 -07:00
parent 3dab88e583
commit bfc86fd9c4
15 changed files with 172 additions and 157 deletions

View File

@@ -1,24 +0,0 @@
def external_run(d, cmd, *args):
import subprocess
topdir = d.getVar('TMPDIR', True)
toolchain_path = d.getVar('EXTERNAL_TOOLCHAIN', True)
if toolchain_path:
target_prefix = d.getVar('EXTERNAL_TARGET_SYS', True) + '-'
path = os.path.join(toolchain_path, 'bin', target_prefix + cmd)
args = [path] + list(args)
try:
output = oe.path.check_output(args, cwd=topdir, stderr=subprocess.STDOUT)
except oe.path.CalledProcessError as exc:
import pipes
bb.debug(1, "{0} failed: {1}".format(' '.join(pipes.quote(a) for a in args), exc.output))
except OSError as exc:
import pipes
bb.debug(1, "{0} failed: {1}".format(' '.join(pipes.quote(a) for a in args), str(exc)))
else:
return output
return 'UNKNOWN'
external_run[vardepsexclude] += "EXTERNAL_TOOLCHAIN TMPDIR"

View File

@@ -44,6 +44,9 @@ PREFERRED_PROVIDER_oprofile ??= "oprofile"
PREFERRED_PROVIDER_libgcc = "libgcc-external"
PREFERRED_PROVIDER_linux-libc-headers = "linux-libc-headers-external"
# Pull in our utility functions for use elsewhere
INHERIT += "external-common"
# Ensure that we don't pull in any internal toolchain recipes
INHERIT += "blacklist blacklist_dynamic"
PNBLACKLIST[uclibc] = "not building with an external toolchain"
@@ -189,15 +192,13 @@ python toolchain_sanity_check () {
toolchain_sanity_check[eventmask] = "bb.event.TreeDataPreparationStarted"
addhandler toolchain_sanity_check
require conf/distro/include/external-run.inc
GCCVERSION ?= "${@'.'.join('${GCC_VERSION}'.split('.')[:2])}%"
GCC_VERSION = "${@external_run(d, 'gcc', '-dumpversion').rstrip()}"
GCC_VERSION_allarch = ""
GCC_VERSION[vardepvalue] = "${GCC_VERSION}"
def sourcery_version(d):
version = external_run(d, 'gcc', '-v').splitlines()[-1]
version = oe.external.run(d, 'gcc', '-v').splitlines()[-1]
if version != 'UNKNOWN':
main_version = version.split()[-1].rstrip(')')
if main_version == 'Preview':