[F] Maybe fix git install
This commit is contained in:
parent
6ddd762b35
commit
3e47640c1a
1 changed files with 9 additions and 19 deletions
|
|
@ -25,18 +25,20 @@ impl AsciiDistro {
|
|||
}
|
||||
}
|
||||
|
||||
fn anything_that_exist(paths: &[&Path]) -> Option<PathBuf> {
|
||||
paths.iter().copied().find(|p| p.exists()).map(Path::to_path_buf)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Path hack to make file paths work in both workspace and manifest directory
|
||||
let dir = PathBuf::from(env::var_os("CARGO_WORKSPACE_DIR").unwrap_or_else(|| env::var_os("CARGO_MANIFEST_DIR").unwrap()));
|
||||
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
|
||||
// Ensure output directory exists
|
||||
if !o.exists() {
|
||||
fs::create_dir_all(&o).expect("Failed to create OUT_DIR");
|
||||
}
|
||||
|
||||
for file in &["neofetch", "hyfetch"] {
|
||||
let src = dir.join(file);
|
||||
let src = anything_that_exist(&[
|
||||
&dir.join(file),
|
||||
&dir.join("/../../").join(file),
|
||||
]).expect("couldn't find neofetch");
|
||||
let dst = o.join(file);
|
||||
println!("cargo:rerun-if-changed={}", src.display());
|
||||
|
||||
|
|
@ -45,19 +47,7 @@ fn main() {
|
|||
let opt = CopyOptions { overwrite: true, copy_inside: true, ..CopyOptions::default() };
|
||||
fs_extra::dir::copy(&src, &dst, &opt).expect("Failed to copy directory to OUT_DIR");
|
||||
}
|
||||
else {
|
||||
// Check src exists
|
||||
if !src.exists() {
|
||||
panic!("Source file {} does not exist", src.display());
|
||||
}
|
||||
// Check dst parent exists
|
||||
if let Some(parent) = dst.parent() {
|
||||
if !parent.exists() {
|
||||
fs::create_dir_all(parent).expect("Failed to create parent directory for OUT_DIR");
|
||||
}
|
||||
}
|
||||
fs::copy(&src, &dst).expect("Failed to copy file to OUT_DIR");
|
||||
}
|
||||
else { fs::copy(&src, &dst).expect("Failed to copy file to OUT_DIR"); }
|
||||
}
|
||||
|
||||
export_distros(&o.join("neofetch"), &o);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue