diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2019-05-09 21:42:53 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-05-16 00:27:57 +0300 |
commit | 957d8e051c0c29beb0106e75ae7a71acc5c62cf5 (patch) | |
tree | 19bb30d1cca5db43b7f540b718a9607a23a6d96a /mesonbuild/envconfig.py | |
parent | 38b347ecd026b8b0f6b533392a23aeeda5221713 (diff) | |
download | meson-957d8e051c0c29beb0106e75ae7a71acc5c62cf5.zip meson-957d8e051c0c29beb0106e75ae7a71acc5c62cf5.tar.gz meson-957d8e051c0c29beb0106e75ae7a71acc5c62cf5.tar.bz2 |
Make `PerMachine` and `MachineChoice` have just `build` and `host`
Meson itself *almost* only cares about the build and host platforms. The
exception is it takes a `target_machine` in the cross file and exposes
it to the user; but it doesn't do anything else with it. It's therefore
overkill to put target in `PerMachine` and `MachineChoice`. Instead, we
make a `PerThreeMachine` only for the machine infos.
Additionally fix a few other things that were bugging me in the process:
- Get rid of `MachineInfos` class. Since `envconfig.py` was created, it
has no methods that couldn't just got on `PerMachine`
- Make `default_missing` and `miss_defaulting` work functionally. That
means we can just locally bind rather than bind as class vars the
"unfrozen" configuration. This helps prevent bugs where one forgets
to freeze a configuration.
Diffstat (limited to 'mesonbuild/envconfig.py')
-rw-r--r-- | mesonbuild/envconfig.py | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 70f964e..0cdb4c4 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -16,7 +16,7 @@ import configparser, os, shlex, subprocess import typing from . import mesonlib -from .mesonlib import EnvironmentException, MachineChoice, PerMachine +from .mesonlib import EnvironmentException from . import mlog _T = typing.TypeVar('_T') @@ -255,40 +255,6 @@ class MachineInfo: def libdir_layout_is_win(self) -> bool: return self.is_windows() or self.is_cygwin() -class PerMachineDefaultable(PerMachine[typing.Optional[_T]]): - """Extends `PerMachine` with the ability to default from `None`s. - """ - def __init__(self) -> None: - super().__init__(None, None, None) - - def default_missing(self) -> None: - """Default host to buid and target to host. - - This allows just specifying nothing in the native case, just host in the - cross non-compiler case, and just target in the native-built - cross-compiler case. - """ - if self.host is None: - self.host = self.build - if self.target is None: - self.target = self.host - - def miss_defaulting(self) -> None: - """Unset definition duplicated from their previous to None - - This is the inverse of ''default_missing''. By removing defaulted - machines, we can elaborate the original and then redefault them and thus - avoid repeating the elaboration explicitly. - """ - if self.target == self.host: - self.target = None - if self.host == self.build: - self.host = None - -class MachineInfos(PerMachineDefaultable[MachineInfo]): - def matches_build_machine(self, machine: MachineChoice) -> bool: - return self.build == self[machine] - class BinaryTable(HasEnvVarFallback): def __init__( self, |