mirror of
https://github.com/uutils/coreutils
synced 2025-01-20 17:14:21 +00:00
stdbuf: get profile from the end of the path
The path is not always /target/{PROFILE}, because cross uses /target/{TARGET_TRIPLE}/profile, so we have to get the name in another way. StackOverflow recommended the getting the third component from the back of the path
This commit is contained in:
parent
c014cb0655
commit
5dfa9548b7
1 changed files with 8 additions and 3 deletions
|
@ -37,15 +37,20 @@ fn main() {
|
||||||
// var for the profile can only be "debug" or "release", not a custom
|
// var for the profile can only be "debug" or "release", not a custom
|
||||||
// profile name, so we have to use the name of the directory within target
|
// profile name, so we have to use the name of the directory within target
|
||||||
// as the profile name.
|
// as the profile name.
|
||||||
|
//
|
||||||
|
// Adapted from https://stackoverflow.com/questions/73595435/how-to-get-profile-from-cargo-toml-in-build-rs-or-at-runtime
|
||||||
|
let profile_name = out_dir
|
||||||
|
.split(std::path::MAIN_SEPARATOR)
|
||||||
|
.nth_back(3)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut name = target_dir.file_name().unwrap().to_string_lossy();
|
let mut name = target_dir.file_name().unwrap().to_string_lossy();
|
||||||
let mut profile_name = name.clone();
|
|
||||||
while name != "target" && !name.starts_with("cargo-install") {
|
while name != "target" && !name.starts_with("cargo-install") {
|
||||||
target_dir = target_dir.parent().unwrap();
|
target_dir = target_dir.parent().unwrap();
|
||||||
profile_name = name.clone();
|
|
||||||
name = target_dir.file_name().unwrap().to_string_lossy();
|
name = target_dir.file_name().unwrap().to_string_lossy();
|
||||||
}
|
}
|
||||||
let mut dir = target_dir.to_path_buf();
|
let mut dir = target_dir.to_path_buf();
|
||||||
dir.push(profile_name.as_ref());
|
dir.push(profile_name);
|
||||||
dir.push("deps");
|
dir.push("deps");
|
||||||
let mut path = None;
|
let mut path = None;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue