aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.py10
-rw-r--r--coredata.py1
-rw-r--r--environment.py9
-rw-r--r--interpreter.py4
-rwxr-xr-xmeson.py2
-rwxr-xr-xmesongui.py30
6 files changed, 39 insertions, 17 deletions
diff --git a/build.py b/build.py
index 64ea6ac..e95020d 100644
--- a/build.py
+++ b/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:
diff --git a/coredata.py b/coredata.py
index 5ba54c6..0c8a0e8 100644
--- a/coredata.py
+++ b/coredata.py
@@ -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:
diff --git a/environment.py b/environment.py
index 3d3d18f..cbf9352 100644
--- a/environment.py
+++ b/environment.py
@@ -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:
diff --git a/interpreter.py b/interpreter.py
index 5c3a317..fe1efd5 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -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:
diff --git a/meson.py b/meson.py
index 9731d1d..4aa7b1c 100755
--- a/meson.py
+++ b/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':
diff --git a/mesongui.py b/mesongui.py
index 8c29178..2f9cac7 100755
--- a/mesongui.py
+++ b/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):