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 | |
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')
-rw-r--r-- | meta/classes/meson-routines.bbclass | 51 | ||||
-rw-r--r-- | meta/classes/meson.bbclass | 52 |
2 files changed, 52 insertions, 51 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)) | ||
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass index bf9b02e06e..8ae0285f72 100644 --- a/meta/classes/meson.bbclass +++ b/meta/classes/meson.bbclass | |||
@@ -1,4 +1,4 @@ | |||
1 | inherit siteinfo python3native | 1 | inherit python3native meson-routines |
2 | 2 | ||
3 | DEPENDS_append = " meson-native ninja-native" | 3 | DEPENDS_append = " meson-native ninja-native" |
4 | 4 | ||
@@ -35,56 +35,6 @@ MESON_CROSS_FILE = "" | |||
35 | MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" | 35 | MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" |
36 | MESON_CROSS_FILE_class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" | 36 | MESON_CROSS_FILE_class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" |
37 | 37 | ||
38 | def meson_array(var, d): | ||
39 | items = d.getVar(var).split() | ||
40 | return repr(items[0] if len(items) == 1 else items) | ||
41 | |||
42 | # Map our ARCH values to what Meson expects: | ||
43 | # http://mesonbuild.com/Reference-tables.html#cpu-families | ||
44 | def meson_cpu_family(var, d): | ||
45 | import re | ||
46 | arch = d.getVar(var) | ||
47 | if arch == 'powerpc': | ||
48 | return 'ppc' | ||
49 | elif arch == 'powerpc64' or arch == 'powerpc64le': | ||
50 | return 'ppc64' | ||
51 | elif arch == 'armeb': | ||
52 | return 'arm' | ||
53 | elif arch == 'aarch64_be': | ||
54 | return 'aarch64' | ||
55 | elif arch == 'mipsel': | ||
56 | return 'mips' | ||
57 | elif arch == 'mips64el': | ||
58 | return 'mips64' | ||
59 | elif re.match(r"i[3-6]86", arch): | ||
60 | return "x86" | ||
61 | elif arch == "microblazeel": | ||
62 | return "microblaze" | ||
63 | else: | ||
64 | return arch | ||
65 | |||
66 | # Map our OS values to what Meson expects: | ||
67 | # https://mesonbuild.com/Reference-tables.html#operating-system-names | ||
68 | def meson_operating_system(var, d): | ||
69 | os = d.getVar(var) | ||
70 | if "mingw" in os: | ||
71 | return "windows" | ||
72 | # avoid e.g 'linux-gnueabi' | ||
73 | elif "linux" in os: | ||
74 | return "linux" | ||
75 | else: | ||
76 | return os | ||
77 | |||
78 | def meson_endian(prefix, d): | ||
79 | arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS") | ||
80 | sitedata = siteinfo_data_for_machine(arch, os, d) | ||
81 | if "endian-little" in sitedata: | ||
82 | return "little" | ||
83 | elif "endian-big" in sitedata: | ||
84 | return "big" | ||
85 | else: | ||
86 | bb.fatal("Cannot determine endianism for %s-%s" % (arch, os)) | ||
87 | |||
88 | addtask write_config before do_configure | 38 | addtask write_config before do_configure |
89 | do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS" | 39 | do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS" |
90 | do_write_config() { | 40 | do_write_config() { |