mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-22 23:19:37 +00:00
Set up conditional compilation for iOS.
This commit is contained in:
parent
27e9aaf034
commit
0d61dc258f
|
@ -9,8 +9,7 @@ exclude = ["*.cfg", "*.yml"]
|
|||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "tts"
|
||||
crate-type = ["staticlib", "cdylib"]
|
||||
crate-type = ["lib", "staticlib"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
|
@ -27,7 +26,7 @@ tts_winrt_bindings = { version = "0.1", path="winrt_bindings" }
|
|||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
speech-dispatcher = "0.4"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
|
||||
cocoa-foundation = "0.1"
|
||||
libc = "0.2"
|
||||
objc = "0.2"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[link(name = "AVFoundation", kind = "framework")]
|
||||
use cocoa_foundation::base::{id, nil};
|
||||
use cocoa_foundation::foundation::NSString;
|
||||
|
@ -132,7 +132,7 @@ impl Backend for AvFoundation {
|
|||
|
||||
fn is_speaking(&self) -> Result<bool, Error> {
|
||||
let is_speaking: i8 = unsafe { msg_send![self.synth, isSpeaking] };
|
||||
Ok(is_speaking == YES)
|
||||
Ok(is_speaking == 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ mod web;
|
|||
#[cfg(target_os = "macos")]
|
||||
mod appkit;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
mod av_foundation;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
@ -28,5 +28,5 @@ pub use self::web::*;
|
|||
#[cfg(target_os = "macos")]
|
||||
pub use self::appkit::*;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
pub use self::av_foundation::*;
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
* * WebAssembly
|
||||
*/
|
||||
|
||||
use std::boxed::Box;
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::{boxed::Box, ffi::CStr};
|
||||
use std::ffi::CStr;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use cocoa_foundation::base::id;
|
||||
|
@ -35,7 +36,7 @@ pub enum Backends {
|
|||
WinRT,
|
||||
#[cfg(target_os = "macos")]
|
||||
AppKit,
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
AvFoundation,
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ impl TTS {
|
|||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
Backends::AppKit => Ok(TTS(Box::new(backends::AppKit::new()))),
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
Backends::AvFoundation => Ok(TTS(Box::new(backends::AvFoundation::new()))),
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +157,8 @@ impl TTS {
|
|||
TTS::new(Backends::AppKit)
|
||||
}
|
||||
};
|
||||
#[cfg(target_os = "ios")]
|
||||
let tts = TTS::new(Backends::AvFoundation);
|
||||
tts
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user