Skip to content

Commit 44ca3b2

Browse files
committed
stdbuf: add external_libstdbuf cfg alias
1 parent 6c21d58 commit 44ca3b2

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/stdbuf/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ workspace = true
1919
[lib]
2020
path = "src/stdbuf.rs"
2121

22+
[build-dependencies]
23+
cfg_aliases.workspace = true
24+
2225
[dependencies]
2326
clap = { workspace = true }
2427
libstdbuf = { package = "uu_stdbuf_libstdbuf", version = "0.6.0", path = "src/libstdbuf" }

src/uu/stdbuf/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use std::fs;
99
use std::path::Path;
1010
use std::process::Command;
1111

12+
use cfg_aliases::cfg_aliases;
13+
1214
#[cfg(any(
1315
target_os = "linux",
1416
target_os = "android",
@@ -32,6 +34,10 @@ mod platform {
3234
}
3335

3436
fn main() {
37+
cfg_aliases! {
38+
external_libstdbuf: { feature = "feat_external_libstdbuf" },
39+
}
40+
3541
println!("cargo:rerun-if-changed=build.rs");
3642
println!("cargo:rerun-if-changed=src/libstdbuf/src/libstdbuf.rs");
3743

src/uu/stdbuf/src/stdbuf.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod options {
3030
}
3131

3232
#[cfg(all(
33-
not(feature = "feat_external_libstdbuf"),
33+
not(external_libstdbuf),
3434
any(
3535
target_os = "linux",
3636
target_os = "android",
@@ -42,10 +42,10 @@ mod options {
4242
))]
4343
const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.so"));
4444

45-
#[cfg(all(not(feature = "feat_external_libstdbuf"), target_vendor = "apple"))]
45+
#[cfg(all(not(external_libstdbuf), target_vendor = "apple"))]
4646
const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.dylib"));
4747

48-
#[cfg(all(not(feature = "feat_external_libstdbuf"), target_os = "cygwin"))]
48+
#[cfg(all(not(external_libstdbuf), target_os = "cygwin"))]
4949
const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.dll"));
5050

5151
enum BufferType {
@@ -158,7 +158,7 @@ fn set_command_env(command: &mut process::Command, buffer_name: &str, buffer_typ
158158
}
159159
}
160160

161-
#[cfg(not(feature = "feat_external_libstdbuf"))]
161+
#[cfg(not(external_libstdbuf))]
162162
fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
163163
use std::fs::File;
164164
use std::io::Write;
@@ -172,7 +172,7 @@ fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
172172
Ok((preload.to_owned(), inject_path))
173173
}
174174

175-
#[cfg(feature = "feat_external_libstdbuf")]
175+
#[cfg(external_libstdbuf)]
176176
fn get_preload_env(_tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
177177
let (preload, extension) = preload_strings()?;
178178

0 commit comments

Comments
 (0)