aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-05-09 21:42:53 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2019-05-16 00:27:57 +0300
commit957d8e051c0c29beb0106e75ae7a71acc5c62cf5 (patch)
tree19bb30d1cca5db43b7f540b718a9607a23a6d96a /mesonbuild/environment.py
parent38b347ecd026b8b0f6b533392a23aeeda5221713 (diff)
downloadmeson-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/environment.py')
-rw-r--r--mesonbuild/environment.py66
1 files changed, 39 insertions, 27 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 9620639..f86b613 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -19,12 +19,13 @@ from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLin
from . import mesonlib
from .mesonlib import (
MesonException, EnvironmentException, MachineChoice, Popen_safe,
+ PerMachineDefaultable, PerThreeMachineDefaultable
)
from . import mlog
from .envconfig import (
- BinaryTable, Directories, MachineInfo, MachineInfos, MesonConfigFile,
- PerMachineDefaultable, Properties, known_cpu_families,
+ BinaryTable, Directories, MachineInfo, MesonConfigFile,
+ Properties, known_cpu_families,
)
from . import compilers
from .compilers import (
@@ -403,48 +404,62 @@ class Environment:
# Just create a fresh coredata in this case
self.create_new_coredata(options)
- self.machines = MachineInfos()
- # Will be fully initialized later using compilers later.
- self.detect_build_machine()
+ ## locally bind some unfrozen configuration
+
+ # Stores machine infos, the only *three* machine one because we have a
+ # target machine info on for the user (Meson never cares about the
+ # target machine.)
+ machines = PerThreeMachineDefaultable()
# Similar to coredata.compilers and build.compilers, but lower level in
# that there is no meta data, only names/paths.
- self.binaries = PerMachineDefaultable()
+ binaries = PerMachineDefaultable()
# Misc other properties about each machine.
- self.properties = PerMachineDefaultable()
-
- # Just uses hard-coded defaults and environment variables. Might be
- # overwritten by a native file.
- self.binaries.build = BinaryTable()
- self.properties.build = Properties()
+ properties = PerMachineDefaultable()
# Store paths for native and cross build files. There is no target
# machine information here because nothing is installed for the target
# architecture, just the build and host architectures
- self.paths = PerMachineDefaultable()
+ paths = PerMachineDefaultable()
+
+ ## Setup build machine defaults
+
+ # Will be fully initialized later using compilers later.
+ machines.build = detect_machine_info()
+
+ # Just uses hard-coded defaults and environment variables. Might be
+ # overwritten by a native file.
+ binaries.build = BinaryTable()
+ properties.build = Properties()
+
+ ## Read in native file(s) to override build machine configuration
if self.coredata.config_files is not None:
config = MesonConfigFile.from_config_parser(
coredata.load_configs(self.coredata.config_files))
- self.binaries.build = BinaryTable(config.get('binaries', {}))
- self.paths.build = Directories(**config.get('paths', {}))
+ binaries.build = BinaryTable(config.get('binaries', {}))
+ paths.build = Directories(**config.get('paths', {}))
+
+ ## Read in cross file(s) to override host machine configuration
if self.coredata.cross_files:
config = MesonConfigFile.from_config_parser(
coredata.load_configs(self.coredata.cross_files))
- self.properties.host = Properties(config.get('properties', {}), False)
- self.binaries.host = BinaryTable(config.get('binaries', {}), False)
+ properties.host = Properties(config.get('properties', {}), False)
+ binaries.host = BinaryTable(config.get('binaries', {}), False)
if 'host_machine' in config:
- self.machines.host = MachineInfo.from_literal(config['host_machine'])
+ machines.host = MachineInfo.from_literal(config['host_machine'])
if 'target_machine' in config:
- self.machines.target = MachineInfo.from_literal(config['target_machine'])
- self.paths.host = Directories(**config.get('paths', {}))
+ machines.target = MachineInfo.from_literal(config['target_machine'])
+ paths.host = Directories(**config.get('paths', {}))
+
+ ## "freeze" now initialized configuration, and "save" to the class.
- self.machines.default_missing()
- self.binaries.default_missing()
- self.properties.default_missing()
- self.paths.default_missing()
+ self.machines = machines.default_missing()
+ self.binaries = binaries.default_missing()
+ self.properties = properties.default_missing()
+ self.paths = paths.default_missing()
exe_wrapper = self.binaries.host.lookup_entry('exe_wrapper')
if exe_wrapper is not None:
@@ -1233,9 +1248,6 @@ class Environment:
self._handle_exceptions(popen_exceptions, linkers, 'linker')
raise EnvironmentException('Unknown static linker "%s"' % ' '.join(linkers))
- def detect_build_machine(self, compilers = None):
- self.machines.build = detect_machine_info(compilers)
-
def get_source_dir(self):
return self.source_dir