Skip to content

Commit

Permalink
docs: document we don't alias for ONLY 1 OS[skip ci] (nix-rust#2346)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLauC committed Mar 25, 2024
1 parent 945910d commit 5b1b695
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ When creating newtypes, we use Rust's `CamelCase` type naming convention.
## cfg gates

When creating operating-system-specific functionality, we gate it by
`#[cfg(target_os = ...)]`. If more than one operating system is affected, we
`#[cfg(target_os = ...)]`. If **MORE THAN ONE operating system** is affected, we
prefer to use the cfg aliases defined in build.rs, like `#[cfg(bsd)]`.

Please **DO NOT** use cfg aliases for **ONLY ONE** system as [they are bad][mismatched_target_os].

[mismatched_target_os]: https://rust-lang.github.io/rust-clippy/master/index.html#/mismatched_target_os

## Bitflags

Many C functions have flags parameters that are combined from constants using
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ fn main() {
watchos: { target_os = "watchos" },
tvos: { target_os = "tvos" },


// cfg aliases we would like to use
apple_targets: { any(ios, macos, watchos, tvos) },
bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets) },
linux_android: { any(android, linux) },
Expand Down

0 comments on commit 5b1b695

Please sign in to comment.