From 0acf0e50656df06aa41ec3ecdd3beff6989dc601 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 29 Sep 2024 07:59:23 -0300 Subject: [PATCH] fix cfg!(dev) --- crates/tauri/build.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/tauri/build.rs b/crates/tauri/build.rs index 57d912105..8b4b88c4d 100644 --- a/crates/tauri/build.rs +++ b/crates/tauri/build.rs @@ -226,13 +226,6 @@ fn alias(alias: &str, has_feature: bool) { } fn main() { - let custom_protocol = has_feature("custom-protocol"); - let dev = !custom_protocol; - alias("custom_protocol", custom_protocol); - alias("dev", dev); - - println!("cargo:dev={dev}"); - let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); let mobile = target_os == "ios" || target_os == "android"; alias("desktop", !mobile); @@ -255,9 +248,18 @@ fn main() { } // a workaround for default features activation based on profile - if has_default && env::var("PROFILE").as_deref() == Ok("release") { + let custom_protocol = if has_default && env::var("PROFILE").as_deref() == Ok("release") { println!("cargo:rustc-cfg=feature=\"custom-protocol\""); - } + true + } else { + has_feature("custom-protocol") + }; + + let dev = !custom_protocol; + alias("custom_protocol", custom_protocol); + alias("dev", dev); + + println!("cargo:dev={dev}"); let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());