diff options
| author | Alexander Kanavin <alex.kanavin@gmail.com> | 2021-05-13 22:56:19 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-05-14 07:57:27 +0100 |
| commit | 830e634bbb4dbefbb4059319fbdcc200b5f9ac4e (patch) | |
| tree | cd2714be62d6ecb7672745b0132dc0f1231fccce /meta/classes/meson-routines.bbclass | |
| parent | 6f8cc237bf3f252802904fc732aaf4e8f6c123b4 (diff) | |
| download | poky-830e634bbb4dbefbb4059319fbdcc200b5f9ac4e.tar.gz | |
meson.bbclass: split python routines into a separate class
This allows reusing them in nativesdk-meson without copy-pasting code.
(From OE-Core rev: f2715f5f2a56f9b660f9f0fe2933ec231a2dd8c0)
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/meson-routines.bbclass')
| -rw-r--r-- | meta/classes/meson-routines.bbclass | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/meta/classes/meson-routines.bbclass b/meta/classes/meson-routines.bbclass new file mode 100644 index 0000000000..be3aeedeba --- /dev/null +++ b/meta/classes/meson-routines.bbclass | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | inherit siteinfo | ||
| 2 | |||
| 3 | def meson_array(var, d): | ||
| 4 | items = d.getVar(var).split() | ||
| 5 | return repr(items[0] if len(items) == 1 else items) | ||
| 6 | |||
| 7 | # Map our ARCH values to what Meson expects: | ||
| 8 | # http://mesonbuild.com/Reference-tables.html#cpu-families | ||
| 9 | def meson_cpu_family(var, d): | ||
| 10 | import re | ||
| 11 | arch = d.getVar(var) | ||
| 12 | if arch == 'powerpc': | ||
| 13 | return 'ppc' | ||
| 14 | elif arch == 'powerpc64' or arch == 'powerpc64le': | ||
| 15 | return 'ppc64' | ||
| 16 | elif arch == 'armeb': | ||
| 17 | return 'arm' | ||
| 18 | elif arch == 'aarch64_be': | ||
| 19 | return 'aarch64' | ||
| 20 | elif arch == 'mipsel': | ||
| 21 | return 'mips' | ||
| 22 | elif arch == 'mips64el': | ||
| 23 | return 'mips64' | ||
| 24 | elif re.match(r"i[3-6]86", arch): | ||
| 25 | return "x86" | ||
| 26 | elif arch == "microblazeel": | ||
| 27 | return "microblaze" | ||
| 28 | else: | ||
| 29 | return arch | ||
| 30 | |||
| 31 | # Map our OS values to what Meson expects: | ||
| 32 | # https://mesonbuild.com/Reference-tables.html#operating-system-names | ||
| 33 | def meson_operating_system(var, d): | ||
| 34 | os = d.getVar(var) | ||
| 35 | if "mingw" in os: | ||
| 36 | return "windows" | ||
| 37 | # avoid e.g 'linux-gnueabi' | ||
| 38 | elif "linux" in os: | ||
| 39 | return "linux" | ||
| 40 | else: | ||
| 41 | return os | ||
| 42 | |||
| 43 | def meson_endian(prefix, d): | ||
| 44 | arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS") | ||
| 45 | sitedata = siteinfo_data_for_machine(arch, os, d) | ||
| 46 | if "endian-little" in sitedata: | ||
| 47 | return "little" | ||
| 48 | elif "endian-big" in sitedata: | ||
| 49 | return "big" | ||
| 50 | else: | ||
| 51 | bb.fatal("Cannot determine endianism for %s-%s" % (arch, os)) | ||
