mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Auto merge of #17864 - Veykril:lsif, r=Veykril
fix: Build and run build scripts in lsif command
This commit is contained in:
commit
18414cdf64
2 changed files with 16 additions and 5 deletions
|
@ -25,6 +25,7 @@ use vfs::{
|
||||||
AbsPath, AbsPathBuf, VfsPath,
|
AbsPath, AbsPathBuf, VfsPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct LoadCargoConfig {
|
pub struct LoadCargoConfig {
|
||||||
pub load_out_dirs_from_check: bool,
|
pub load_out_dirs_from_check: bool,
|
||||||
pub with_proc_macro_server: ProcMacroServerChoice,
|
pub with_proc_macro_server: ProcMacroServerChoice,
|
||||||
|
@ -68,6 +69,7 @@ pub fn load_workspace(
|
||||||
Box::new(loader)
|
Box::new(loader)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tracing::debug!(?load_config, "LoadCargoConfig");
|
||||||
let proc_macro_server = match &load_config.with_proc_macro_server {
|
let proc_macro_server = match &load_config.with_proc_macro_server {
|
||||||
ProcMacroServerChoice::Sysroot => ws
|
ProcMacroServerChoice::Sysroot => ws
|
||||||
.find_sysroot_proc_macro_srv()
|
.find_sysroot_proc_macro_srv()
|
||||||
|
@ -80,6 +82,14 @@ pub fn load_workspace(
|
||||||
Err((anyhow::format_err!("proc macro server disabled"), false))
|
Err((anyhow::format_err!("proc macro server disabled"), false))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
match &proc_macro_server {
|
||||||
|
Ok(server) => {
|
||||||
|
tracing::info!(path=%server.path(), "Proc-macro server started")
|
||||||
|
}
|
||||||
|
Err((e, _)) => {
|
||||||
|
tracing::info!(%e, "Failed to start proc-macro server")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (crate_graph, proc_macros) = ws.to_crate_graph(
|
let (crate_graph, proc_macros) = ws.to_crate_graph(
|
||||||
&mut |path: &AbsPath| {
|
&mut |path: &AbsPath| {
|
||||||
|
|
|
@ -276,7 +276,7 @@ impl flags::Lsif {
|
||||||
eprintln!("Generating LSIF started...");
|
eprintln!("Generating LSIF started...");
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let cargo_config =
|
let cargo_config =
|
||||||
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
&CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
|
||||||
let no_progress = &|_| ();
|
let no_progress = &|_| ();
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config = LoadCargoConfig {
|
||||||
load_out_dirs_from_check: true,
|
load_out_dirs_from_check: true,
|
||||||
|
@ -284,10 +284,11 @@ impl flags::Lsif {
|
||||||
prefill_caches: false,
|
prefill_caches: false,
|
||||||
};
|
};
|
||||||
let path = AbsPathBuf::assert_utf8(env::current_dir()?.join(self.path));
|
let path = AbsPathBuf::assert_utf8(env::current_dir()?.join(self.path));
|
||||||
let manifest = ProjectManifest::discover_single(&path)?;
|
let root = ProjectManifest::discover_single(&path)?;
|
||||||
|
let mut workspace = ProjectWorkspace::load(root, cargo_config, no_progress)?;
|
||||||
|
|
||||||
let workspace = ProjectWorkspace::load(manifest, &cargo_config, no_progress)?;
|
let build_scripts = workspace.run_build_scripts(cargo_config, no_progress)?;
|
||||||
let root = workspace.workspace_root().to_owned();
|
workspace.set_build_scripts(build_scripts);
|
||||||
|
|
||||||
let (db, vfs, _proc_macro) =
|
let (db, vfs, _proc_macro) =
|
||||||
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?;
|
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?;
|
||||||
|
@ -295,7 +296,7 @@ impl flags::Lsif {
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
let analysis = host.analysis();
|
let analysis = host.analysis();
|
||||||
|
|
||||||
let si = StaticIndex::compute(&analysis, &root.into());
|
let si = StaticIndex::compute(&analysis, &path.clone().into());
|
||||||
|
|
||||||
let mut lsif = LsifManager::new(&analysis, db, &vfs);
|
let mut lsif = LsifManager::new(&analysis, db, &vfs);
|
||||||
lsif.add_vertex(lsif::Vertex::MetaData(lsif::MetaData {
|
lsif.add_vertex(lsif::Vertex::MetaData(lsif::MetaData {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue