Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ fn main() {

The linker may warn that a couple of these were ignored because nothing imports from them. That's expected: those are bridges for backends that only exist on other platforms.

On macOS and iOS, cargo links the system frameworks a static build needs. If you build a Rust `staticlib` and link it from Xcode, cargo isn't doing the final link, so add them to your Xcode target yourself: Foundation, AVFoundation, AppKit, IOKit, and CoreFoundation on macOS, or Foundation, AVFoundation, and UIKit on iOS.

## Custom backends

You can write a backend in Rust and register it alongside prism's own. Implement `CustomBackend`, declare the operations you implemented, and freeze a registry:
Expand Down
24 changes: 24 additions & 0 deletions crates/prism-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ use cmake::Config;
/// otherwise it failed with unresolved UI Automation, RPC and Windows Runtime symbols.
const WINDOWS_SYSTEM_LIBS: &[&str] = &["ole32", "onecore", "runtimeobject", "uiautomationcore", "rpcrt4", "powrprof"];

/// The frameworks prism links itself on macOS, in `PrismPlatformApple.cmake`.
///
/// `IOKit` and `CoreFoundation` are for the power notifier, which is always linked, so a static
/// binary fails to link without them even before any backend is used.
const MACOS_FRAMEWORKS: &[&str] = &["Foundation", "AVFoundation", "AppKit", "IOKit", "CoreFoundation"];

/// The frameworks prism links itself on iOS, in `PrismPlatformApple.cmake`.
const IOS_FRAMEWORKS: &[&str] = &["Foundation", "AVFoundation", "UIKit"];

fn main() {
println!("cargo:rerun-if-env-changed=PRISM_LIB_DIR");
let static_link = env::var("CARGO_FEATURE_STATIC").is_ok();
Expand All @@ -24,6 +33,21 @@ fn main() {
if static_link {
link_cpp_runtime();
link_windows_import_libs();
link_apple_frameworks();
}
}

/// Links the frameworks the Apple backends and power notifier use.
///
/// A shared prism links these itself; a static one leaves them to the final link.
fn link_apple_frameworks() {
let frameworks = match env::var("CARGO_CFG_TARGET_OS").as_deref() {
Ok("macos") => MACOS_FRAMEWORKS,
Ok("ios") => IOS_FRAMEWORKS,
_ => return,
};
for framework in frameworks {
println!("cargo:rustc-link-lib=framework={framework}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/prism-sys/prism
Submodule prism updated 54 files
+3 −2 .clang-tidy
+1 −1 .github/workflows/build-tvos.yml
+1 −1 .github/workflows/build-visionos.yml
+1 −1 .github/workflows/build-watchos.yml
+2 −0 README.md
+1 −2 build.gradle
+33 −14 cmake/PrismBackends.cmake
+1 −0 cmake/PrismLinting.cmake
+8 −1 cmake/PrismPlatformWindows.cmake
+1 −1 cmake/backend_anchors.h.in
+16 −1 defs/prism_speech_dispatcher_bridge.def
+16 −1 defs/prism_speech_dispatcher_bridge32.def
+23 −0 defs/prism_spiel_bridge.def
+23 −0 defs/prism_spiel_bridge32.def
+1 −0 doc/src/SUMMARY.md
+1 −1 doc/src/api/backend-identifiers.md
+10 −14 doc/src/api/backend-notes.md
+146 −0 doc/src/wine-bridges.md
+1 −1 include/prism.h
+2 −0 include/prism_version.h.in
+3 −2 source/backend.h
+26 −20 source/backend_catalog.h
+4 −4 source/backend_enumerator.h
+2 −2 source/backends/android/TextChunker.java
+11 −5 source/backends/android_screen_reader.cpp
+11 −5 source/backends/android_tts.cpp
+1 −1 source/backends/onecore.cpp
+48 −11 source/backends/raw/prism_speech_dispatcher_bridge.h
+63 −0 source/backends/raw/prism_spiel_bridge.h
+34 −0 source/backends/raw/prism_winelib_status.h
+43 −16 source/backends/sapi.cpp
+149 −55 source/backends/speech_dispatcher.cpp
+241 −19 source/backends/spiel.cpp
+458 −393 source/delayimp.cpp
+4 −3 source/frozen_registry.h
+13 −8 source/logging.cpp
+16 −12 source/logging.h
+4 −5 source/plugin_loader.cpp
+11 −11 source/poll_waiter.cpp
+2 −1 source/poll_waiter.h
+33 −7 source/prism.cpp
+73 −0 source/winelib_bridge.h
+0 −10 winelibs/.clang-tidy
+6 −0 winelibs/CMakeLists.txt
+34 −0 winelibs/cmake/PrismWinelib.cmake
+0 −16 winelibs/orca/CMakeLists.txt
+2 −2 winelibs/orca/bridge.c
+389 −72 winelibs/speechd/bridge.cpp
+48 −11 winelibs/speechd/bridge.h
+17 −2 winelibs/speechd/exports.spec
+12 −0 winelibs/spiel/CMakeLists.txt
+570 −0 winelibs/spiel/bridge.cpp
+68 −0 winelibs/spiel/bridge.h
+21 −0 winelibs/spiel/exports.spec