-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Enable CARGO_CFG_DEBUG_ASSERTIONS in build scripts based on profile #16160
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
5ca05d3
8c298d0
90d4e7a
be3ebae
cf9c97e
ee5e6e3
2eb1ecc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For future reference, in Conventional commits, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -554,3 +554,40 @@ fn build_script_debug_assertions_override_release() { | |
| // Release profile with debug-assertions explicitly enabled | ||
| p.cargo("check --release").run(); | ||
| } | ||
|
|
||
| #[cargo_test] | ||
| fn build_script_debug_assertions_build_override() { | ||
| let build_rs = r#" | ||
| fn main() { | ||
| let profile = std::env::var("PROFILE").unwrap(); | ||
| if profile == "debug" { | ||
| assert!(!cfg!(debug_assertions)); | ||
| } else if profile == "release" { | ||
| assert!(cfg!(debug_assertions)); | ||
| } | ||
| } | ||
| "#; | ||
|
|
||
| let p = project() | ||
| .file( | ||
| "Cargo.toml", | ||
| r#" | ||
| [package] | ||
| name = "foo" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [profile.dev.build-override] | ||
| debug-assertions = false | ||
|
|
||
| [profile.release.build-override] | ||
| debug-assertions = true | ||
| "#, | ||
| ) | ||
| .file("src/lib.rs", r#""#) | ||
| .file("build.rs", build_rs) | ||
| .build(); | ||
|
|
||
| p.cargo("check").run(); | ||
| p.cargo("check --release").run(); | ||
| } | ||
|
Comment on lines
+558
to
+593
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this checking dev and release? The test is only relevant for the profile There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is checking both to verify that build-override correctly affects build script compilation in both profiles. It's showing the override works bidirectionally: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, for some reason I had missed the use of We don't really need tests for each of these two profiles. Once we test things in one profile, its sufficient for all. |
||
Uh oh!
There was an error while loading. Please reload this page.