Skip to content

Commit b5e002c

Browse files
committed
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 <[email protected]>
1 parent 518d095 commit b5e002c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mesonbuild/interpreter/interpreter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,11 @@ def _do_subproject_cargo(self, subp_name: str, subdir: str,
10601060
except cargo.TomlImplementationMissing as e:
10611061
raise MesonException(f'Failed to load Cargo.lock: {e!s}')
10621062

1063-
ast = cargo_int.interpret(subdir)
1063+
if os.path.exists(os.path.join(self.environment.get_source_dir(), subdir, environment.build_filename)):
1064+
ast = None
1065+
else:
1066+
ast = cargo_int.interpret(subdir)
1067+
10641068
return self._do_subproject_meson(
10651069
subp_name, subdir, default_options, kwargs, ast,
10661070
relaxations={InterpreterRuleRelaxation.CARGO_SUBDIR},

0 commit comments

Comments
 (0)