dioxus/packages/cli-config/build.rs
Evan Almloff 460a685fa3
Warn if cli-config is not available at compile time (#2135)
* warn if a package relies on the CLI config, but it is not built with the CLI

* fix default features

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2024-03-26 19:10:26 -07:00

11 lines
736 B
Rust

// warn if the "read-config" feature is enabled, but the DIOXUS_CONFIG environment variable is not set
// This means that some library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application.
fn main() {
println!("cargo:rerun-if-env-changed=DIOXUS_CONFIG");
let dioxus_config = std::env::var("DIOXUS_CONFIG");
let built_with_dioxus = dioxus_config.is_ok();
if cfg!(feature = "read-config") && !built_with_dioxus {
println!("cargo:warning=A library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application. Information about the Dioxus CLI is available at https://dioxuslabs.com/learn/0.5/CLI/installation");
}
}