Skip to content

Commit 428619d

Browse files
committed
better hypr-data prod guard
1 parent 7bfe001 commit 428619d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/data/build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
fn main() {
2-
if std::env::var("PROFILE").as_deref() == Ok("release") {
2+
let is_release = std::env::var("PROFILE").as_deref() == Ok("release");
3+
// CARGO_PRIMARY_PACKAGE is only set for the crate being directly compiled,
4+
// not for its (dev-)dependencies. A non-primary crate compiled in release
5+
// mode is a dev-dependency of `cargo test --release`, which is fine.
6+
let is_primary = std::env::var("CARGO_PRIMARY_PACKAGE").is_ok();
7+
8+
if is_release && is_primary {
39
panic!(
410
"\n\nhypr-data is a test-only crate.\nDo not add it to [dependencies]; use [dev-dependencies] instead.\n"
511
);

0 commit comments

Comments
 (0)