summaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2024-10-02 18:52:17 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2024-10-02 22:58:50 +0300
commitb4a7251eb8cb73eb2038ffe80a0b3d4211733fe8 (patch)
treeeec137443e885d7c55a9638502ceb816500ae344 /mesonbuild/scripts
parent1c11a04f94ae18fbe494cce84038763f11b65583 (diff)
downloadmeson-b4a7251eb8cb73eb2038ffe80a0b3d4211733fe8.tar.gz
env2mfile: Add a function for mostly-identity mappings with special cases
This makes the frequent pattern of things like "CPU families are the same as GNU CPUs, with a few known exceptions" less verbose. Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 'mesonbuild/scripts')
-rwxr-xr-xmesonbuild/scripts/env2mfile.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/mesonbuild/scripts/env2mfile.py b/mesonbuild/scripts/env2mfile.py
index debf2745e..68496b9f2 100755
--- a/mesonbuild/scripts/env2mfile.py
+++ b/mesonbuild/scripts/env2mfile.py
@@ -142,6 +142,13 @@ deb_cpu_map = {
'powerpc64le': 'ppc64',
}
+def replace_special_cases(special_cases: T.Mapping[str, str], name: str) -> str:
+ '''
+ If name is a key in special_cases, replace it with the value, or otherwise
+ pass it through unchanged.
+ '''
+ return special_cases.get(name, name)
+
def deb_detect_cmake(infos: MachineInfo, data: T.Dict[str, str]) -> None:
system_name_map = {'linux': 'Linux', 'kfreebsd': 'kFreeBSD', 'hurd': 'GNU'}
system_processor_map = {'arm': 'armv7l', 'mips64el': 'mips64', 'powerpc64le': 'ppc64le'}
@@ -152,8 +159,7 @@ def deb_detect_cmake(infos: MachineInfo, data: T.Dict[str, str]) -> None:
except KeyError:
pass
infos.cmake["CMAKE_SYSTEM_NAME"] = system_name_map[data['DEB_HOST_ARCH_OS']]
- infos.cmake["CMAKE_SYSTEM_PROCESSOR"] = system_processor_map.get(data['DEB_HOST_GNU_CPU'],
- data['DEB_HOST_GNU_CPU'])
+ infos.cmake["CMAKE_SYSTEM_PROCESSOR"] = replace_special_cases(system_processor_map, data['DEB_HOST_GNU_CPU'])
def deb_compiler_lookup(infos: MachineInfo, compilerstems: T.List[T.Tuple[str, str]], host_arch: str, gccsuffix: str) -> None:
for langname, stem in compilerstems:
@@ -185,10 +191,8 @@ def dpkg_architecture_to_machine_info(output: str, options: T.Any) -> MachineInf
host_os = data['DEB_HOST_ARCH_OS']
host_subsystem = host_os
host_kernel = 'linux'
- host_cpu_family = deb_cpu_family_map.get(data['DEB_HOST_GNU_CPU'],
- data['DEB_HOST_GNU_CPU'])
- host_cpu = deb_cpu_map.get(data['DEB_HOST_ARCH'],
- data['DEB_HOST_ARCH'])
+ host_cpu_family = replace_special_cases(deb_cpu_family_map, data['DEB_HOST_GNU_CPU'])
+ host_cpu = replace_special_cases(deb_cpu_map, data['DEB_HOST_ARCH'])
host_endian = data['DEB_HOST_ARCH_ENDIAN']
compilerstems = [('c', 'gcc'),