diff options
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index ec4aa9f..e3ddf28 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -323,6 +323,12 @@ class MachineChoice(OrderedEnum): BUILD = 0 HOST = 1 + def get_lower_case_name(self): + return PerMachine('build', 'host')[self] + + def get_prefix(self): + return PerMachine('build.', '')[self] + class PerMachine(typing.Generic[_T]): def __init__(self, build: _T, host: _T): @@ -336,11 +342,7 @@ class PerMachine(typing.Generic[_T]): }[machine] def __setitem__(self, machine: MachineChoice, val: _T) -> None: - key = { - MachineChoice.BUILD: 'build', - MachineChoice.HOST: 'host', - }[machine] - setattr(self, key, val) + setattr(self, machine.get_lower_case_name(), val) def miss_defaulting(self) -> "PerMachineDefaultable[typing.Optional[_T]]": """Unset definition duplicated from their previous to None |