Skip to contentSkip to conversation

FIXME: overlay .inc files for external-arm-toolchain

PATCH New Denys Dmytriyenko 1 participant 1 message Feb 5, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 FIXME: overlay .inc files for external-arm-toolchain

Remove later when using external-arm-toolchain from meta-linaro-toolchain

---
 .../include/external-arm-toolchain-versions.inc    | 128 +++++++++++++++++++++
 .../conf/distro/include/tcmode-external-arm.inc    | 113 ++++++++++++++++++
 2 files changed, 241 insertions(+)
 create mode 100644 meta-arago-extras/conf/distro/include/external-arm-toolchain-versions.inc
 create mode 100644 meta-arago-extras/conf/distro/include/tcmode-external-arm.inc
meta-arago-extras/conf/distro/include/external-arm-toolchain-versions.inc new file +128 -0
new file mode 100644
index 0000000..6c3acec
@@ -0,0 +1,128 @@
+def eat_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 eat_get_version(d):
+    try:
+        stdout, stderr = eat_run(d, 'gcc', '-v')
+    except bb.process.CmdError as exc:
+        bb.error('Failed to obtain external Arm toolchain version: %s' % exc)
+        return 'UNKNOWN'
+    else:
+        last_line = stderr.splitlines()[-1]
+        return last_line
+
+# Extract the YYYY.MM version
+def eat_get_main_version(d):
+    version = eat_get_version(d)
+    bb.debug(2, 'Trying for parse version info from: %s' % version)
+    if version != 'UNKNOWN':
+        if version.split()[4] == '(GNU':
+            # gcc version 8.2.1 20180802 (GNU Toolchain for the A-profile Architecture 8.2-2018.11 (arm-rel-8.26)) 
+            return version.split()[10].split('-')[1]
+        bb.error('Failed to parse external Arm toolchain version from: %s' % version)
+    else:
+        return version
+
+# Extract the x.y.z version from 'gcc version 4.9.1'
+def eat_get_gcc_version(d):
+    version = eat_get_version(d)
+    if version != 'UNKNOWN':
+        return version.split()[2]
+    else:
+        return version
+
+def eat_get_libc_version(d):
+    import os,bb
+    syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${EAT_TARGET_SYS}', d)
+    if not syspath:
+        return 'UNKNOWN'
+
+    libpath = syspath + '/libc/' + bb.data.expand('${EAT_LIBDIR}/${EAT_TARGET_SYS}/', d)
+
+    if os.path.exists(libpath):
+        for file in os.listdir(libpath):
+            if file.find('libc-') == 0:
+                return file[5:-3]
+
+    libpath = syspath + '/libc/' + bb.data.expand('${EAT_LIBDIR}/', d)
+
+    if os.path.exists(libpath):
+        for file in os.listdir(libpath):
+            if file.find('libc-') == 0:
+                return file[5:-3]
+
+    libpath = syspath + '/libc/usr/' + bb.data.expand('${EAT_LIBDIR}/${EAT_TARGET_SYS}/', d)
+
+    if os.path.exists(libpath):
+        for file in os.listdir(libpath):
+            if file.find('libc-') == 0:
+                return file[5:-3]
+
+    libpath = syspath + '/libc/usr/' + bb.data.expand('${EAT_LIBDIR}/', d)
+
+    if os.path.exists(libpath):
+        for file in os.listdir(libpath):
+            if file.find('libc-') == 0:
+                return file[5:-3]
+    return 'UNKNOWN'
+
+def eat_get_kernel_version(d):
+    import os,bb
+    syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${EAT_TARGET_SYS}', d)
+    if not syspath:
+        return 'UNKNOWN'
+
+    vf = syspath + '/libc/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 eat_get_gdb_version(d):
+    try:
+        stdout, stderr = eat_run(d, 'gdb', '-v')
+    except bb.process.CmdError:
+        return 'UNKNOWN'
+    else:
+        first_line = stdout.splitlines()[0]
+        return first_line.split()[-1]
+
+python external_arm_toolchain_version_handler () {
+    if not isinstance(e, bb.event.ConfigParsed):
+        return
+    d = e.data
+    ld = d.createCopy()
+    ld.finalize()
+
+    d.setVar('EAT_VER_MAIN', eat_get_main_version(ld))
+    d.setVar('EAT_VER_GCC', eat_get_gcc_version(ld))
+    d.setVar('EAT_VER_LIBC', eat_get_libc_version(ld))
+    d.setVar('EAT_VER_KERNEL', eat_get_kernel_version(ld))
+    d.setVar('EAT_VER_GDB', eat_get_gdb_version(ld))
+}
+addhandler external_arm_toolchain_version_handler
meta-arago-extras/conf/distro/include/tcmode-external-arm.inc new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.7.4