From c5973277e795f00504acf781e76ea4d0d3a61441 Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Tue, 26 Nov 2019 23:57:51 -0600 Subject: [PATCH] Don't do wasmbind on wasi --- Cargo.toml | 4 ++-- src/lib.rs | 4 ++-- src/offset/local.rs | 4 ++-- src/offset/utc.rs | 9 ++++++--- tests/wasm.rs | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9c59752..0c23f23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ num-traits = { version = "0.2", default-features = false } rustc-serialize = { version = "0.3.20", optional = true } serde = { version = "1.0.99", default-features = false, optional = true } -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] +[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dependencies] wasm-bindgen = { version = "0.2", optional = true } js-sys = { version = "0.3", optional = true } # contains FFI bindings for the JS Date API @@ -49,7 +49,7 @@ bincode = { version = "0.8.0" } num-iter = { version = "0.1.35", default-features = false } doc-comment = "0.3" -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dev-dependencies] +[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dev-dependencies] wasm-bindgen-test = "0.2" [package.metadata.docs.rs] diff --git a/src/lib.rs b/src/lib.rs index ef76a7f..f8aba3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -424,9 +424,9 @@ extern crate serde as serdelib; #[cfg(test)] #[macro_use] extern crate doc_comment; -#[cfg(all(target_arch = "wasm32", feature="wasmbind"))] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))] extern crate wasm_bindgen; -#[cfg(all(target_arch = "wasm32", feature="wasmbind"))] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))] extern crate js_sys; #[cfg(feature = "bench")] extern crate test; diff --git a/src/offset/local.rs b/src/offset/local.rs index 70c01e6..a3ba034 100644 --- a/src/offset/local.rs +++ b/src/offset/local.rs @@ -87,13 +87,13 @@ impl Local { } /// Returns a `DateTime` which corresponds to the current date. - #[cfg(not(all(target_arch = "wasm32", feature = "wasmbind")))] + #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))] pub fn now() -> DateTime { tm_to_datetime(oldtime::now()) } /// Returns a `DateTime` which corresponds to the current date. - #[cfg(all(target_arch = "wasm32", feature = "wasmbind"))] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))] pub fn now() -> DateTime { use super::Utc; let now: DateTime = super::Utc::now(); diff --git a/src/offset/utc.rs b/src/offset/utc.rs index da8de11..3862fa6 100644 --- a/src/offset/utc.rs +++ b/src/offset/utc.rs @@ -4,7 +4,10 @@ //! The UTC (Coordinated Universal Time) time zone. use core::fmt; -#[cfg(all(feature="clock", not(all(target_arch = "wasm32", feature = "wasmbind"))))] +#[cfg(all( + feature = "clock", + not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")) +))] use oldtime; use naive::{NaiveDate, NaiveDateTime}; @@ -38,7 +41,7 @@ impl Utc { pub fn today() -> Date { Utc::now().date() } /// Returns a `DateTime` which corresponds to the current date. - #[cfg(not(all(target_arch = "wasm32", feature = "wasmbind")))] + #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))] pub fn now() -> DateTime { let spec = oldtime::get_time(); let naive = NaiveDateTime::from_timestamp(spec.sec, spec.nsec as u32); @@ -46,7 +49,7 @@ impl Utc { } /// Returns a `DateTime` which corresponds to the current date. - #[cfg(all(target_arch = "wasm32", feature = "wasmbind"))] + #[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))] pub fn now() -> DateTime { let now = js_sys::Date::new_0(); let millisecs_since_unix_epoch: u64 = now.get_time() as u64; diff --git a/tests/wasm.rs b/tests/wasm.rs index 48ac8db..908a4d3 100644 --- a/tests/wasm.rs +++ b/tests/wasm.rs @@ -1,4 +1,4 @@ -#[cfg(all(target_arch = "wasm32", feature = "wasmbind"))] +#[cfg(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))] mod test { extern crate chrono; extern crate wasm_bindgen_test;