From 88e61261265607a4bcbeabc055e643d2ee2e66dd Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 26 Oct 2025 12:22:03 +0100 Subject: 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 --- mesonbuild/interpreter/interpreter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mesonbuild') 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}, -- cgit v1.2.3