Skip to content
Merged
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
28 changes: 21 additions & 7 deletions sudachi/src/plugin/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,32 @@ struct PluginLoader<'a, 'b, T: PluginCategory + ?Sized> {
}

#[cfg(any(target_os = "linux", target_os = "freebsd"))]
fn make_system_specific_name(s: &str) -> String {
format!("lib{}.so", s)
fn make_system_specific_name(s: &str) -> Option<String> {
Some(format!("lib{}.so", s))
}

#[cfg(target_os = "windows")]
fn make_system_specific_name(s: &str) -> String {
format!("{}.dll", s)
fn make_system_specific_name(s: &str) -> Option<String> {
Some(format!("{}.dll", s))
}

#[cfg(target_os = "macos")]
fn make_system_specific_name(s: &str) -> String {
format!("lib{}.dylib", s)
fn make_system_specific_name(s: &str) -> Option<String> {
Some(format!("lib{}.dylib", s))
}

#[cfg(any(
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
))]
// Apple embedded platforms do not support dynamic library loading (DSO plugins)
// due to platform security restrictions. Returning None here
// effectively disables loading plugins from DSOs, while still allowing
// plugins bundled with the application/binary to work as expected.
fn make_system_specific_name(_s: &str) -> Option<String> {
None
}

fn system_specific_name(s: &str) -> Option<String> {
Expand All @@ -75,7 +89,7 @@ fn system_specific_name(s: &str) -> Option<String> {
let fname = p
.file_name()
.and_then(|np| np.to_str())
.map(make_system_specific_name);
.and_then(make_system_specific_name);
let parent = p.parent().and_then(|np| np.to_str());
match (parent, fname) {
(Some(p), Some(c)) => Some(format!("{}/{}", p, c)),
Expand Down