summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/ast/introspection.py4
-rw-r--r--mesonbuild/environment.py11
-rw-r--r--mesonbuild/interpreter/interpreter.py8
3 files changed, 13 insertions, 10 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index e610b536d..b4cf8203c 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -128,10 +128,8 @@ class IntrospectionInterpreter(AstInterpreter):
if os.path.isdir(os.path.join(subprojects_dir, i)):
self.do_subproject(SubProject(i))
- self.coredata.init_backend_options(self.backend)
- options = {k: v for k, v in self.environment.options.items() if self.environment.coredata.optstore.is_backend_option(k)}
+ self.environment.init_backend_options(self.backend)
- self.coredata.set_options(options)
self._add_languages(proj_langs, True, MachineChoice.HOST)
self._add_languages(proj_langs, True, MachineChoice.BUILD)
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 689508f09..7d1511633 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -906,6 +906,17 @@ class Environment:
self.coredata = coredata.CoreData(options, self.scratch_dir, meson_command)
self.first_invocation = True
+ def init_backend_options(self, backend_name: str) -> None:
+ # Only init backend options on first invocation otherwise it would
+ # override values previously set from command line.
+ if not self.first_invocation:
+ return
+
+ self.coredata.init_backend_options(backend_name)
+ for k, v in self.options.items():
+ if self.coredata.optstore.is_backend_option(k):
+ self.coredata.optstore.set_option(k, v)
+
def is_cross_build(self, when_building_for: MachineChoice = MachineChoice.HOST) -> bool:
return self.coredata.is_cross_build(when_building_for)
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index e7560f863..73be40eec 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1155,13 +1155,7 @@ class Interpreter(InterpreterBase, HoldableObject):
raise MesonBugException(f'Backend changed from {backend_name} to {self.backend.name}')
self.coredata.optstore.set_option(OptionKey('backend'), self.backend.name, first_invocation=True)
- # Only init backend options on first invocation otherwise it would
- # override values previously set from command line.
- if self.environment.first_invocation:
- self.coredata.init_backend_options(backend_name)
-
- options = {k: v for k, v in self.environment.options.items() if self.environment.coredata.optstore.is_backend_option(k)}
- self.coredata.set_options(options)
+ self.environment.init_backend_options(backend_name)
@typed_pos_args('project', str, varargs=str)
@typed_kwargs(