mesonlib: Add repr() methods to PerMachine classes
Which is super helpful in debuggers
@@ -389,6 +389,9 @@ class PerMachine(T.Generic[_T]):
unfreeze.host = None
return unfreeze
+ def __repr__(self) -> str:
+ return 'PerMachine({!r}, {!r})'.format(self.build, self.host)
+
class PerThreeMachine(PerMachine[_T]):
"""Like `PerMachine` but includes `target` too.
@@ -421,6 +424,9 @@ class PerThreeMachine(PerMachine[_T]):
def matches_build_machine(self, machine: MachineChoice) -> bool:
return self.build == self[machine]
+ def __repr__(self) -> str:
+ return 'PerThreeMachine({!r}, {!r}, {!r})'.format(self.build, self.host, self.target)
+
class PerMachineDefaultable(PerMachine[T.Optional[_T]]):
"""Extends `PerMachine` with the ability to default from `None`s.
@@ -439,6 +445,9 @@ class PerMachineDefaultable(PerMachine[T.Optional[_T]]):
freeze.host = freeze.build
return freeze
+ def __repr__(self) -> str:
+ return 'PerMachineDefaultable({!r}, {!r})'.format(self.build, self.host)
+
class PerThreeMachineDefaultable(PerMachineDefaultable, PerThreeMachine[T.Optional[_T]]):
"""Extends `PerThreeMachine` with the ability to default from `None`s.
@@ -460,6 +469,9 @@ class PerThreeMachineDefaultable(PerMachineDefaultable, PerThreeMachine[T.Option
freeze.target = freeze.host
return freeze
+ def __repr__(self) -> str:
+ return 'PerThreeMachineDefaultable({!r}, {!r}, {!r})'.format(self.build, self.host, self.target)
+
def is_sunos() -> bool:
return platform.system().lower() == 'sunos'
