Skip to content

Commit

Permalink
Add comments on crate-type switch
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Nov 13, 2024
1 parent 72133a5 commit 5e81c30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
11 changes: 11 additions & 0 deletions src/wasm_lib.rs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5e81c30

Please sign in to comment.