Merge pull request #104 from nabijaczleweli/main

Point links to just basename-ver, print them the right way 'round
This commit is contained in:
Ryan 2022-03-14 11:58:27 +13:00 committed by GitHub
commit 856728b2c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
use std::path::PathBuf; use std::path::{PathBuf, Path};
use cargo_toml::Product; use cargo_toml::Product;
use log::debug; use log::debug;
@ -70,8 +70,8 @@ impl BinFile {
format!( format!(
"{} ({} -> {})", "{} ({} -> {})",
self.base_name, self.base_name,
self.dest.display(), self.link.display(),
self.link.display() self.link_dest().display()
) )
} }
@ -102,18 +102,26 @@ impl BinFile {
std::fs::remove_file(&self.link)?; std::fs::remove_file(&self.link)?;
} }
let dest = self.link_dest();
debug!( debug!(
"Create link '{}' pointing to '{}'", "Create link '{}' pointing to '{}'",
self.link.display(), self.link.display(),
self.dest.display() dest.display()
); );
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
std::os::unix::fs::symlink(&self.dest, &self.link)?; std::os::unix::fs::symlink(dest, &self.link)?;
#[cfg(target_family = "windows")] #[cfg(target_family = "windows")]
std::os::windows::fs::symlink_file(&self.dest, &self.link)?; std::os::windows::fs::symlink_file(dest, &self.link)?;
Ok(()) Ok(())
} }
fn link_dest(&self) -> &Path {
#[cfg(target_family = "unix")]
{ Path::new(self.dest.file_name().unwrap()) }
#[cfg(target_family = "windows")]
{ &self.dest }
}
} }
/// Data required to get bin paths /// Data required to get bin paths