From cf153f38de8688d0e400a77f16760c76e4d483a8 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 3 Jan 2024 11:33:42 +0000 Subject: [PATCH] Panic when try to build for wasm32 without vendored feature (except luau) --- Cargo.toml | 3 --- mlua-sys/build/find_normal.rs | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c72e1d..8f2ee52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,9 +60,6 @@ ffi = { package = "mlua-sys", version = "0.4.0", path = "mlua-sys" } [target.'cfg(unix)'.dependencies] libloading = { version = "0.8", optional = true } -[target.'cfg(target_arch = "wasm32")'.dependencies] -ffi = { package = "mlua-sys", version = "0.4.0", path = "mlua-sys", features = ["vendored"] } - [dev-dependencies] trybuild = "1.0" futures = "0.3.5" diff --git a/mlua-sys/build/find_normal.rs b/mlua-sys/build/find_normal.rs index 655814b..26b1200 100644 --- a/mlua-sys/build/find_normal.rs +++ b/mlua-sys/build/find_normal.rs @@ -4,6 +4,12 @@ use std::env; use std::ops::Bound; pub fn probe_lua() { + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + + if target_arch == "wasm32" && cfg!(not(feature = "vendored")) { + panic!("Please enable `vendored` feature to build for wasm32"); + } + let lib_dir = env::var("LUA_LIB").unwrap_or_default(); let lua_lib = env::var("LUA_LIB_NAME").unwrap_or_default();