Skip to content

Commit

Permalink
env2mfile: Don't hard-code Debian as always being Linux
Browse files Browse the repository at this point in the history
All official Debian release architectures use the Linux kernel, but
unofficial ports like hurd-i386 and kfreebsd-amd64 use the Hurd and
FreeBSD kernel, respectively.

Map Linux to 'linux' and kFreeBSD ports to 'freebsd' as per the
reference tables in Meson's documentation. For now, use the Debian
system name such as 'hurd' for anything else (see #13740 for the
question of whether Hurd should identify its kernel differently).

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv authored and jpakkane committed Oct 2, 2024
1 parent 1909a81 commit 114a3e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion mesonbuild/scripts/env2mfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def get_args_from_envvars(infos: MachineInfo) -> None:
'hurd': 'gnu',
}

# map from DEB_HOST_ARCH_OS to Meson machine.kernel()
deb_kernel_map = {
'kfreebsd': 'freebsd',
}

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
Expand Down Expand Up @@ -195,7 +200,7 @@ def dpkg_architecture_to_machine_info(output: str, options: T.Any) -> MachineInf
host_arch = data['DEB_HOST_GNU_TYPE']
host_os = replace_special_cases(deb_os_map, data['DEB_HOST_ARCH_OS'])
host_subsystem = host_os
host_kernel = 'linux'
host_kernel = replace_special_cases(deb_kernel_map, data['DEB_HOST_ARCH_OS'])
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']
Expand Down
7 changes: 4 additions & 3 deletions unittests/internaltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,9 @@ def expected_binaries(gnu_tuple: str) -> T.Dict[str, T.List[str]]:
},
system='gnu',
subsystem='gnu',
# TODO: Currently linux, but should be gnu/hurd/mach?
# TODO: Currently hurd; should match whatever happens
# during native builds, but at the moment native builds
# fail when kernel() is called.
# https://github.com/mesonbuild/meson/issues/13740
kernel='TODO',
# TODO: Currently hurd-i386, but should be i686
Expand Down Expand Up @@ -1977,8 +1979,7 @@ def expected_binaries(gnu_tuple: str) -> T.Dict[str, T.List[str]]:
},
system='kfreebsd',
subsystem='kfreebsd',
# TODO: Currently linux but should be freebsd
kernel='TODO',
kernel='freebsd',
# TODO: Currently kfreebsd-amd64 but should be x86_64
cpu='TODO',
cpu_family='x86_64',
Expand Down

0 comments on commit 114a3e2

Please sign in to comment.