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' |
| 26 | elif arch == 'mipsel': |
| 27 | return 'mips' |
| 28 | elif arch == 'mips64el': |
| 29 | return 'mips64' |
| 30 | elif re.match(r"i[3-6]86", arch): |
| 31 | return "x86" |
| 32 | elif arch == "microblazeel": |
| 33 | return "microblaze" |
| 34 | else: |
| 35 | return arch |
| 36 | |
| 37 | # Map our OS values to what Meson expects: |
| 38 | # https://mesonbuild.com/Reference-tables.html#operating-system-names |
| 39 | def meson_operating_system(var, d): |
| 40 | os = d.getVar(var) |
| 41 | if "mingw" in os: |
| 42 | return "windows" |
| 43 | # avoid e.g 'linux-gnueabi' |
| 44 | elif "linux" in os: |
| 45 | return "linux" |
| 46 | else: |
| 47 | return os |
| 48 | |
| 49 | def meson_endian(prefix, d): |
| 50 | arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS") |
| 51 | sitedata = siteinfo_data_for_machine(arch, os, d) |
| 52 | if "endian-little" in sitedata: |
| 53 | return "little" |
| 54 | elif "endian-big" in sitedata: |
| 55 | return "big" |
| 56 | else: |
| 57 | bb.fatal("Cannot determine endianism for %s-%s" % (arch, os)) |