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 | |
| 13 | # Map our ARCH values to what Meson expects: |
| 14 | # http://mesonbuild.com/Reference-tables.html#cpu-families |
| 15 | def 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 Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 26 | elif arch == 'loongarch64': |
| 27 | return 'loongarch64' |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 28 | 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 |
| 41 | def 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 | |
| 51 | def 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)) |