diff --git a/Cargo.toml b/Cargo.toml index 1331839b2..d3d1e6909 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -512,3 +512,22 @@ path = "src/bin/coreutils.rs" name = "uudoc" path = "src/bin/uudoc.rs" required-features = ["uudoc"] + +# The default release profile. It contains all optimizations, without +# sacrificing debug info. With this profile (like in the standard +# release profile), the debug info and the stack traces will still be available. +[profile.release] +lto = true + +# A release-like profile that is tuned to be fast, even when being fast +# compromises on binary size. This includes aborting on panic. +[profile.release-fast] +inherits = "release" +panic = "abort" + +# A release-like profile that is as small as possible. +[profile.release-small] +inherits = "release" +opt-level = "z" +panic = "abort" +strip = true diff --git a/src/uu/stdbuf/build.rs b/src/uu/stdbuf/build.rs index 9d36f20f4..5938f6396 100644 --- a/src/uu/stdbuf/build.rs +++ b/src/uu/stdbuf/build.rs @@ -23,19 +23,29 @@ fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let mut target_dir = Path::new(&out_dir); - // Depending on how this is util is built, the directory structure. This seems to work for now. - // Here are three cases to test when changing this: + // Depending on how this is util is built, the directory structure changes. + // This seems to work for now. Here are three cases to test when changing + // this: + // // - cargo run // - cross run // - cargo install --git // - cargo publish --dry-run + // + // The goal is to find the directory in which we are installing, but that + // depends on the build method, which is annoying. Additionally the env + // 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 + // as the profile name. 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") { target_dir = target_dir.parent().unwrap(); + profile_name = name.clone(); name = target_dir.file_name().unwrap().to_string_lossy(); } let mut dir = target_dir.to_path_buf(); - dir.push(env::var("PROFILE").unwrap()); + dir.push(profile_name.as_ref()); dir.push("deps"); let mut path = None;