From 8b7cc4a0dc036334723bc4617bfb9220eedafa30 Mon Sep 17 00:00:00 2001 From: Mark Friedenbach Date: Fri, 8 Dec 2023 11:46:48 -0800 Subject: [PATCH] Do not use "bevy/dynamic_linking" or "bevy/file_watcher" on wasm --- Cargo.toml | 6 ------ build.rs | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4d864092..b07f6978 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,12 +68,6 @@ codegen-units = 1 inherits = "release" lto = "thin" -[features] -dev = [ - "bevy/dynamic_linking", - "bevy/file_watcher", -] - [dependencies] bevy = { workspace = true } bevy_asset_loader = { version = "0.18" } diff --git a/build.rs b/build.rs index a28a9eb7..11ae5d95 100644 --- a/build.rs +++ b/build.rs @@ -11,6 +11,14 @@ fn main() { // on windows we will set our app icon as icon for the executable embed_resource::compile("build/windows/icon.rc"); } + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let profile = env::var("PROFILE").unwrap(); + if !target_arch.contains("wasm") && profile.contains("debug") { + // Use dynamic linking for faster recompilation + println!("cargo:rustc-cfg=feature=\"bevy/dynamic_linking\""); + // Enable bevy's asset hot-reloading capability + println!("cargo:rustc-cfg=feature=\"bevy/file_watcher\""); + } } // End of File