User options now do a full round trip.
This commit is contained in:
parent
4a899f2d9b
commit
ae06ca2afc
10
build.py
10
build.py
|
@ -40,16 +40,6 @@ class Build:
|
|||
self.static_cross_linker = None
|
||||
self.configure_files = []
|
||||
self.pot = []
|
||||
self.user_options = {}
|
||||
|
||||
def merge_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 add_compiler(self, compiler):
|
||||
if len(self.compilers) == 0:
|
||||
|
|
|
@ -36,6 +36,7 @@ class CoreData():
|
|||
self.strip = options.strip
|
||||
self.use_pch = options.use_pch
|
||||
self.coverage = options.coverage
|
||||
self.user_options = {}
|
||||
if options.cross_file is not None:
|
||||
self.cross_file = os.path.join(os.getcwd(), options.cross_file)
|
||||
else:
|
||||
|
|
|
@ -852,6 +852,15 @@ class Environment():
|
|||
def is_source(self, fname):
|
||||
return is_source(fname)
|
||||
|
||||
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
|
||||
|
||||
def detect_c_compiler(self, want_cross):
|
||||
evar = 'CC'
|
||||
if self.is_cross_build() and want_cross:
|
||||
|
|
|
@ -703,9 +703,9 @@ class Interpreter():
|
|||
optname = args[0]
|
||||
if not isinstance(optname, str):
|
||||
raise InterpreterException('Argument of get_option must be a string.')
|
||||
if optname not in self.build.user_options:
|
||||
if optname not in self.environment.coredata.user_options:
|
||||
raise InterpreterException('Tried to access unknown option "%s".' % optname)
|
||||
return self.build.user_options[optname].value
|
||||
return self.environment.coredata.user_options[optname].value
|
||||
|
||||
def func_configuration_data(self, node, args, kwargs):
|
||||
if len(args) != 0:
|
||||
|
|
2
meson.py
2
meson.py
|
@ -125,7 +125,7 @@ itself as required.'''
|
|||
if os.path.exists(option_file):
|
||||
oi = optinterpreter.OptionInterpreter()
|
||||
oi.process(option_file)
|
||||
b.merge_options(oi.options)
|
||||
env.merge_options(oi.options)
|
||||
intr = interpreter.Interpreter(b)
|
||||
intr.run()
|
||||
if options.backend == 'ninja':
|
||||
|
|
30
mesongui.py
30
mesongui.py
|
@ -234,8 +234,7 @@ class CoreModel(QAbstractItemModel):
|
|||
return QModelIndex()
|
||||
|
||||
class OptionForm:
|
||||
def __init__(self, build, coredata, form):
|
||||
self.build = build
|
||||
def __init__(self, coredata, form):
|
||||
self.coredata = coredata
|
||||
self.form = form
|
||||
form.addRow(PyQt5.QtWidgets.QLabel("Meson options"))
|
||||
|
@ -262,25 +261,48 @@ class OptionForm:
|
|||
self.set_user_options()
|
||||
|
||||
def set_user_options(self):
|
||||
options = self.build.user_options
|
||||
options = self.coredata.user_options
|
||||
keys = list(options.keys())
|
||||
keys.sort()
|
||||
self.opt_keys = keys
|
||||
self.opt_widgets = []
|
||||
for key in keys:
|
||||
opt = options[key]
|
||||
if isinstance(opt, optinterpreter.UserStringOption):
|
||||
w = PyQt5.QtWidgets.QLineEdit(opt.value)
|
||||
w.textChanged.connect(self.user_option_changed)
|
||||
elif isinstance(opt, optinterpreter.UserBooleanOption):
|
||||
w = QCheckBox('')
|
||||
w.setChecked(opt.value)
|
||||
w.stateChanged.connect(self.user_option_changed)
|
||||
elif isinstance(opt, optinterpreter.UserComboOption):
|
||||
w = QComboBox()
|
||||
for i in opt.choices:
|
||||
w.addItem(i)
|
||||
w.setCurrentText(opt.value)
|
||||
w.currentTextChanged.connect(self.user_option_changed)
|
||||
else:
|
||||
raise RuntimeError("Unknown option type")
|
||||
self.opt_widgets.append(w)
|
||||
self.form.addRow(opt.description, w)
|
||||
|
||||
def user_option_changed(self, dummy=None):
|
||||
for i in range(len(self.opt_keys)):
|
||||
key = self.opt_keys[i]
|
||||
w = self.opt_widgets[i]
|
||||
if isinstance(w, PyQt5.QtWidgets.QLineEdit):
|
||||
newval = w.text()
|
||||
elif isinstance(w, QComboBox):
|
||||
newval = w.currentText()
|
||||
elif isinstance(w, QCheckBox):
|
||||
if w.checkState() == 0:
|
||||
newval = False
|
||||
else:
|
||||
newval = True
|
||||
else:
|
||||
raise RuntimeError('Unknown widget type')
|
||||
self.coredata.user_options[key].value = newval
|
||||
|
||||
def build_type_changed(self, newtype):
|
||||
self.coredata.buildtype = newtype
|
||||
|
||||
|
@ -362,7 +384,7 @@ class MesonGui():
|
|||
self.build_dir = self.build.environment.build_dir
|
||||
self.src_dir = self.build.environment.source_dir
|
||||
self.build_models()
|
||||
self.options = OptionForm(self.build, self.coredata, self.ui.option_form)
|
||||
self.options = OptionForm(self.coredata, self.ui.option_form)
|
||||
self.ui.show()
|
||||
|
||||
def build_models(self):
|
||||
|
|
Loading…
Reference in New Issue