Skip to content

Commit 1b983e3

Browse files
committed
Build and run build scripts in lsif command
1 parent 1ebd727 commit 1b983e3

File tree

2 files changed

+16
-5
lines changed
  • src/tools/rust-analyzer/crates

2 files changed

+16
-5
lines changed

src/tools/rust-analyzer/crates/load-cargo/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use vfs::{
2525
AbsPath, AbsPathBuf, VfsPath,
2626
};
2727

28+
#[derive(Debug)]
2829
pub struct LoadCargoConfig {
2930
pub load_out_dirs_from_check: bool,
3031
pub with_proc_macro_server: ProcMacroServerChoice,
@@ -69,6 +70,7 @@ pub fn load_workspace(
6970
Box::new(loader)
7071
};
7172

73+
tracing::debug!(?load_config, "LoadCargoConfig");
7274
let proc_macro_server = match &load_config.with_proc_macro_server {
7375
ProcMacroServerChoice::Sysroot => ws
7476
.find_sysroot_proc_macro_srv()
@@ -81,6 +83,14 @@ pub fn load_workspace(
8183
Err((anyhow::format_err!("proc macro server disabled"), false))
8284
}
8385
};
86+
match &proc_macro_server {
87+
Ok(server) => {
88+
tracing::info!(path=%server.path(), "Proc-macro server started")
89+
}
90+
Err((e, _)) => {
91+
tracing::info!(%e, "Failed to start proc-macro server")
92+
}
93+
}
8494

8595
let (crate_graph, proc_macros) = ws.to_crate_graph(
8696
&mut |path: &AbsPath| {

src/tools/rust-analyzer/crates/rust-analyzer/src/cli/lsif.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -276,26 +276,27 @@ impl flags::Lsif {
276276
eprintln!("Generating LSIF started...");
277277
let now = Instant::now();
278278
let cargo_config =
279-
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
279+
&CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
280280
let no_progress = &|_| ();
281281
let load_cargo_config = LoadCargoConfig {
282282
load_out_dirs_from_check: true,
283283
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
284284
prefill_caches: false,
285285
};
286286
let path = AbsPathBuf::assert_utf8(env::current_dir()?.join(self.path));
287-
let manifest = ProjectManifest::discover_single(&path)?;
287+
let root = ProjectManifest::discover_single(&path)?;
288+
let mut workspace = ProjectWorkspace::load(root, cargo_config, no_progress)?;
288289

289-
let workspace = ProjectWorkspace::load(manifest, &cargo_config, no_progress)?;
290-
let root = workspace.workspace_root().to_owned();
290+
let build_scripts = workspace.run_build_scripts(cargo_config, no_progress)?;
291+
workspace.set_build_scripts(build_scripts);
291292

292293
let (db, vfs, _proc_macro) =
293294
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?;
294295
let host = AnalysisHost::with_database(db);
295296
let db = host.raw_database();
296297
let analysis = host.analysis();
297298

298-
let si = StaticIndex::compute(&analysis, &root.into());
299+
let si = StaticIndex::compute(&analysis, &path.clone().into());
299300

300301
let mut lsif = LsifManager::new(&analysis, db, &vfs);
301302
lsif.add_vertex(lsif::Vertex::MetaData(lsif::MetaData {

0 commit comments

Comments
 (0)