Get rid of `ConfigData`

pull/4445/head
John Ericson 6 years ago committed by John Ericson
parent edb3585b65
commit e147054d6f
  1. 36
      mesonbuild/coredata.py
  2. 11
      mesonbuild/environment.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.

@ -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:

Loading…
Cancel
Save