From 92538fbdb869eeb29d8114f8e7338bb662308679 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 1 Nov 2021 10:36:15 -0500 Subject: [PATCH] Upgrade windows-rs to 0.23. --- Cargo.toml | 14 ++++++++++---- build.rs | 10 ---------- src/backends/{winrt/mod.rs => winrt.rs} | 9 +++------ src/backends/winrt/bindings.rs | 1 - src/lib.rs | 2 +- 5 files changed, 14 insertions(+), 22 deletions(-) rename src/backends/{winrt/mod.rs => winrt.rs} (98%) delete mode 100644 src/backends/winrt/bindings.rs diff --git a/Cargo.toml b/Cargo.toml index fcf5bfd..1b52894 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,12 +20,18 @@ thiserror = "1" [dev-dependencies] env_logger = "0.8" +[dependencies.windows] +version = "0.23" +features = [ + "Foundation", + "Media_Core", + "Media_Playback", + "Media_SpeechSynthesis", + "Storage_Streams", +] + [target.'cfg(windows)'.dependencies] tolk = { version = "0.5", optional = true } -windows = "0.9" - -[target.'cfg(windows)'.build-dependencies] -windows = "0.9" [target.'cfg(target_os = "linux")'.dependencies] speech-dispatcher = "0.7" diff --git a/build.rs b/build.rs index e2e2035..8b1edc2 100644 --- a/build.rs +++ b/build.rs @@ -1,14 +1,4 @@ fn main() { - #[cfg(windows)] - if std::env::var("TARGET").unwrap().contains("windows") { - windows::build!( - Windows::Foundation::{EventRegistrationToken, IAsyncOperation, TypedEventHandler}, - Windows::Media::Core::MediaSource, - Windows::Media::Playback::{MediaPlaybackSession, MediaPlaybackState, MediaPlayer, MediaPlayerAudioCategory}, - Windows::Media::SpeechSynthesis::{SpeechSynthesisStream, SpeechSynthesizer, SpeechSynthesizerOptions}, - Windows::Storage::Streams::IRandomAccessStream, - ); - } if std::env::var("TARGET").unwrap().contains("-apple") { println!("cargo:rustc-link-lib=framework=AVFoundation"); if !std::env::var("CARGO_CFG_TARGET_OS") diff --git a/src/backends/winrt/mod.rs b/src/backends/winrt.rs similarity index 98% rename from src/backends/winrt/mod.rs rename to src/backends/winrt.rs index af9ca34..00ccc51 100644 --- a/src/backends/winrt/mod.rs +++ b/src/backends/winrt.rs @@ -4,10 +4,7 @@ use std::sync::Mutex; use lazy_static::lazy_static; use log::{info, trace}; - -mod bindings; - -use bindings::Windows::{ +use windows::{ Foundation::TypedEventHandler, Media::{ Core::MediaSource, @@ -18,8 +15,8 @@ use bindings::Windows::{ use crate::{Backend, BackendId, Error, Features, UtteranceId, CALLBACKS}; -impl From for Error { - fn from(e: windows::Error) -> Self { +impl From for Error { + fn from(e: windows::runtime::Error) -> Self { Error::WinRt(e) } } diff --git a/src/backends/winrt/bindings.rs b/src/backends/winrt/bindings.rs deleted file mode 100644 index 7915760..0000000 --- a/src/backends/winrt/bindings.rs +++ /dev/null @@ -1 +0,0 @@ -::windows::include_bindings!(); diff --git a/src/lib.rs b/src/lib.rs index d62c245..f91ceac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -117,7 +117,7 @@ pub enum Error { JavaScriptError(wasm_bindgen::JsValue), #[cfg(windows)] #[error("WinRT error")] - WinRt(windows::Error), + WinRt(windows::runtime::Error), #[error("Unsupported feature")] UnsupportedFeature, #[error("Out of range")]