Skip to content

Commit cc3a6a4

Browse files
authored
Merge pull request #8566 from sylvestre/fix-publishing
stdbuf: fix a publish issue
2 parents 2be17aa + a9ff704 commit cc3a6a4

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/uu/stdbuf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ path = "src/stdbuf.rs"
2020

2121
[dependencies]
2222
clap = { workspace = true }
23-
libstdbuf = { package = "uu_stdbuf_libstdbuf", path = "src/libstdbuf" }
23+
libstdbuf = { package = "uu_stdbuf_libstdbuf", version = "0.2.0", path = "src/libstdbuf" }
2424
tempfile = { workspace = true }
2525
uucore = { workspace = true, features = ["parser"] }
2626
thiserror = { workspace = true }

src/uu/stdbuf/build.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ fn main() {
5252
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
5353
let target = env::var("TARGET").unwrap_or_else(|_| "unknown".to_string());
5454

55+
// Check if we're building from the repository (where src/libstdbuf exists)
56+
// or from crates.io (where it doesn't)
57+
let libstdbuf_src = Path::new("src/libstdbuf");
58+
if !libstdbuf_src.exists() {
59+
// When building from crates.io, libstdbuf is already available as a dependency
60+
// We can't build it here, so we'll need to handle this differently
61+
// For now, we'll create a dummy library file to satisfy the include_bytes! macro
62+
let lib_name = format!("libstdbuf{}", platform::DYLIB_EXT);
63+
let dest_path = Path::new(&out_dir).join(&lib_name);
64+
65+
// Create an empty file as a placeholder
66+
// The actual library will be provided by the dependency
67+
fs::write(&dest_path, []).expect("Failed to create placeholder libstdbuf");
68+
return;
69+
}
70+
5571
// Create a separate build directory for libstdbuf to avoid conflicts
5672
let build_dir = Path::new(&out_dir).join("libstdbuf-build");
5773
fs::create_dir_all(&build_dir).expect("Failed to create build directory");
@@ -66,11 +82,8 @@ fn main() {
6682
// See the tracking issue: https://github.com/rust-lang/cargo/issues/9096
6783
let mut cmd = Command::new(&cargo);
6884
cmd.env_clear().envs(env::vars());
69-
cmd.current_dir(Path::new("src/libstdbuf")).args([
70-
"build",
71-
"--target-dir",
72-
build_dir.to_str().unwrap(),
73-
]);
85+
cmd.current_dir(libstdbuf_src)
86+
.args(["build", "--target-dir", build_dir.to_str().unwrap()]);
7487

7588
// Get the current profile
7689
let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_string());

0 commit comments

Comments
 (0)