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

There are no documentation that cargo currently does not tell build script if cfg!(test) or not #13294

Closed
anatawa12 opened this issue Jan 14, 2024 · 1 comment · Fixed by #14676
Labels
A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation A-environment-variables Area: environment variables S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@anatawa12
Copy link

In #4789, an member of the repository says "This is currently intentional behavior because build scripts don't have a "I'm running tests" mode." but it looks there are no documentation about that in cargo book.

https://github.com/rust-lang/cargo/blob/92395d90106b3b61bcb68bcf2069052c93771764/src/doc/src/reference/environment-variables.md#environment-variables-cargo-sets-for-build-scripts
https://github.com/rust-lang/cargo/blob/92395d90106b3b61bcb68bcf2069052c93771764/src/doc/src/reference/build-scripts.md

I think it's good to mention that in the cargo book.

@anatawa12 anatawa12 changed the title There are no documentation that cargo currently does not tell build script if cfg!(test) There are no documentation that cargo currently does not tell build script if cfg!(test) or not Jan 14, 2024
@weihanglo weihanglo added the S-triage Status: This issue is waiting on initial triage. label Jan 19, 2024
@weihanglo
Copy link
Member

Thanks for the report. And yes we can have something alike that [target] has:

Do not try to match on debug_assertions or Cargo features like feature="foo".

@weihanglo weihanglo added S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review A-documenting-cargo-itself Area: Cargo's documentation A-build-scripts Area: build.rs scripts A-environment-variables Area: environment variables and removed S-triage Status: This issue is waiting on initial triage. S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review labels Mar 28, 2024
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 A-environment-variables Area: environment variables S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants