mirror of
https://git.yoctoproject.org/poky
synced 2026-04-21 21:32:12 +02:00
external-csl-toolchain: extract version info from the toolchain
(From OE-Core rev: ba59a35cd2b7a0cb5903146d991f5d7f535f4f19) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
79e48d853b
commit
a29939639b
105
meta/conf/distro/include/csl-versions.inc
Normal file
105
meta/conf/distro/include/csl-versions.inc
Normal file
@@ -0,0 +1,105 @@
|
||||
def csl_run(d, cmd, *args):
|
||||
import bb.process
|
||||
import subprocess
|
||||
|
||||
topdir = d.getVar('TOPDIR', True)
|
||||
toolchain_path = d.getVar('EXTERNAL_TOOLCHAIN', True)
|
||||
if not toolchain_path:
|
||||
return 'UNKNOWN', 'UNKNOWN'
|
||||
|
||||
target_prefix = d.getVar('TARGET_PREFIX', True)
|
||||
path = os.path.join(toolchain_path, 'bin', target_prefix + cmd)
|
||||
args = [path] + list(args)
|
||||
|
||||
return bb.process.run(args, cwd=topdir, stderr=subprocess.PIPE)
|
||||
|
||||
def csl_get_version(d):
|
||||
try:
|
||||
stdout, stderr = csl_run(d, 'gcc', '-v')
|
||||
except bb.process.CmdError as exc:
|
||||
bb.error('Failed to obtain CodeSourcery toolchain version: %s' % exc)
|
||||
return 'UNKNOWN'
|
||||
else:
|
||||
last_line = stderr.splitlines()[-1]
|
||||
return last_line
|
||||
|
||||
def csl_get_main_version(d):
|
||||
version = csl_get_version(d)
|
||||
if version != 'UNKNOWN':
|
||||
return version.split()[-1].rstrip(')')
|
||||
else:
|
||||
return version
|
||||
|
||||
def csl_get_gcc_version(d):
|
||||
version = csl_get_version(d)
|
||||
if version != 'UNKNOWN':
|
||||
return version.split()[2]
|
||||
else:
|
||||
return version
|
||||
|
||||
def csl_get_libc_version(d):
|
||||
import os,bb
|
||||
syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}', d)
|
||||
if not syspath:
|
||||
return 'UNKNOWN'
|
||||
|
||||
libpath = syspath + '/libc/lib/'
|
||||
if not os.path.exists(libpath):
|
||||
libpath = syspath + '/libc/sgxx-glibc/lib/'
|
||||
|
||||
if os.path.exists(libpath):
|
||||
for file in os.listdir(libpath):
|
||||
if file.find('libc-') == 0:
|
||||
return file[5:-3]
|
||||
return 'UNKNOWN'
|
||||
|
||||
def csl_get_kernel_version(d):
|
||||
import os,bb
|
||||
syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}', d)
|
||||
if not syspath:
|
||||
return 'UNKNOWN'
|
||||
|
||||
vf = syspath + '/libc/usr/include/linux/version.h'
|
||||
if not os.path.exists(vf):
|
||||
vf = syspath + '/libc/sgxx-glibc/usr/include/linux/version.h'
|
||||
|
||||
try:
|
||||
f = open(vf, 'r')
|
||||
except (OSError, IOError):
|
||||
return 'UNKNOWN'
|
||||
|
||||
l = f.readlines();
|
||||
f.close();
|
||||
for s in l:
|
||||
if s.find('LINUX_VERSION_CODE') > 0:
|
||||
ver = int(s.split()[2])
|
||||
maj = ver / 65536
|
||||
ver = ver % 65536
|
||||
min = ver / 256
|
||||
ver = ver % 256
|
||||
return str(maj)+'.'+str(min)+'.'+str(ver)
|
||||
return 'UNKNOWN'
|
||||
|
||||
def csl_get_gdb_version(d):
|
||||
try:
|
||||
stdout, stderr = csl_run(d, 'gdb', '-v')
|
||||
except CmdError:
|
||||
return 'UNKNOWN'
|
||||
else:
|
||||
first_line = stdout.splitlines()[0]
|
||||
return first_line.split()[-1]
|
||||
|
||||
python csl_version_handler () {
|
||||
if not isinstance(e, bb.event.ConfigParsed):
|
||||
return
|
||||
d = e.data
|
||||
ld = d.createCopy()
|
||||
ld.finalize()
|
||||
|
||||
d.setVar('CSL_VER_MAIN', csl_get_main_version(ld))
|
||||
d.setVar('CSL_VER_GCC', csl_get_gcc_version(ld))
|
||||
d.setVar('CSL_VER_LIBC', csl_get_libc_version(ld))
|
||||
d.setVar('CSL_VER_KERNEL', csl_get_kernel_version(ld))
|
||||
d.setVar('CSL_VER_GDB', csl_get_gdb_version(ld))
|
||||
}
|
||||
addhandler csl_version_handler
|
||||
@@ -108,3 +108,5 @@ def populate_toolchain_links(d):
|
||||
if exc.errno == errno.EEXIST:
|
||||
break
|
||||
bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc))
|
||||
|
||||
require conf/distro/include/csl-versions.inc
|
||||
|
||||
@@ -23,6 +23,7 @@ PROVIDES += "\
|
||||
libgcc \
|
||||
virtual/linux-libc-headers \
|
||||
"
|
||||
PV = "${CSL_VER_MAIN}"
|
||||
PR = "r3"
|
||||
|
||||
#SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/${CSL_TARGET_SYS}/arm-${PV}-${TARGET_PREFIX}i686-pc-linux-gnu.tar.bz2"
|
||||
@@ -97,6 +98,29 @@ PKG_${PN}-extra-nss = "eglibc-extra-nss"
|
||||
PKG_${PN}-thread-db = "eglibc-thread-db"
|
||||
PKG_${PN}-pcprofile = "eglibc-pcprofile"
|
||||
|
||||
PKGV_${PN} = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-dev = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-doc = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-dbg = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-pic = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-utils = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-gconv = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-extra-nss = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-thread-db = "${CSL_VER_LIBC}"
|
||||
PKGV_${PN}-pcprofile = "${CSL_VER_LIBC}"
|
||||
PKGV_catchsegv = "${CSL_VER_LIBC}"
|
||||
PKGV_libsegfault = "${CSL_VER_LIBC}"
|
||||
PKGV_sln = "${CSL_VER_LIBC}"
|
||||
PKGV_nscd = "${CSL_VER_LIBC}"
|
||||
PKGV_ldd = "${CSL_VER_LIBC}"
|
||||
PKGV_libgcc = "${CSL_VER_GCC}"
|
||||
PKGV_libgcc-dev = "${CSL_VER_GCC}"
|
||||
PKGV_libstdc++ = "${CSL_VER_GCC}"
|
||||
PKGV_libstdc++-dev = "${CSL_VER_GCC}"
|
||||
PKGV_linux-libc-headers = "${CSL_VER_KERNEL}"
|
||||
PKGV_linux-libc-headers-dev = "${CSL_VER_KERNEL}"
|
||||
PKGV_gdbserver = "${CSL_VER_GDBSERVER}"
|
||||
|
||||
FILES_libgcc = "${base_libdir}/libgcc_s.so.1"
|
||||
FILES_libgcc-dev = "${base_libdir}/libgcc_s.so"
|
||||
FILES_libstdc++ = "${libdir}/libstdc++.so.*"
|
||||
|
||||
Reference in New Issue
Block a user