diff options
-rw-r--r-- | meta/conf/distro/include/csl-versions.inc | 105 | ||||
-rw-r--r-- | meta/conf/distro/include/tcmode-external-csl.inc | 2 | ||||
-rw-r--r-- | meta/recipes-core/meta/external-csl-toolchain.bb | 24 |
3 files changed, 131 insertions, 0 deletions
diff --git a/meta/conf/distro/include/csl-versions.inc b/meta/conf/distro/include/csl-versions.inc new file mode 100644 index 0000000000..22e83946a1 --- /dev/null +++ b/meta/conf/distro/include/csl-versions.inc | |||
@@ -0,0 +1,105 @@ | |||
1 | def 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 | |||
16 | def 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 | return 'UNKNOWN' | ||
22 | else: | ||
23 | last_line = stderr.splitlines()[-1] | ||
24 | return last_line | ||
25 | |||
26 | def csl_get_main_version(d): | ||
27 | version = csl_get_version(d) | ||
28 | if version != 'UNKNOWN': | ||
29 | return version.split()[-1].rstrip(')') | ||
30 | else: | ||
31 | return version | ||
32 | |||
33 | def csl_get_gcc_version(d): | ||
34 | version = csl_get_version(d) | ||
35 | if version != 'UNKNOWN': | ||
36 | return version.split()[2] | ||
37 | else: | ||
38 | return version | ||
39 | |||
40 | def csl_get_libc_version(d): | ||
41 | import os,bb | ||
42 | syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}', d) | ||
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 | |||
56 | def csl_get_kernel_version(d): | ||
57 | import os,bb | ||
58 | syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${CSL_TARGET_SYS}', d) | ||
59 | if not syspath: | ||
60 | return 'UNKNOWN' | ||
61 | |||
62 | vf = syspath + '/libc/usr/include/linux/version.h' | ||
63 | if not os.path.exists(vf): | ||
64 | vf = syspath + '/libc/sgxx-glibc/usr/include/linux/version.h' | ||
65 | |||
66 | try: | ||
67 | f = open(vf, 'r') | ||
68 | except (OSError, IOError): | ||
69 | return 'UNKNOWN' | ||
70 | |||
71 | l = f.readlines(); | ||
72 | f.close(); | ||
73 | for s in l: | ||
74 | if s.find('LINUX_VERSION_CODE') > 0: | ||
75 | ver = int(s.split()[2]) | ||
76 | maj = ver / 65536 | ||
77 | ver = ver % 65536 | ||
78 | min = ver / 256 | ||
79 | ver = ver % 256 | ||
80 | return str(maj)+'.'+str(min)+'.'+str(ver) | ||
81 | return 'UNKNOWN' | ||
82 | |||
83 | def csl_get_gdb_version(d): | ||
84 | try: | ||
85 | stdout, stderr = csl_run(d, 'gdb', '-v') | ||
86 | except CmdError: | ||
87 | return 'UNKNOWN' | ||
88 | else: | ||
89 | first_line = stdout.splitlines()[0] | ||
90 | return first_line.split()[-1] | ||
91 | |||
92 | python csl_version_handler () { | ||
93 | if not isinstance(e, bb.event.ConfigParsed): | ||
94 | return | ||
95 | d = e.data | ||
96 | ld = d.createCopy() | ||
97 | ld.finalize() | ||
98 | |||
99 | d.setVar('CSL_VER_MAIN', csl_get_main_version(ld)) | ||
100 | d.setVar('CSL_VER_GCC', csl_get_gcc_version(ld)) | ||
101 | d.setVar('CSL_VER_LIBC', csl_get_libc_version(ld)) | ||
102 | d.setVar('CSL_VER_KERNEL', csl_get_kernel_version(ld)) | ||
103 | d.setVar('CSL_VER_GDB', csl_get_gdb_version(ld)) | ||
104 | } | ||
105 | addhandler csl_version_handler | ||
diff --git a/meta/conf/distro/include/tcmode-external-csl.inc b/meta/conf/distro/include/tcmode-external-csl.inc index 0135590060..1ff808d9e7 100644 --- a/meta/conf/distro/include/tcmode-external-csl.inc +++ b/meta/conf/distro/include/tcmode-external-csl.inc | |||
@@ -108,3 +108,5 @@ def populate_toolchain_links(d): | |||
108 | if exc.errno == errno.EEXIST: | 108 | if exc.errno == errno.EEXIST: |
109 | break | 109 | break |
110 | bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) | 110 | bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) |
111 | |||
112 | require conf/distro/include/csl-versions.inc | ||
diff --git a/meta/recipes-core/meta/external-csl-toolchain.bb b/meta/recipes-core/meta/external-csl-toolchain.bb index 8cf73dad99..c9f35c408d 100644 --- a/meta/recipes-core/meta/external-csl-toolchain.bb +++ b/meta/recipes-core/meta/external-csl-toolchain.bb | |||
@@ -23,6 +23,7 @@ PROVIDES += "\ | |||
23 | libgcc \ | 23 | libgcc \ |
24 | virtual/linux-libc-headers \ | 24 | virtual/linux-libc-headers \ |
25 | " | 25 | " |
26 | PV = "${CSL_VER_MAIN}" | ||
26 | PR = "r3" | 27 | PR = "r3" |
27 | 28 | ||
28 | #SRC_URI = "http://www.codesourcery.com/public/gnu_toolchain/${CSL_TARGET_SYS}/arm-${PV}-${TARGET_PREFIX}i686-pc-linux-gnu.tar.bz2" | 29 | #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" | |||
97 | PKG_${PN}-thread-db = "eglibc-thread-db" | 98 | PKG_${PN}-thread-db = "eglibc-thread-db" |
98 | PKG_${PN}-pcprofile = "eglibc-pcprofile" | 99 | PKG_${PN}-pcprofile = "eglibc-pcprofile" |
99 | 100 | ||
101 | PKGV_${PN} = "${CSL_VER_LIBC}" | ||
102 | PKGV_${PN}-dev = "${CSL_VER_LIBC}" | ||
103 | PKGV_${PN}-doc = "${CSL_VER_LIBC}" | ||
104 | PKGV_${PN}-dbg = "${CSL_VER_LIBC}" | ||
105 | PKGV_${PN}-pic = "${CSL_VER_LIBC}" | ||
106 | PKGV_${PN}-utils = "${CSL_VER_LIBC}" | ||
107 | PKGV_${PN}-gconv = "${CSL_VER_LIBC}" | ||
108 | PKGV_${PN}-extra-nss = "${CSL_VER_LIBC}" | ||
109 | PKGV_${PN}-thread-db = "${CSL_VER_LIBC}" | ||
110 | PKGV_${PN}-pcprofile = "${CSL_VER_LIBC}" | ||
111 | PKGV_catchsegv = "${CSL_VER_LIBC}" | ||
112 | PKGV_libsegfault = "${CSL_VER_LIBC}" | ||
113 | PKGV_sln = "${CSL_VER_LIBC}" | ||
114 | PKGV_nscd = "${CSL_VER_LIBC}" | ||
115 | PKGV_ldd = "${CSL_VER_LIBC}" | ||
116 | PKGV_libgcc = "${CSL_VER_GCC}" | ||
117 | PKGV_libgcc-dev = "${CSL_VER_GCC}" | ||
118 | PKGV_libstdc++ = "${CSL_VER_GCC}" | ||
119 | PKGV_libstdc++-dev = "${CSL_VER_GCC}" | ||
120 | PKGV_linux-libc-headers = "${CSL_VER_KERNEL}" | ||
121 | PKGV_linux-libc-headers-dev = "${CSL_VER_KERNEL}" | ||
122 | PKGV_gdbserver = "${CSL_VER_GDBSERVER}" | ||
123 | |||
100 | FILES_libgcc = "${base_libdir}/libgcc_s.so.1" | 124 | FILES_libgcc = "${base_libdir}/libgcc_s.so.1" |
101 | FILES_libgcc-dev = "${base_libdir}/libgcc_s.so" | 125 | FILES_libgcc-dev = "${base_libdir}/libgcc_s.so" |
102 | FILES_libstdc++ = "${libdir}/libstdc++.so.*" | 126 | FILES_libstdc++ = "${libdir}/libstdc++.so.*" |