fix: make bin linkers for non-direct dependencies

Previously, binary linkers weren't made for
non-direct dependencies despite this being the
documented & expected behaviour.
This commit is contained in:
daimond113 2025-03-09 01:33:41 +01:00
parent 9a75ebf637
commit 19d6a07851
No known key found for this signature in database
GPG key ID: 640DC95EC1190354
2 changed files with 27 additions and 14 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed ### Fixed
- Fix path dependencies using project's workspace dependencies by @daimond113 - Fix path dependencies using project's workspace dependencies by @daimond113
- Fix binary linkers not being created for non-direct dependencies by @daimond113
### Changed ### Changed
- Binary linkers are now done in Rust to simplify their implementation and cross-runtime portability by @daimond113 - Binary linkers are now done in Rust to simplify their implementation and cross-runtime portability by @daimond113

View file

@ -25,8 +25,9 @@ use pesde::{
version_matches, Project, RefreshedSources, MANIFEST_FILE_NAME, version_matches, Project, RefreshedSources, MANIFEST_FILE_NAME,
}; };
use std::{ use std::{
collections::{BTreeMap, BTreeSet, HashMap}, collections::{BTreeMap, BTreeSet, HashMap, HashSet},
num::NonZeroUsize, num::NonZeroUsize,
path::Path,
sync::Arc, sync::Arc,
time::Instant, time::Instant,
}; };
@ -47,21 +48,32 @@ impl DownloadAndLinkHooks for InstallHooks {
&self, &self,
graph: &DependencyGraphWithTarget, graph: &DependencyGraphWithTarget,
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
let mut tasks = graph let binary_packages = graph
.values() .iter()
.filter(|node| node.target.bin_path().is_some()) .filter_map(|(id, node)| node.target.bin_path().is_some().then_some(id))
.filter_map(|node| node.node.direct.as_ref()) .collect::<HashSet<_>>();
.map(|(alias, _, _)| {
let bin_folder = self.bin_folder.clone(); let aliases = graph
let alias = alias.clone(); .iter()
.flat_map(|(_, node)| node.node.dependencies.iter())
.filter_map(|(id, alias)| binary_packages.contains(id).then_some(alias))
.collect::<HashSet<_>>();
let curr_exe: Arc<Path> = std::env::current_exe()
.context("failed to get current executable path")?
.as_path()
.into();
let mut tasks = aliases
.into_iter()
.map(|alias| {
let bin_exec_file = self
.bin_folder
.join(alias.as_str())
.with_extension(std::env::consts::EXE_EXTENSION);
let curr_exe = curr_exe.clone();
async move { async move {
let bin_exec_file = bin_folder
.join(alias.as_str())
.with_extension(std::env::consts::EXE_EXTENSION);
let curr_exe =
std::env::current_exe().context("failed to get current executable path")?;
// TODO: remove this in a major release // TODO: remove this in a major release
#[cfg(unix)] #[cfg(unix)]
if fs::metadata(&bin_exec_file) if fs::metadata(&bin_exec_file)