Move to coredata some methods handling options

Those methods only use coredata object, so better just move them as a
coredata method.
pull/3705/head
Xavier Claessens 7 years ago committed by Nirbheek Chauhan
parent 3e6dc8fb71
commit 8fb72510c3
  1. 31
      mesonbuild/coredata.py
  2. 9
      mesonbuild/environment.py
  3. 2
      mesonbuild/interpreter.py
  4. 25
      mesonbuild/mconf.py

@ -351,6 +351,37 @@ class CoreData:
def get_external_preprocess_args(self, lang):
return self.external_preprocess_args[lang]
def merge_user_options(self, options):
for (name, value) in options.items():
if name not in self.user_options:
self.user_options[name] = value
else:
oldval = self.user_options[name]
if type(oldval) != type(value):
self.user_options[name] = value
def set_options(self, options):
for o in options:
if '=' not in o:
raise MesonException('Value "%s" not of type "a=b".' % o)
(k, v) = o.split('=', 1)
if is_builtin_option(k):
self.set_builtin_option(k, v)
elif k in self.backend_options:
tgt = self.backend_options[k]
tgt.set_value(v)
elif k in self.user_options:
tgt = self.user_options[k]
tgt.set_value(v)
elif k in self.compiler_options:
tgt = self.compiler_options[k]
tgt.set_value(v)
elif k in self.base_options:
tgt = self.base_options[k]
tgt.set_value(v)
else:
raise MesonException('Unknown option %s.' % k)
def load(build_dir):
filename = os.path.join(build_dir, 'meson-private', 'coredata.dat')
load_fail_msg = 'Coredata file {!r} is corrupted. Try with a fresh build tree.'.format(filename)

@ -386,15 +386,6 @@ class Environment:
previous_is_plaind = i == '-D'
return False
def merge_options(self, options):
for (name, value) in options.items():
if name not in self.coredata.user_options:
self.coredata.user_options[name] = value
else:
oldval = self.coredata.user_options[name]
if type(oldval) != type(value):
self.coredata.user_options[name] = value
@staticmethod
def get_gnu_compiler_defines(compiler):
"""

@ -2306,7 +2306,7 @@ to directly access options of other subprojects.''')
self.build.environment.cmd_line_options.projectoptions,
)
oi.process(self.option_file)
self.build.environment.merge_options(oi.options)
self.coredata.merge_user_options(oi.options)
self.set_backend()
self.active_projectname = proj_name
self.project_version = kwargs.get('version', 'undefined')

@ -42,6 +42,9 @@ class Conf:
def clear_cache(self):
self.coredata.deps = {}
def set_options(self, options):
self.coredata.set_options(options)
def save(self):
# Only called if something has changed so overwrite unconditionally.
coredata.save(self.coredata, self.build_dir)
@ -94,28 +97,6 @@ class Conf:
else:
print(' {0:{width[0]}} {1:{width[1]}} {3:{width[3]}}'.format(*line, width=col_widths))
def set_options(self, options):
for o in options:
if '=' not in o:
raise ConfException('Value "%s" not of type "a=b".' % o)
(k, v) = o.split('=', 1)
if coredata.is_builtin_option(k):
self.coredata.set_builtin_option(k, v)
elif k in self.coredata.backend_options:
tgt = self.coredata.backend_options[k]
tgt.set_value(v)
elif k in self.coredata.user_options:
tgt = self.coredata.user_options[k]
tgt.set_value(v)
elif k in self.coredata.compiler_options:
tgt = self.coredata.compiler_options[k]
tgt.set_value(v)
elif k in self.coredata.base_options:
tgt = self.coredata.base_options[k]
tgt.set_value(v)
else:
raise ConfException('Unknown option %s.' % k)
def print_conf(self):
print('Core properties:')
print(' Source dir', self.build.environment.source_dir)

Loading…
Cancel
Save