From e147054d6f8b78b306125fd785603ca0519fdfc1 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 28 Nov 2018 01:48:57 -0500 Subject: [PATCH] Get rid of `ConfigData` --- mesonbuild/coredata.py | 36 ------------------------------------ mesonbuild/environment.py | 11 +++++++---- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 8ada86a98..b650f78b7 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -231,42 +231,6 @@ def load_configs(filenames): return config -def _get_section(config, section): - if config.has_section(section): - final = {} - for k, v in config.items(section): - # Windows paths... - v = v.replace('\\', '\\\\') - try: - final[k] = ast.literal_eval(v) - except SyntaxError: - raise MesonException( - 'Malformed value in native file variable: {}'.format(v)) - return final - return {} - - -class ConfigData: - - """Contains configuration information provided by the user for the build.""" - - def __init__(self, config=None): - if config: - self.binaries = _get_section(config, 'binaries') - # global is a keyword and globals is a builtin, rather than mangle it, - # use a similar word - self.universal = _get_section(config, 'globals') - self.subprojects = {s: _get_section(config, s) for s in config.sections() - if s not in {'binaries', 'globals'}} - else: - self.binaries = {} - self.universal = {} - self.subprojects = {} - - def get_binaries(self, name): - return self.binaries.get(name, None) - - # This class contains all data that must persist over multiple # invocations of Meson. It is roughly the same thing as # cmakecache. diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b48868c9b..b10f826ee 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -346,16 +346,17 @@ class Environment: # Similar to coredata.compilers and build.compilers, but lower level in # that there is no meta data, only names/paths. self.binaries = PerMachineDefaultable() + # Just uses hard-coded defaults and environment variables. Might be + # overwritten by a native file. + self.binaries.build = BinaryTable({}) # Misc other properties about each machine. self.properties = PerMachine(Properties(), Properties(), Properties()) if self.coredata.config_files is not None: - config_info = coredata.ConfigData( + config = MesonConfigFile.from_config_parser( coredata.load_configs(self.coredata.config_files)) - else: - config_info = coredata.ConfigData() - self.binaries.build = BinaryTable(config_info.binaries) + self.binaries.build = BinaryTable(config.get('binaries', {})) if self.coredata.cross_file is not None: config = MesonConfigFile.parse_datafile(self.coredata.cross_file) @@ -1168,6 +1169,8 @@ class MesonConfigFile: section = {} for entry in parser[s]: value = parser[s][entry] + # Windows paths... + value = value.replace('\\', '\\\\') if ' ' in entry or '\t' in entry or "'" in entry or '"' in entry: raise EnvironmentException('Malformed variable name %s in cross file..' % entry) try: