summaryrefslogtreecommitdiffstats
path: root/meta/conf/distro/include/csl-versions.inc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/conf/distro/include/csl-versions.inc')
-rw-r--r--meta/conf/distro/include/csl-versions.inc107
1 files changed, 0 insertions, 107 deletions
diff --git a/meta/conf/distro/include/csl-versions.inc b/meta/conf/distro/include/csl-versions.inc
deleted file mode 100644
index 3938bf7ed2..0000000000
--- a/meta/conf/distro/include/csl-versions.inc
+++ /dev/null
@@ -1,107 +0,0 @@
1def csl_run(d, cmd, *args):
2 import bb.process
3 import subprocess
4
5 topdir = d.getVar('TOPDIR', True)
6 toolchain_path = d.getVar('EXTERNAL_TOOLCHAIN', True)
7 if not toolchain_path:
8 return 'UNKNOWN', 'UNKNOWN'
9
10 target_prefix = d.getVar('TARGET_PREFIX', True)
11 path = os.path.join(toolchain_path, 'bin', target_prefix + cmd)
12 args = [path] + list(args)
13
14 return bb.process.run(args, cwd=topdir, stderr=subprocess.PIPE)
15
16def csl_get_version(d):
17 try:
18 stdout, stderr = csl_run(d, 'gcc', '-v')
19 except bb.process.CmdError as exc:
20 bb.error('Failed to obtain CodeSourcery toolchain version: %s' % exc)
21 bb.error('Make sure that MACHINE is set correctly in your local.conf and the toolchain supports %s.' % d.getVar("TARGET_ARCH", True))
22 return 'UNKNOWN'
23 else:
24 last_line = stderr.splitlines()[-1]
25 return last_line
26
27def csl_get_main_version(d):
28 version = csl_get_version(d)
29 if version != 'UNKNOWN':
30 return version.split()[-1].rstrip(')')
31 else:
32 return version
33
34def csl_get_gcc_version(d):
35 version = csl_get_version(d)
36 if version != 'UNKNOWN':
37 return version.split()[2]
38 else:
39 return version
40
41def csl_get_libc_version(d):
42 syspath = d.expand('${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}')
43 if not syspath:
44 return 'UNKNOWN'
45
46 libpath = syspath + '/libc/lib/'
47 if not os.path.exists(libpath):
48 libpath = syspath + '/libc/sgxx-glibc/lib/'
49
50 if os.path.exists(libpath):
51 for file in os.listdir(libpath):
52 if file.find('libc-') == 0:
53 return file[5:-3]
54 return 'UNKNOWN'
55
56def csl_get_kernel_version(d):
57 syspath = d.expand('${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}')
58 if not syspath:
59 return 'UNKNOWN'
60
61 vf = syspath + '/libc/usr/include/linux/version.h'
62 if not os.path.exists(vf):
63 vf = syspath + '/libc/sgxx-glibc/usr/include/linux/version.h'
64
65 try:
66 f = open(vf, 'r')
67 except (OSError, IOError):
68 return 'UNKNOWN'
69
70 l = f.readlines();
71 f.close();
72 for s in l:
73 if s.find('LINUX_VERSION_CODE') > 0:
74 ver = int(s.split()[2])
75 maj = ver / 65536
76 ver = ver % 65536
77 min = ver / 256
78 ver = ver % 256
79 return str(maj)+'.'+str(min)+'.'+str(ver)
80 return 'UNKNOWN'
81
82def csl_get_gdb_version(d):
83 try:
84 stdout, stderr = csl_run(d, 'gdb', '-v')
85 except bb.process.CmdError:
86 return 'UNKNOWN'
87 else:
88 first_line = stdout.splitlines()[0]
89 return first_line.split()[-1]
90
91python csl_version_handler () {
92 d = e.data
93 ld = d.createCopy()
94 ld.finalize()
95
96 d.setVar('CSL_VER_MAIN', csl_get_main_version(ld))
97 d.setVar('CSL_VER_GCC', csl_get_gcc_version(ld))
98 d.setVar('CSL_VER_LIBC', csl_get_libc_version(ld))
99 d.setVar('CSL_VER_KERNEL', csl_get_kernel_version(ld))
100 d.setVar('CSL_VER_GDB', csl_get_gdb_version(ld))
101}
102addhandler csl_version_handler
103csl_version_handler[eventmask] = "bb.event.ConfigParsed"
104
105# Ensure that any variable which includes the --sysroot (CC, CXX, etc) also
106# depends on the toolchain version
107TOOLCHAIN_OPTIONS[vardeps] += "CSL_VER_MAIN CSL_VER_GCC"