Set option name in constructor. Closes #164.

pull/174/head
Jussi Pakkanen 10 years ago
parent 790fe206e6
commit 214a6b5c0a
  1. 18
      optinterpreter.py

@ -37,16 +37,17 @@ class OptionException(coredata.MesonException):
optname_regex = re.compile('[^a-zA-Z0-9_-]')
class UserOption:
def __init__(self, kwargs):
def __init__(self, name, kwargs):
super().__init__()
self.description = kwargs.get('description', '')
self.name = name
def parse_string(self, valuestring):
return valuestring
class UserStringOption(UserOption):
def __init__(self, kwargs):
super().__init__(kwargs)
def __init__(self, name, kwargs):
super().__init__(name, kwargs)
self.set_value(kwargs.get('value', ''))
def set_value(self, newvalue):
@ -55,8 +56,8 @@ class UserStringOption(UserOption):
self.value = newvalue
class UserBooleanOption(UserOption):
def __init__(self, kwargs):
super().__init__(kwargs)
def __init__(self, name, kwargs):
super().__init__(name, kwargs)
self.set_value(kwargs.get('value', 'true'))
def set_value(self, newvalue):
@ -72,8 +73,8 @@ class UserBooleanOption(UserOption):
raise OptionException('Value "%s" for boolean option "%s" is not a boolean.' % (valuestring, self.name))
class UserComboOption(UserOption):
def __init__(self, kwargs):
super().__init__(kwargs)
def __init__(self, name, kwargs):
super().__init__(name, kwargs)
if 'choices' not in kwargs:
raise OptionException('Combo option missing "choices" keyword.')
self.choices = kwargs['choices']
@ -173,8 +174,7 @@ class OptionInterpreter:
raise OptionException('Option name %s is reserved.' % opt_name)
if self.subproject != '':
opt_name = self.subproject + ':' + opt_name
opt = option_types[opt_type](kwargs)
opt.name = opt_name
opt = option_types[opt_type](opt_name, kwargs)
if opt.description == '':
opt.description = opt_name
if opt_name in self.cmd_line_options:

Loading…
Cancel
Save