Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | inherit siteinfo |
| 8 | |
| 9 | def meson_array(var, d): |
| 10 | items = d.getVar(var).split() |
| 11 | return repr(items[0] if len(items) == 1 else items) |
| 12 | |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame^] | 13 | def 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 19 | # Map our ARCH values to what Meson expects: |
| 20 | # http://mesonbuild.com/Reference-tables.html#cpu-families |
| 21 | def 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 Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 32 | elif arch == 'loongarch64': |
| 33 | return 'loongarch64' |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 34 | 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 |
| 47 | def 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 | |
| 57 | def 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)) |