diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index c95ecae..ca142b5 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -46,11 +46,6 @@ jobs: with: toolchain: stable - - name: Cargo Build - uses: actions-rs/cargo@v1 - with: - command: build - - name: Install wasm-pack run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh diff --git a/Cargo.lock b/Cargo.lock index 533e231..9f80713 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,6 +250,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" name = "finlib" version = "0.0.1" dependencies = [ + "getrandom 0.2.15", "log", "nalgebra", "ndarray", @@ -285,8 +286,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] diff --git a/finlib-wasm/.cargo/config.toml b/finlib-wasm/.cargo/config.toml new file mode 100644 index 0000000..81163b2 --- /dev/null +++ b/finlib-wasm/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ['--cfg=getrandom_backend="wasm_js"'] \ No newline at end of file diff --git a/finlib-wasm/Cargo.toml b/finlib-wasm/Cargo.toml index 2b8b9ed..d8c2603 100644 --- a/finlib-wasm/Cargo.toml +++ b/finlib-wasm/Cargo.toml @@ -12,7 +12,7 @@ default = ["console_error_panic_hook"] [dependencies] wasm-bindgen = "0.2.100" -finlib = { path = "../finlib" } +finlib = { path = "../finlib", features = ["wasm"] } # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires diff --git a/finlib/Cargo.toml b/finlib/Cargo.toml index 0adf369..2fd05c5 100644 --- a/finlib/Cargo.toml +++ b/finlib/Cargo.toml @@ -12,7 +12,9 @@ ndarray-stats = { workspace = true } nalgebra = { workspace = true } statrs = { workspace = true } log = { workspace = true } +getrandom = "*" [features] py = ["dep:pyo3"] +wasm = ["getrandom/js"] parallel = ["dep:rayon"] \ No newline at end of file