mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 06:26:43 +01:00
resolve dependencies recursively
This commit is contained in:
parent
da39ae3aab
commit
a6511a5ed2
1 changed files with 11 additions and 6 deletions
|
|
@ -63,13 +63,16 @@ impl Rebuilder {
|
|||
}
|
||||
fn load (&mut self, path: &impl AsRef<Path>, recurse: bool) -> Usually<()> {
|
||||
let path: Arc<PathBuf> = Arc::from(PathBuf::from(path.as_ref()));
|
||||
if self.visited.contains(&path) {
|
||||
return Ok(())
|
||||
}
|
||||
self.visited.insert(path.clone());
|
||||
let dll = Arc::new(Dll::new(&Arc::new(PathBuf::from(path.as_ref())), true)?);
|
||||
let dll = Arc::new(Dll::new(&Arc::new(PathBuf::from(path.as_ref())), false)?);
|
||||
self.dlls.insert(dll.name.clone(), dll.clone());
|
||||
if recurse {
|
||||
for dep in dll.deps_by_library.keys() {
|
||||
if let Some(dep) = self.find(dep, true)? {
|
||||
println!("{dep:?}");
|
||||
if let Some(dep) = self.find(dep, false)? {
|
||||
self.load(&dep, recurse)?;
|
||||
} else {
|
||||
panic!("not found: {dep:?}");
|
||||
}
|
||||
|
|
@ -82,9 +85,12 @@ impl Rebuilder {
|
|||
let mut path = base.as_ref().clone();
|
||||
path.push(name.to_lowercase());
|
||||
if verbose {
|
||||
println!("looking for {name} at {path:?}");
|
||||
println!("# looking for {name} at {path:?}");
|
||||
}
|
||||
if std::fs::exists(&path)? {
|
||||
if verbose {
|
||||
println!("# found {name} at {path:?}");
|
||||
}
|
||||
return Ok(Some(canonicalize(&path)?))
|
||||
}
|
||||
}
|
||||
|
|
@ -124,7 +130,7 @@ impl Dll {
|
|||
Some(&deps_by_address),
|
||||
&mut calls_by_source,
|
||||
&mut calls_by_target,
|
||||
true
|
||||
false
|
||||
)?;
|
||||
Ok(Self {
|
||||
name: name.clone(),
|
||||
|
|
@ -357,7 +363,6 @@ fn main () -> Usually<()> {
|
|||
println!("(search {path:?})")
|
||||
}
|
||||
if let Some(path) = rebuilder.find(path.to_str().expect("path must be unicode"), false)? {
|
||||
let mut rebuilder = Rebuilder::default();
|
||||
rebuilder.load(&path, true)?;
|
||||
} else {
|
||||
panic!("Could not find: {path:?}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue