Skip to content

Commit

Permalink
Add WASM/JS support via wasm-bindgen
Browse files Browse the repository at this point in the history
Fixes #32
  • Loading branch information
sdroege committed Sep 27, 2020
1 parent 0c772d3 commit fb81be5
Show file tree
Hide file tree
Showing 3 changed files with 463 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ readme = "README.md"
bitflags = "1.0"
smallvec = "1.0"

[target.'cfg(target_arch="wasm32")'.dependencies]
wasm-bindgen = { version = "0.2", optional = true }
js-sys = { version = "0.3", optional = true }

[build-dependencies]
cc = { version = "1.0", optional = true }

Expand All @@ -32,9 +36,12 @@ internal-tests = []
c-tests = ["cc", "internal-tests"] # and ebur128-c, quickcheck, quickcheck_macros, rand but dev-dependencies can't be optional...
reference-tests = []
capi = []
wasm = ["wasm-bindgen", "js-sys"]

[lib]
name = "ebur128"
# Needed for wasm-bindgen...
crate-type = ["cdylib", "rlib"]

[package.metadata.capi]
min_version = "0.6.12"
Expand All @@ -53,6 +60,10 @@ version = "1.2.4"
name = "ebur128"
version = "1.2.4"

[package.metadata.wasm-pack.profile.release]
# See https://github.com/rustwasm/wasm-pack/issues/886
wasm-opt = ["-Oz", "--enable-mutable-globals"]

[[bench]]
name = "interp"
harness = false
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ pub mod tests {
#[cfg(feature = "capi")]
#[allow(clippy::missing_safety_doc)]
pub mod capi;

#[cfg(all(feature = "wasm", target_arch = "wasm32"))]
pub mod wasm;
Loading

0 comments on commit fb81be5

Please sign in to comment.