From 702667ff8c83b4427ba52bdbda0eb9778ab1cfbc Mon Sep 17 00:00:00 2001 From: Yureka Date: Fri, 17 Sep 2021 18:05:37 +0200 Subject: [PATCH 1/4] use stub for anything not unix and not windows --- src/sys/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; From 09ac33884ec9f79ac215f1b07ad7b5ba28b62966 Mon Sep 17 00:00:00 2001 From: Yureka Date: Fri, 17 Sep 2021 18:10:29 +0200 Subject: [PATCH 2/4] add wasm32-unknown-emscripten test --- .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ ci/github.sh | 6 ++++++ 2 files changed, 34 insertions(+) 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/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 "$@" From 9ac4e7bca57ebf49a4e01a2241ff7db826a8cf9c Mon Sep 17 00:00:00 2001 From: Yureka Date: Fri, 17 Sep 2021 18:28:47 +0200 Subject: [PATCH 3/4] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 51aa03e33dcd9c86ce66ad73036c5cc39edd4439 Mon Sep 17 00:00:00 2001 From: Yureka Date: Sat, 9 Apr 2022 10:21:15 +0200 Subject: [PATCH 4/4] some lint errors from the 1.60 upgrade --- src/offset/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) 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)) }