Skip to content

Commit

Permalink
Allow the library name to be specified without prefix/extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
samdeane committed Oct 11, 2024
1 parent b4cbc21 commit 5bde41b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions platform/macos/os_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,23 @@
return p_path.path_join(p_path.get_file().get_basename());
}

// If we've got no extension, try a couple
// of common patterns: lib<name>.dylib and <name>.framework.
if (p_path.get_extension().is_empty()) {
// Try adding .dylib extension.
String dylib_path = p_path.get_base_dir().path_join("lib" + p_path.get_file().get_basename() + ".dylib");
OS::get_singleton()->print("trying %s\n", dylib_path.utf8().get_data());
if (da->file_exists(dylib_path)) {
return dylib_path;
}
// Try adding .framework extension.
String framework_path = p_path + ".framework";
OS::get_singleton()->print("trying %s\n", framework_path.utf8().get_data());
if (da->dir_exists(framework_path)) {
return framework_path;
}
}

// Not a framework, try loading as .dylib.
return p_path;
}
Expand Down

0 comments on commit 5bde41b

Please sign in to comment.