blob: 9925465ed8fac32a36f333eefa68dc08255ffbda [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit siteinfo
8
9def meson_array(var, d):
10 items = d.getVar(var).split()
11 return repr(items[0] if len(items) == 1 else items)
12
Patrick Williams73bd93f2024-02-20 08:07:48 -060013def meson_array_abspath(var, d):
14 import shutil
15 items = d.getVar(var).split()
16 items[0] = shutil.which(items[0]) or items[0]
17 return repr(items[0] if len(items) == 1 else items)
18
Patrick Williams92b42cb2022-09-03 06:53:57 -050019# Map our ARCH values to what Meson expects:
20# http://mesonbuild.com/Reference-tables.html#cpu-families
21def meson_cpu_family(var, d):
22 import re
23 arch = d.getVar(var)
24 if arch == 'powerpc':
25 return 'ppc'
26 elif arch == 'powerpc64' or arch == 'powerpc64le':
27 return 'ppc64'
28 elif arch == 'armeb':
29 return 'arm'
30 elif arch == 'aarch64_be':
31 return 'aarch64'
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050032 elif arch == 'loongarch64':
33 return 'loongarch64'
Patrick Williams92b42cb2022-09-03 06:53:57 -050034 elif arch == 'mipsel':
35 return 'mips'
36 elif arch == 'mips64el':
37 return 'mips64'
38 elif re.match(r"i[3-6]86", arch):
39 return "x86"
40 elif arch == "microblazeel":
41 return "microblaze"
42 else:
43 return arch
44
45# Map our OS values to what Meson expects:
46# https://mesonbuild.com/Reference-tables.html#operating-system-names
47def meson_operating_system(var, d):
48 os = d.getVar(var)
49 if "mingw" in os:
50 return "windows"
51 # avoid e.g 'linux-gnueabi'
52 elif "linux" in os:
53 return "linux"
54 else:
55 return os
56
57def meson_endian(prefix, d):
58 arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS")
59 sitedata = siteinfo_data_for_machine(arch, os, d)
60 if "endian-little" in sitedata:
61 return "little"
62 elif "endian-big" in sitedata:
63 return "big"
64 else:
65 bb.fatal("Cannot determine endianism for %s-%s" % (arch, os))