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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ nix = { workspace = true, features = ["fs", "signal"] }
rustix = { workspace = true, features = ["net", "process"] }

[build-dependencies]
cfg_aliases.workspace = true
phf_codegen.workspace = true

[features]
Expand Down
10 changes: 10 additions & 0 deletions build.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this applied for uu_*? Or coreutils and test only?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this applied for uu_*? Or coreutils and test only?

These changes affect coreutils package only (including tests/by-util).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we have to define cfg aliases in each package, at least based on my conclusions in #11016.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want the full buffet, could we put the alias definitions in a shared build helper that each package’s build.rs calls? Cargo would still need the hookup in each package, but at least we’d only cook the BSD list once

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we put the alias definitions in a shared build helper that each package’s build.rs calls?

We already tried and failed to make that work: #11016 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we reuse uucore_procs for a small platform_cfg_aliases!() macro called from each build script? It could supply the shared platform-only aliases and accept package-specific aliases as input. That would preserve the existing cfg checks without another helper crate or cross-package includes. Each package would still need to opt in, but perhaps we could try it just for root + stty first?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We found the right approach for a shared build helper: #15634.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ pub fn main() {
const FEATURE_PREFIX: &str = "feat_";
const OVERRIDE_PREFIX: &str = "uu_";

cfg_aliases::cfg_aliases! {
bsd: { any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
) },
};

// Do not rebuild build script unless the script itself or the enabled features are modified
// See <https://doc.rust-lang.org/cargo/reference/build-scripts.html#change-detection>
println!("cargo:rerun-if-changed=build.rs");
Expand Down
48 changes: 6 additions & 42 deletions tests/by-util/test_stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,7 @@ fn invalid_setting() {

#[test]
fn invalid_baud_setting() {
#[cfg(not(any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
)))]
#[cfg(not(bsd))]
new_ucmd!()
.args(&["100"])
.fails()
Expand All @@ -180,25 +174,13 @@ fn invalid_baud_setting() {
.fails()
.stderr_contains("missing argument to 'ospeed'");

#[cfg(not(any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
)))]
#[cfg(not(bsd))]
new_ucmd!()
.args(&["ispeed", "995"])
.fails()
.stderr_contains("invalid ispeed '995'");

#[cfg(not(any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
)))]
#[cfg(not(bsd))]
new_ucmd!()
.args(&["ospeed", "995"])
.fails()
Expand Down Expand Up @@ -471,13 +453,7 @@ fn grouped_flag_removal() {
#[ignore = "Fails because cargo test does not run in a tty"]
fn baud_rate_validation() {
// Test various baud rate formats
#[cfg(any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
))]
#[cfg(bsd)]
{
// BSD accepts numeric baud rates
new_ucmd!().args(&["9600"]).fails(); // Fails due to no TTY, but validates parsing
Expand Down Expand Up @@ -1473,13 +1449,7 @@ fn invalid_baud_rate() {

// On non-BSD systems, test invalid numeric baud rate
// On BSD systems, any u32 is accepted, so we skip this test
#[cfg(not(any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
)))]
#[cfg(not(bsd))]
{
new_ucmd!()
.args(&["ospeed", "999999999"])
Expand Down Expand Up @@ -1632,13 +1602,7 @@ fn test_ispeed_ospeed_valid_speeds() {
}

#[test]
#[cfg(not(any(
target_vendor = "apple",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "netbsd",
target_os = "openbsd"
)))]
#[cfg(not(bsd))]
#[ignore = "Issue: #9547"]
fn test_ispeed_ospeed_invalid_speeds() {
let (path, _controller, _replica) = pty_path();
Expand Down
Loading