Skip to content

docs: document we don't alias for ONLY 1 OS[skip ci] #2346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2024
Merged
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
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