blob: a944a8fff1c6a76cf2d84f3f2c37bb488431829e [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
13# Map our ARCH values to what Meson expects:
14# http://mesonbuild.com/Reference-tables.html#cpu-families
15def meson_cpu_family(var, d):
16 import re
17 arch = d.getVar(var)
18 if arch == 'powerpc':
19 return 'ppc'
20 elif arch == 'powerpc64' or arch == 'powerpc64le':
21 return 'ppc64'
22 elif arch == 'armeb':
23 return 'arm'
24 elif arch == 'aarch64_be':
25 return 'aarch64'
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050026 elif arch == 'loongarch64':
27 return 'loongarch64'
Patrick Williams92b42cb2022-09-03 06:53:57 -050028 elif arch == 'mipsel':
29 return 'mips'
30 elif arch == 'mips64el':
31 return 'mips64'
32 elif re.match(r"i[3-6]86", arch):
33 return "x86"
34 elif arch == "microblazeel":
35 return "microblaze"
36 else:
37 return arch
38
39# Map our OS values to what Meson expects:
40# https://mesonbuild.com/Reference-tables.html#operating-system-names
41def meson_operating_system(var, d):
42 os = d.getVar(var)
43 if "mingw" in os:
44 return "windows"
45 # avoid e.g 'linux-gnueabi'
46 elif "linux" in os:
47 return "linux"
48 else:
49 return os
50
51def meson_endian(prefix, d):
52 arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS")
53 sitedata = siteinfo_data_for_machine(arch, os, d)
54 if "endian-little" in sitedata:
55 return "little"
56 elif "endian-big" in sitedata:
57 return "big"
58 else:
59 bb.fatal("Cannot determine endianism for %s-%s" % (arch, os))