coreutils/src/uu/stdbuf/build.rs

37 lines
993 B
Rust
Raw Normal View History

// spell-checker:ignore (ToDO) dylib libstdbuf deps liblibstdbuf
use std::env;
use std::fs;
use std::path::Path;
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))]
mod platform {
pub const DYLIB_EXT: &str = ".so";
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod platform {
pub const DYLIB_EXT: &str = ".dylib";
}
#[cfg(target_os = "windows")]
mod platform {
pub const DYLIB_EXT: &str = ".dll";
}
fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("Could not find manifest dir");
let profile = env::var("PROFILE").expect("Could not determine profile");
let out_dir = env::var("OUT_DIR").unwrap();
2018-03-12 08:20:58 +00:00
let libstdbuf = format!(
"{}/../../../{}/{}/deps/liblibstdbuf{}",
2018-03-12 08:20:58 +00:00
manifest_dir,
env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_string()),
2018-03-12 08:20:58 +00:00
profile,
platform::DYLIB_EXT
);
fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap();
}