Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ linker = "aarch64-linux-gnu-gcc"
rustflags = ["-C", "target-feature=+crt-static"]
[target.'cfg(target_env = "msvc")']
rustflags = ["-C", "target-feature=+crt-static"]

[env]
# See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml
LIBSTDBUF_DIR = "/usr/local/libexec/coreutils"
20 changes: 0 additions & 20 deletions src/uu/stdbuf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,6 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/libstdbuf/src/libstdbuf.rs");

// Check for external stdbuf feature requirements
#[cfg(feature = "feat_external_libstdbuf")]
{
if env::var("LIBSTDBUF_DIR").is_err() {
eprintln!(
"\n\x1b[31mError:\x1b[0m The 'feat_external_libstdbuf' feature requires the LIBSTDBUF_DIR environment variable to be set."
);
eprintln!(
"\x1b[33mUsage:\x1b[0m LIBSTDBUF_DIR=/path/to/lib/directory cargo build --features feat_external_libstdbuf"
);
eprintln!(
"\x1b[33mExample:\x1b[0m LIBSTDBUF_DIR=/usr/lib cargo build --features feat_external_libstdbuf"
);
eprintln!(
"\nThis directory should point to where libstdbuf.so / libstdbuf.dylib will be installed on the target system."
);
std::process::exit(1);
}
}

let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
let target = env::var("TARGET").unwrap_or_else(|_| "unknown".to_string());

Expand Down
7 changes: 5 additions & 2 deletions src/uu/stdbuf/src/stdbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
#[cfg(feature = "feat_external_libstdbuf")]
fn get_preload_env(_tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
// Use the directory provided at compile time via LIBSTDBUF_DIR environment variable
// This will fail to compile if LIBSTDBUF_DIR is not set, which is the desired behavior
const LIBSTDBUF_DIR: &str = env!("LIBSTDBUF_DIR");
// cannot use unwrap_or <https://github.com/rust-lang/rust/issues/143874>
const LIBSTDBUF_DIR: &str = match option_env!("LIBSTDBUF_DIR") {
Some(v) => v,
None => "/usr/local/libexec/coreutils",
};

let (preload, extension) = preload_strings();

Expand Down
Loading