diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-10-18 20:55:10 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-10-18 20:55:10 +0300 |
commit | ae06ca2afc58901d9d72f13f662701cf12281b51 (patch) | |
tree | 25421861a84584438b39a3972b62d7398ac5d99b | |
parent | 4a899f2d9becbd204e6f63dbf4fb7be921a1ce71 (diff) | |
download | meson-ae06ca2afc58901d9d72f13f662701cf12281b51.zip meson-ae06ca2afc58901d9d72f13f662701cf12281b51.tar.gz meson-ae06ca2afc58901d9d72f13f662701cf12281b51.tar.bz2 |
User options now do a full round trip.
-rw-r--r-- | build.py | 10 | ||||
-rw-r--r-- | coredata.py | 1 | ||||
-rw-r--r-- | environment.py | 9 | ||||
-rw-r--r-- | interpreter.py | 4 | ||||
-rwxr-xr-x | meson.py | 2 | ||||
-rwxr-xr-x | mesongui.py | 30 |
6 files changed, 39 insertions, 17 deletions
@@ -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: @@ -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): |