Skip to content
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

Improve documentation on using cfg values with build scripts #12198

Open
ehuss opened this issue May 29, 2023 · 2 comments
Open

Improve documentation on using cfg values with build scripts #12198

ehuss opened this issue May 29, 2023 · 2 comments
Labels
A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@ehuss
Copy link
Contributor

ehuss commented May 29, 2023

The docs don't clearly specify how to properly read cfg values in a build script:

Some things I think might be good to cover:

  • Don't use cfg! or #[cfg] for target-related configs (only host-related to the build script itself).
  • Don't examine the TARGET env for specific values, use the CARGO_CFG_* values instead.
  • Some examples of how to properly handle comma-separated values (and maybe explicitly document which env vars have multiple values? or assume all of them do?).

This would be relevant on these pages:

The environment variables page could contain a link to the build-script-examples page that shows how to use them.

Some discussion here: https://internals.rust-lang.org/t/futher-extensions-to-cfg-target-family-and-concerns-about-breakage/16313

@ehuss ehuss added A-documenting-cargo-itself Area: Cargo's documentation S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review A-build-scripts Area: build.rs scripts labels May 29, 2023
@epage
Copy link
Contributor

epage commented Sep 20, 2023

#12432 might also help with this

@epage
Copy link
Contributor

epage commented Dec 4, 2024

I believe #14881 is a case of someone running into this confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

No branches or pull requests

2 participants