Skip to content

Commit 0c4f586

Browse files
committed
Add release-fast and release-small targets to Cargo.toml
1 parent 24fb389 commit 0c4f586

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,22 @@ path = "src/bin/coreutils.rs"
512512
name = "uudoc"
513513
path = "src/bin/uudoc.rs"
514514
required-features = ["uudoc"]
515+
516+
# The default release profile. It contains all optimizations, without
517+
# sacrificing debug info. With this profile (like in the standard
518+
# release profile), the debug info and the stack traces will still be available.
519+
[profile.release]
520+
lto = true
521+
522+
# A release-like profile that is tuned to be fast, even when being fast
523+
# compromises on binary size. This includes aborting on panic.
524+
[profile.release-fast]
525+
inherits = "release"
526+
panic = "abort"
527+
528+
# A release-like profile that is as small as possible.
529+
[profile.release-small]
530+
inherits = "release"
531+
opt-level = "z"
532+
panic = "abort"
533+
strip = true

src/uu/stdbuf/build.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,29 @@ fn main() {
2323
let out_dir = env::var("OUT_DIR").unwrap();
2424
let mut target_dir = Path::new(&out_dir);
2525

26-
// Depending on how this is util is built, the directory structure. This seems to work for now.
27-
// Here are three cases to test when changing this:
26+
// Depending on how this is util is built, the directory structure changes.
27+
// This seems to work for now. Here are three cases to test when changing
28+
// this:
29+
//
2830
// - cargo run
2931
// - cross run
3032
// - cargo install --git
3133
// - cargo publish --dry-run
34+
//
35+
// The goal is to find the directory in which we are installing, but that
36+
// depends on the build method, which is annoying. Additionally the env
37+
// var for the profile can only be "debug" or "release", not a custom
38+
// profile name, so we have to use the name of the directory within target
39+
// as the profile name.
3240
let mut name = target_dir.file_name().unwrap().to_string_lossy();
41+
let mut profile_name = name.clone();
3342
while name != "target" && !name.starts_with("cargo-install") {
3443
target_dir = target_dir.parent().unwrap();
44+
profile_name = name.clone();
3545
name = target_dir.file_name().unwrap().to_string_lossy();
3646
}
3747
let mut dir = target_dir.to_path_buf();
38-
dir.push(env::var("PROFILE").unwrap());
48+
dir.push(profile_name.as_ref());
3949
dir.push("deps");
4050
let mut path = None;
4151

0 commit comments

Comments
 (0)