Rust: allow to specify more cargo configuration options

This allows to tweak via extractor options some aspects of the cargo
configuration:
* the target architecture
* features (including `*` for all, which we must understand whether to
  set by default)
* cfg overrides

Integration tests will be added in a follow-up commit.
This commit is contained in:
Paolo Tranquilli
2024-11-08 12:21:25 +01:00
parent 083394073a
commit be45e3deed
7 changed files with 155 additions and 33 deletions

View File

@@ -130,11 +130,9 @@ fn main() -> anyhow::Result<()> {
}
extractor.extract_without_semantics(file, "no manifest found");
}
let target_dir = &cfg
.cargo_target_dir
.unwrap_or_else(|| cfg.scratch_dir.join("target"));
let cargo_config = cfg.to_cargo_config();
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, target_dir) {
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, &cargo_config) {
let semantics = Semantics::new(db);
for file in files {
let Some(id) = path_to_file_id(file, vfs) else {