diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 710ad46526..b32c9f47f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -121,6 +121,34 @@ jobs: RUST_VERSION: stable WASM: wasm_simple + wasm_emscripten: + strategy: + matrix: + os: [macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: wasm32-unknown-emscripten + override: true + + - name: Install node + uses: actions/setup-node@v1 + with: + node-version: '12' + + - name: Build and Test + run: bash ci/github.sh + env: + RUST_VERSION: stable + WASM: wasm_emscripten + cross-targets: strategy: matrix: diff --git a/CHANGELOG.md b/CHANGELOG.md index 92590cd39b..8c07750da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Versions with only mechanical changes will be omitted from the following list. * Add optional rkyv support. * Add support for microseconds timestamps serde serialization for `NaiveDateTime`. * Add support for optional timestamps serde serialization for `NaiveDateTime`. +* Fix build for wasm32-unknown-emscripten (@yu-re-ka #593) ## 0.4.19 diff --git a/ci/github.sh b/ci/github.sh index 207cb08a04..081a128b90 100755 --- a/ci/github.sh +++ b/ci/github.sh @@ -34,6 +34,8 @@ meaningful in the github actions feature matrix UI. test_wasm elif [[ ${WASM:-} == wasm_simple ]]; then test_wasm_simple + elif [[ ${WASM:-} == wasm_emscripten ]]; then + test_wasm_emscripten elif [[ ${CORE:-} == no_std ]]; then test_core elif [[ ${EXHAUSTIVE_TZ:-} == all_tzs ]]; then @@ -112,4 +114,8 @@ test_wasm_simple() { fi } +test_wasm_emscripten() { + runt cargo build --target wasm32-unknown-emscripten +} + main "$@" diff --git a/src/offset/mod.rs b/src/offset/mod.rs index cc04bc568e..237b5505f1 100644 --- a/src/offset/mod.rs +++ b/src/offset/mod.rs @@ -430,6 +430,7 @@ pub trait TimeZone: Sized + Clone { fn offset_from_local_datetime(&self, local: &NaiveDateTime) -> LocalResult; /// Converts the local `NaiveDate` to the timezone-aware `Date` if possible. + #[allow(clippy::wrong_self_convention)] fn from_local_date(&self, local: &NaiveDate) -> LocalResult> { self.offset_from_local_date(local).map(|offset| { // since FixedOffset is within +/- 1 day, the date is never affected @@ -438,6 +439,7 @@ pub trait TimeZone: Sized + Clone { } /// Converts the local `NaiveDateTime` to the timezone-aware `DateTime` if possible. + #[allow(clippy::wrong_self_convention)] fn from_local_datetime(&self, local: &NaiveDateTime) -> LocalResult> { self.offset_from_local_datetime(local) .map(|offset| DateTime::from_utc(*local - offset.fix(), offset)) @@ -451,12 +453,14 @@ pub trait TimeZone: Sized + Clone { /// Converts the UTC `NaiveDate` to the local time. /// The UTC is continuous and thus this cannot fail (but can give the duplicate local time). + #[allow(clippy::wrong_self_convention)] fn from_utc_date(&self, utc: &NaiveDate) -> Date { Date::from_utc(*utc, self.offset_from_utc_date(utc)) } /// Converts the UTC `NaiveDateTime` to the local time. /// The UTC is continuous and thus this cannot fail (but can give the duplicate local time). + #[allow(clippy::wrong_self_convention)] fn from_utc_datetime(&self, utc: &NaiveDateTime) -> DateTime { DateTime::from_utc(*utc, self.offset_from_utc_datetime(utc)) } diff --git a/src/sys/mod.rs b/src/sys/mod.rs index 2dc3453625..25fd87a5ca 100644 --- a/src/sys/mod.rs +++ b/src/sys/mod.rs @@ -16,15 +16,15 @@ use std::time::{SystemTime, UNIX_EPOCH}; -#[cfg(any(target_arch = "wasm32", target_env = "sgx"))] +#[cfg(all(not(unix), not(windows)))] #[path = "stub.rs"] mod inner; -#[cfg(all(unix, not(target_arch = "wasm32"), not(target_env = "sgx")))] +#[cfg(unix)] #[path = "unix.rs"] mod inner; -#[cfg(all(windows, not(target_arch = "wasm32"), not(target_env = "sgx")))] +#[cfg(windows)] #[path = "windows.rs"] mod inner;