From c21d4a6a38de84048124e8768f9c63b20cf7d3bd Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 11 Mar 2021 13:21:41 -0600 Subject: [PATCH] Eliminate separate winrt_bindings crate since it no longer seems necessary for fast builds. --- Cargo.toml | 4 +++- build.rs | 10 +++++++++- .../src/lib.rs => src/backends/winrt/bindings.rs | 2 +- src/backends/{winrt.rs => winrt/mod.rs} | 13 +++++++++---- winrt_bindings/Cargo.toml | 13 ------------- winrt_bindings/build.rs | 9 --------- 6 files changed, 22 insertions(+), 29 deletions(-) rename winrt_bindings/src/lib.rs => src/backends/winrt/bindings.rs (96%) rename src/backends/{winrt.rs => winrt/mod.rs} (97%) delete mode 100644 winrt_bindings/Cargo.toml delete mode 100644 winrt_bindings/build.rs diff --git a/Cargo.toml b/Cargo.toml index 8325028..3502664 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,9 @@ env_logger = "0.8" [target.'cfg(windows)'.dependencies] tolk = { version = "0.3", optional = true } windows = "0.4" -tts_winrt_bindings = { version = "0.3", path="winrt_bindings" } + +[target.'cfg(windows)'.build-dependencies] +windows = "0.4" [target.'cfg(target_os = "linux")'.dependencies] speech-dispatcher = "0.7" diff --git a/build.rs b/build.rs index 8b1edc2..6df6312 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,13 @@ fn main() { - if std::env::var("TARGET").unwrap().contains("-apple") { + 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::speech_synthesis::{SpeechSynthesisStream, SpeechSynthesizer, SpeechSynthesizerOptions}, + windows::storage::streams::IRandomAccessStream, + ); + } else if std::env::var("TARGET").unwrap().contains("-apple") { println!("cargo:rustc-link-lib=framework=AVFoundation"); if !std::env::var("CARGO_CFG_TARGET_OS") .unwrap() diff --git a/winrt_bindings/src/lib.rs b/src/backends/winrt/bindings.rs similarity index 96% rename from winrt_bindings/src/lib.rs rename to src/backends/winrt/bindings.rs index 42af6ba..7915760 100644 --- a/winrt_bindings/src/lib.rs +++ b/src/backends/winrt/bindings.rs @@ -1 +1 @@ -::windows::include_bindings!(); +::windows::include_bindings!(); diff --git a/src/backends/winrt.rs b/src/backends/winrt/mod.rs similarity index 97% rename from src/backends/winrt.rs rename to src/backends/winrt/mod.rs index d9b7704..5aec81d 100644 --- a/src/backends/winrt.rs +++ b/src/backends/winrt/mod.rs @@ -5,11 +5,16 @@ use std::sync::Mutex; use lazy_static::lazy_static; use log::{info, trace}; -use tts_winrt_bindings::windows::media::playback::{ - MediaPlaybackState, MediaPlayer, MediaPlayerAudioCategory, +mod bindings; + +use bindings::windows::{ + foundation::TypedEventHandler, + media::{ + core::MediaSource, + playback::{MediaPlaybackState, MediaPlayer, MediaPlayerAudioCategory}, + speech_synthesis::SpeechSynthesizer, + }, }; -use tts_winrt_bindings::windows::media::speech_synthesis::SpeechSynthesizer; -use tts_winrt_bindings::windows::{foundation::TypedEventHandler, media::core::MediaSource}; use crate::{Backend, BackendId, Error, Features, UtteranceId, CALLBACKS}; diff --git a/winrt_bindings/Cargo.toml b/winrt_bindings/Cargo.toml deleted file mode 100644 index da14f55..0000000 --- a/winrt_bindings/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "tts_winrt_bindings" -version = "0.3.0" -authors = ["Nolan Darilek "] -description = "Internal crate used by `tts`" -license = "MIT" -edition = "2018" - -[dependencies] -windows = "0.4" - -[build-dependencies] -windows = "0.4" diff --git a/winrt_bindings/build.rs b/winrt_bindings/build.rs deleted file mode 100644 index 3080588..0000000 --- a/winrt_bindings/build.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - windows::build!( - windows::foundation::{EventRegistrationToken, IAsyncOperation, TypedEventHandler}, - windows::media::core::MediaSource, - windows::media::playback::{MediaPlaybackSession, MediaPlaybackState, MediaPlayer, MediaPlayerAudioCategory}, - windows::media::speech_synthesis::{SpeechSynthesisStream, SpeechSynthesizer, SpeechSynthesizerOptions}, - windows::storage::streams::IRandomAccessStream, - ); -}