diff options
Diffstat (limited to 'meta-linaro-toolchain/conf')
3 files changed, 225 insertions, 0 deletions
diff --git a/meta-linaro-toolchain/conf/distro/include/external-linaro-toolchain-versions.inc b/meta-linaro-toolchain/conf/distro/include/external-linaro-toolchain-versions.inc new file mode 100644 index 0000000..6165520 --- /dev/null +++ b/meta-linaro-toolchain/conf/distro/include/external-linaro-toolchain-versions.inc | |||
@@ -0,0 +1,111 @@ | |||
1 | def elt_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 elt_get_version(d): | ||
17 | try: | ||
18 | stdout, stderr = elt_run(d, 'gcc', '-v') | ||
19 | except bb.process.CmdError as exc: | ||
20 | bb.error('Failed to obtain external Linaro toolchain version: %s' % exc) | ||
21 | return 'UNKNOWN' | ||
22 | else: | ||
23 | last_line = stderr.splitlines()[-1] | ||
24 | return last_line | ||
25 | |||
26 | def elt_get_main_version(d): | ||
27 | version = elt_get_version(d) | ||
28 | if version != 'UNKNOWN': | ||
29 | if version.split()[5] != '(crosstool-NG': | ||
30 | return version.split()[7].split(')')[0] | ||
31 | else: | ||
32 | return version.split()[6].split('-')[3] | ||
33 | else: | ||
34 | return version | ||
35 | |||
36 | def elt_get_gcc_version(d): | ||
37 | version = elt_get_version(d) | ||
38 | if version != 'UNKNOWN': | ||
39 | return version.split()[2] | ||
40 | else: | ||
41 | return version | ||
42 | |||
43 | def elt_get_libc_version(d): | ||
44 | import os,bb | ||
45 | syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${ELT_TARGET_SYS}', d) | ||
46 | if not syspath: | ||
47 | return 'UNKNOWN' | ||
48 | |||
49 | libpath = syspath + '/libc/lib/' + bb.data.expand('${ELT_TARGET_SYS}/', d) | ||
50 | |||
51 | if os.path.exists(libpath): | ||
52 | for file in os.listdir(libpath): | ||
53 | if file.find('libc-') == 0: | ||
54 | return file[5:-3] | ||
55 | |||
56 | libpath = syspath + '/libc/lib/' | ||
57 | |||
58 | if os.path.exists(libpath): | ||
59 | for file in os.listdir(libpath): | ||
60 | if file.find('libc-') == 0: | ||
61 | return file[5:-3] | ||
62 | return 'UNKNOWN' | ||
63 | |||
64 | def elt_get_kernel_version(d): | ||
65 | import os,bb | ||
66 | syspath = bb.data.expand('${EXTERNAL_TOOLCHAIN}/${ELT_TARGET_SYS}', d) | ||
67 | if not syspath: | ||
68 | return 'UNKNOWN' | ||
69 | |||
70 | vf = syspath + '/libc/usr/include/linux/version.h' | ||
71 | |||
72 | try: | ||
73 | f = open(vf, 'r') | ||
74 | except (OSError, IOError): | ||
75 | return 'UNKNOWN' | ||
76 | |||
77 | l = f.readlines(); | ||
78 | f.close(); | ||
79 | for s in l: | ||
80 | if s.find('LINUX_VERSION_CODE') > 0: | ||
81 | ver = int(s.split()[2]) | ||
82 | maj = ver / 65536 | ||
83 | ver = ver % 65536 | ||
84 | min = ver / 256 | ||
85 | ver = ver % 256 | ||
86 | return str(maj)+'.'+str(min)+'.'+str(ver) | ||
87 | return 'UNKNOWN' | ||
88 | |||
89 | def elt_get_gdb_version(d): | ||
90 | try: | ||
91 | stdout, stderr = elt_run(d, 'gdb', '-v') | ||
92 | except bb.process.CmdError: | ||
93 | return 'UNKNOWN' | ||
94 | else: | ||
95 | first_line = stdout.splitlines()[0] | ||
96 | return first_line.split()[-1] | ||
97 | |||
98 | python external_linaro_toolchain_version_handler () { | ||
99 | if not isinstance(e, bb.event.ConfigParsed): | ||
100 | return | ||
101 | d = e.data | ||
102 | ld = d.createCopy() | ||
103 | ld.finalize() | ||
104 | |||
105 | d.setVar('ELT_VER_MAIN', elt_get_main_version(ld)) | ||
106 | d.setVar('ELT_VER_GCC', elt_get_gcc_version(ld)) | ||
107 | d.setVar('ELT_VER_LIBC', elt_get_libc_version(ld)) | ||
108 | d.setVar('ELT_VER_KERNEL', elt_get_kernel_version(ld)) | ||
109 | d.setVar('ELT_VER_GDB', elt_get_gdb_version(ld)) | ||
110 | } | ||
111 | addhandler external_linaro_toolchain_version_handler | ||
diff --git a/meta-linaro-toolchain/conf/distro/include/tcmode-external-linaro.inc b/meta-linaro-toolchain/conf/distro/include/tcmode-external-linaro.inc new file mode 100644 index 0000000..19be8af --- /dev/null +++ b/meta-linaro-toolchain/conf/distro/include/tcmode-external-linaro.inc | |||
@@ -0,0 +1,101 @@ | |||
1 | # | ||
2 | # Configuration to use an external Linaro binary toolchain | ||
3 | # | ||
4 | |||
5 | EXTERNAL_TOOLCHAIN ?= "/usr/local/linaro-binary-toolchain/${TARGET_ARCH}" | ||
6 | |||
7 | TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:" | ||
8 | PATH =. "${TOOLCHAIN_PATH_ADD}" | ||
9 | |||
10 | ELT_TARGET_SYS_arm ?= "arm-linux-gnueabihf" | ||
11 | ELT_TARGET_SYS_aarch64 ?= "aarch64-linux-gnu" | ||
12 | ELT_TARGET_SYS = "${TARGET_SYS}" | ||
13 | TARGET_PREFIX = "${ELT_TARGET_SYS}-" | ||
14 | |||
15 | GCCMULTILIB_forcevariable = "--disable-multilib" | ||
16 | IMAGE_LINGUAS_forcevariable = "" | ||
17 | |||
18 | PREFERRED_PROVIDER_linux-libc-headers = "external-linaro-toolchain" | ||
19 | PREFERRED_PROVIDER_linux-libc-headers-dev = "external-linaro-toolchain" | ||
20 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-linaro-toolchain" | ||
21 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-initial = "external-linaro-toolchain" | ||
22 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ = "external-linaro-toolchain" | ||
23 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "external-linaro-toolchain" | ||
24 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "external-linaro-toolchain" | ||
25 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs = "external-linaro-toolchain" | ||
26 | PREFERRED_PROVIDER_glibc = "external-linaro-toolchain" | ||
27 | PREFERRED_PROVIDER_libgcc = "external-linaro-toolchain" | ||
28 | PREFERRED_PROVIDER_virtual/libc = "external-linaro-toolchain" | ||
29 | PREFERRED_PROVIDER_virtual/libintl = "external-linaro-toolchain" | ||
30 | PREFERRED_PROVIDER_virtual/libiconv = "external-linaro-toolchain" | ||
31 | PREFERRED_PROVIDER_glibc-thread-db = "external-linaro-toolchain" | ||
32 | PREFERRED_PROVIDER_virtual/linux-libc-headers = "external-linaro-toolchain" | ||
33 | |||
34 | TARGET_CPPFLAGS_prepend = " -isystem${EXTERNAL_TOOLCHAIN}/${ELT_TARGET_SYS}/include " | ||
35 | TARGET_LDFLAGS_prepend = " -L${EXTERNAL_TOOLCHAIN}/${ELT_TARGET_SYS}/lib -Wl,-rpath-link,${EXTERNAL_TOOLCHAIN}/${ELT_TARGET_SYS}/lib " | ||
36 | |||
37 | TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}" | ||
38 | |||
39 | DISTRO_FEATURES_LIBC = "ipv4 ipv6 libc-backtrace libc-big-macros libc-bsd libc-cxx-tests libc-catgets libc-crypt \ | ||
40 | libc-crypt-ufc libc-db-aliases libc-envz libc-fcvt libc-fmtmsg libc-fstab libc-ftraverse \ | ||
41 | libc-getlogin libc-idn libc-inet-anl libc-libm libc-libm-big \ | ||
42 | libc-memusage libc-nis libc-nsswitch libc-rcmd libc-rtld-debug libc-spawn libc-streams libc-sunrpc \ | ||
43 | libc-utmp libc-utmpx libc-wordexp libc-posix-clang-wchar libc-posix-regexp libc-posix-regexp-glibc \ | ||
44 | libc-posix-wchar-io" | ||
45 | |||
46 | ENABLE_BINARY_LOCALE_GENERATION = "0" | ||
47 | GLIBC_INTERNAL_USE_BINARY_LOCALE = "precompiled" | ||
48 | |||
49 | ERROR_QA[type] ?= "list" | ||
50 | python toolchain_metadata_setup () { | ||
51 | import subprocess | ||
52 | if not isinstance(e, bb.event.ConfigParsed): | ||
53 | return | ||
54 | |||
55 | d = e.data | ||
56 | l = d.createCopy() | ||
57 | l.finalize() | ||
58 | oe_import(l) | ||
59 | |||
60 | external_toolchain = l.getVar('EXTERNAL_TOOLCHAIN', True) | ||
61 | if not external_toolchain or external_toolchain == 'UNDEFINED': | ||
62 | bb.fatal("Error: EXTERNAL_TOOLCHAIN must be set to the path to your linaro toolchain") | ||
63 | |||
64 | if not os.path.exists(external_toolchain): | ||
65 | bb.fatal("Error: EXTERNAL_TOOLCHAIN path '%s' does not exist" % external_toolchain) | ||
66 | |||
67 | # The external toolchain may not have been built with the oe-core preferred | ||
68 | # gnu hash setting, so ensure that the corresponding sanity check is not an error. | ||
69 | error_qa = oe.data.typed_value('ERROR_QA', l) | ||
70 | if 'ldflags' in error_qa: | ||
71 | error_qa.remove('ldflags') | ||
72 | d.setVar('ERROR_QA', ' '.join(error_qa)) | ||
73 | } | ||
74 | addhandler toolchain_metadata_setup | ||
75 | |||
76 | def populate_toolchain_links(d): | ||
77 | import errno | ||
78 | import os | ||
79 | from glob import glob | ||
80 | |||
81 | d = d.createCopy() | ||
82 | d.finalize() | ||
83 | |||
84 | pattern = bb.data.expand('${EXTERNAL_TOOLCHAIN}/bin/${TARGET_PREFIX}*', d) | ||
85 | files = glob(pattern) | ||
86 | if not files: | ||
87 | bb.fatal("Unable to populate toolchain binary symlinks") | ||
88 | |||
89 | bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True) | ||
90 | bb.mkdirhier(bindir) | ||
91 | for f in files: | ||
92 | base = os.path.basename(f) | ||
93 | newpath = os.path.join(bindir, base) | ||
94 | try: | ||
95 | os.symlink(f, newpath) | ||
96 | except OSError as exc: | ||
97 | if exc.errno == errno.EEXIST: | ||
98 | break | ||
99 | bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) | ||
100 | |||
101 | require conf/distro/include/external-linaro-toolchain-versions.inc | ||
diff --git a/meta-linaro-toolchain/conf/layer.conf b/meta-linaro-toolchain/conf/layer.conf new file mode 100644 index 0000000..7e96dcd --- /dev/null +++ b/meta-linaro-toolchain/conf/layer.conf | |||
@@ -0,0 +1,13 @@ | |||
1 | BBPATH .= ":${LAYERDIR}" | ||
2 | BBFILES += "\ | ||
3 | ${LAYERDIR}/recipes-*/*/*.bb \ | ||
4 | ${LAYERDIR}/recipes-*/*/*.bbappend \ | ||
5 | " | ||
6 | |||
7 | BBFILE_COLLECTIONS += "linaro-toolchain" | ||
8 | BBFILE_PATTERN_linaro-toolchain := "^${LAYERDIR}/" | ||
9 | BBFILE_PRIORITY_linaro-toolchain = "30" | ||
10 | |||
11 | # do not error out on bbappends for missing recipes | ||
12 | BB_DANGLINGAPPENDS_WARNONLY = "true" | ||
13 | |||