From b6117d5040de965de510f575112a70d03112cf15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Quentin?= Date: Thu, 28 Nov 2024 11:52:11 +0100 Subject: [PATCH] Use opt-level to detect debug profile (#2622) --- examples/build.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/build.rs b/examples/build.rs index 848be4d26..6b0dafb09 100644 --- a/examples/build.rs +++ b/examples/build.rs @@ -2,8 +2,11 @@ fn main() { // Allow building examples in CI in debug mode println!("cargo:rustc-check-cfg=cfg(is_not_release)"); println!("cargo:rerun-if-env-changed=CI"); - #[cfg(debug_assertions)] if std::env::var("CI").is_err() { - println!("cargo::rustc-cfg=is_not_release"); + if let Ok(level) = std::env::var("OPT_LEVEL") { + if level == "0" || level == "1" { + println!("cargo::rustc-cfg=is_not_release"); + } + } } }