1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

Merge pull request #2843 from tertsdiepraam/stdbuf/fix-cargo-git-build

stdbuf: fix cargo --git build (#1276) (Attempt 2)
This commit is contained in:
Sylvestre Ledru 2022-01-02 23:06:59 +01:00 committed by GitHub
commit 3c68988ae7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,17 +20,23 @@ mod platform {
} }
fn main() { 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(); let out_dir = env::var("OUT_DIR").unwrap();
let libstdbuf = format!( let mut target_dir = Path::new(&out_dir);
"{}/../../../{}/{}/deps/liblibstdbuf{}",
manifest_dir, // Depending on how this is util is built, the directory structure. This seems to work for now.
env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_string()), // Here are three cases to test when changing this:
profile, // - cargo run
platform::DYLIB_EXT // - cross run
); // - cargo install --git
let mut name = target_dir.file_name().unwrap().to_string_lossy();
while name != "target" && !name.starts_with("cargo-install") {
target_dir = target_dir.parent().unwrap();
name = target_dir.file_name().unwrap().to_string_lossy();
}
let mut libstdbuf = target_dir.to_path_buf();
libstdbuf.push(env::var("PROFILE").unwrap());
libstdbuf.push("deps");
libstdbuf.push(format!("liblibstdbuf{}", platform::DYLIB_EXT));
fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap(); fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap();
} }