Skip to content

fix: Build and run build scripts in lsif command #17864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use vfs::{
AbsPath, AbsPathBuf, VfsPath,
};

#[derive(Debug)]
pub struct LoadCargoConfig {
pub load_out_dirs_from_check: bool,
pub with_proc_macro_server: ProcMacroServerChoice,
Expand Down Expand Up @@ -69,6 +70,7 @@ pub fn load_workspace(
Box::new(loader)
};

tracing::debug!(?load_config, "LoadCargoConfig");
let proc_macro_server = match &load_config.with_proc_macro_server {
ProcMacroServerChoice::Sysroot => ws
.find_sysroot_proc_macro_srv()
Expand All @@ -81,6 +83,14 @@ pub fn load_workspace(
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(
&mut |path: &AbsPath| {
Expand Down
11 changes: 6 additions & 5 deletions crates/rust-analyzer/src/cli/lsif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,26 +276,27 @@ impl flags::Lsif {
eprintln!("Generating LSIF started...");
let now = Instant::now();
let cargo_config =
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
&CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
let no_progress = &|_| ();
let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: true,
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
prefill_caches: false,
};
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 root = workspace.workspace_root().to_owned();
let build_scripts = workspace.run_build_scripts(cargo_config, no_progress)?;
workspace.set_build_scripts(build_scripts);

let (db, vfs, _proc_macro) =
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?;
let host = AnalysisHost::with_database(db);
let db = host.raw_database();
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);
lsif.add_vertex(lsif::Vertex::MetaData(lsif::MetaData {
Expand Down