Explicitly add buildfiles when constructing ProjectFolders

This commit is contained in:
David Richey 2025-01-24 09:59:06 -06:00
parent 6e4c29f7ce
commit c0c7d5a2e1
2 changed files with 38 additions and 21 deletions

View file

@ -524,6 +524,17 @@ impl ProjectWorkspace {
}
}
pub fn buildfiles(&self) -> Vec<AbsPathBuf> {
match &self.kind {
ProjectWorkspaceKind::Json(project) => project
.crates()
.filter_map(|(_, krate)| krate.build.as_ref().map(|build| build.build_file.clone()))
.map(|build_file| self.workspace_root().join(build_file))
.collect(),
_ => vec![],
}
}
pub fn find_sysroot_proc_macro_srv(&self) -> anyhow::Result<AbsPathBuf> {
self.sysroot.discover_proc_macro_srv()
}
@ -568,27 +579,15 @@ impl ProjectWorkspace {
match &self.kind {
ProjectWorkspaceKind::Json(project) => project
.crates()
.map(|(_, krate)| {
// FIXME: PackageRoots dont allow specifying files, only directories
let build_file = krate
.build
.as_ref()
.map(|build| self.workspace_root().join(&build.build_file))
.as_deref()
.and_then(AbsPath::parent)
.map(ToOwned::to_owned);
PackageRoot {
is_local: krate.is_workspace_member,
include: krate
.include
.iter()
.cloned()
.chain(build_file)
.chain(self.extra_includes.iter().cloned())
.collect(),
exclude: krate.exclude.clone(),
}
.map(|(_, krate)| PackageRoot {
is_local: krate.is_workspace_member,
include: krate
.include
.iter()
.cloned()
.chain(self.extra_includes.iter().cloned())
.collect(),
exclude: krate.exclude.clone(),
})
.collect::<FxHashSet<_>>()
.into_iter()