aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-04-15 01:23:10 -0400
committerJohn Ericson <git@JohnEricson.me>2019-06-05 23:05:34 -0400
commitaf2d7af9983a04fa2dd6c073bdc41847a23012c8 (patch)
treeaa84b24acb247df40bc924557f92934e3e3776f3 /mesonbuild/mesonlib.py
parent126100b1666bfd75db37a0a9aaeee5dbfd11e53a (diff)
downloadmeson-af2d7af9983a04fa2dd6c073bdc41847a23012c8.zip
meson-af2d7af9983a04fa2dd6c073bdc41847a23012c8.tar.gz
meson-af2d7af9983a04fa2dd6c073bdc41847a23012c8.tar.bz2
Per machine do 'build.' and '' option prefixes
See the docs/ changes for details.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py12
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