I aware that we can use different dependencies
based on the compiled target, like:
[dependencies]
[target.'cfg(target_arch="wasm32")'.dependencies]
wasm-bindgen = "0.2.29"
[target.'cfg(target_os="android")'.dependencies]
jni = { version = "0.5", default-features = false }
Can we define crate-type
based on the target type as well, I tried the below but it failed;
[lib]
name = "greetings"
crate-type = ["rlib"]
[target.'cfg(target_arch="wasm32")'.lib]
crate-type = ["cdylib"]
[target.'cfg(target_os="android")'.lib]
crate-type = ["dylib"]
[target.'cfg(target_os="ios",target_arch="armv7s")'.lib]
crate-type = ["cdylib"]
[target.'cfg(target_os="ios",not(target_arch="armv7s"))'.lib]
crate-type = ["staticlib"]
Once I tried compiling for was32
for example, I got the below error:
Hasans-Air:utils2 h_ajsf$ wasm-pack build
**[1/9]** 🦀 Checking `rustc` version...
**[2/9]** 🔧 Checking crate configuration...
crate-type must be cdylib to compile to wasm32-unknown-unknown. Add the following to your Cargo.toml file:
[lib]
crate-type = ["cdylib", "rlib"]