summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-10-26 12:22:03 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-12-22 11:58:30 +0100
commit88e61261265607a4bcbeabc055e643d2ee2e66dd (patch)
treeb75b7765fda5e0ecc3e25694c769dbe9a16fd0a4
parent28db962cd183a961d9057a5b210d17d38771c9e6 (diff)
downloadmeson-88e61261265607a4bcbeabc055e643d2ee2e66dd.tar.gz
cargo: allow overriding Meson's Cargo interpreter
Some projects may want to override Meson's AST generation for Cargo projects. This was not really doable before without hard coding the results of feature resolution; however, now it will be possible by accessing the results of the global feature resolution from the Rust module's workspace object. At the same time, the subproject must keep using the Cargo method, which is forced by the workspace object's subproject() method, because otherwise the interpreter is not propagated. So just skip the interpretation phase if a Meson.build is present. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/interpreter/interpreter.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 3b87f48ea..323daefed 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1060,7 +1060,11 @@ class Interpreter(InterpreterBase, HoldableObject):
except cargo.TomlImplementationMissing as e:
raise MesonException(f'Failed to load Cargo.lock: {e!s}')
- ast = cargo_int.interpret(subdir)
+ if os.path.exists(os.path.join(self.environment.get_source_dir(), subdir, environment.build_filename)):
+ ast = None
+ else:
+ ast = cargo_int.interpret(subdir)
+
return self._do_subproject_meson(
subp_name, subdir, default_options, kwargs, ast,
relaxations={InterpreterRuleRelaxation.CARGO_SUBDIR},