From 5e81c30887a98f247fdca07d214089eae8112e0f Mon Sep 17 00:00:00 2001 From: Carlo Piovesan Date: Wed, 13 Nov 2024 10:38:53 +0100 Subject: [PATCH] Add comments on crate-type switch --- Cargo.toml | 4 ++++ src/wasm_lib.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 6792d64..19ed968 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,10 @@ edition = "2021" crate-type = ["cdylib"] [[example]] +# crate-type can't be (at the moment) be overriden for specific targets +# src/wasm_lib.rs forwards to src/lib.rs so that we can change from cdylib +# (that is needed while compiling natively) to staticlib (needed since the +# actual linking will be done via emcc name = "rusty_quack" path = "src/wasm_lib.rs" crate-type = ["staticlib"] diff --git a/src/wasm_lib.rs b/src/wasm_lib.rs index 2700c77..3f9a73e 100644 --- a/src/wasm_lib.rs +++ b/src/wasm_lib.rs @@ -1,3 +1,14 @@ #![allow(special_module_name)] mod lib; + +// To build the Wasm target, a `staticlib` crate-type is required +// +// This is different than the default needed in native, and there is +// currently no way to select crate-type depending on target. +// +// This file sole purpose is remapping the content of lib as an +// example, do not change the content of the file. +// +// To build the Wasm target explicitly, use: +// cargo build --example $PACKAGE_NAME