mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Merge pull request #112784 from migueldeicaza/fix_dynamic_xcframework_loading
iOS: Fix loading of xcframework dynamic libraries.
This commit is contained in:
commit
eafc21fb05
3 changed files with 20 additions and 7 deletions
|
|
@ -195,9 +195,13 @@ Error GDExtensionLibraryLoader::open_library(const String &p_path) {
|
|||
&abs_dependencies_paths, // library_dependencies
|
||||
};
|
||||
|
||||
err = OS::get_singleton()->open_dynamic_library(is_static_library ? String() : abs_path, library, &data);
|
||||
// Apple has a complex lookup system which goes beyond looking up the filename, so we try that first.
|
||||
err = OS::get_singleton()->open_dynamic_library(abs_path, library, &data);
|
||||
if (err != OK) {
|
||||
return err;
|
||||
err = OS::get_singleton()->open_dynamic_library(String(), library, &data);
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
|
@ -361,8 +365,6 @@ Error GDExtensionLibraryLoader::parse_gdextension_file(const String &p_path) {
|
|||
return ERR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
is_static_library = library_path.ends_with(".a") || library_path.ends_with(".xcframework");
|
||||
|
||||
if (!library_path.is_resource_file() && !library_path.is_absolute_path()) {
|
||||
library_path = p_path.get_base_dir().path_join(library_path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ private:
|
|||
String library_path;
|
||||
String entry_symbol;
|
||||
|
||||
bool is_static_library = false;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
bool is_reloadable = false;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -279,6 +279,11 @@ Error OS_AppleEmbedded::open_dynamic_library(const String &p_path, void *&p_libr
|
|||
path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file().get_basename() + ".framework"));
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(path)) {
|
||||
// Load .dylib from within the executable path.
|
||||
path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file().get_basename() + ".dylib"));
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(path)) {
|
||||
// Load .dylib or framework from a standard iOS location.
|
||||
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file()));
|
||||
|
|
@ -289,8 +294,16 @@ Error OS_AppleEmbedded::open_dynamic_library(const String &p_path, void *&p_libr
|
|||
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file().get_basename() + ".framework"));
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(!FileAccess::exists(path), ERR_FILE_NOT_FOUND);
|
||||
if (!FileAccess::exists(path)) {
|
||||
// Load .dylib from a standard iOS location.
|
||||
path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file().get_basename() + ".dylib"));
|
||||
}
|
||||
|
||||
if (!FileAccess::exists(path) && (p_path.ends_with(".a") || p_path.ends_with(".xcframework"))) {
|
||||
path = String(); // Try loading static library.
|
||||
} else {
|
||||
ERR_FAIL_COND_V(!FileAccess::exists(path), ERR_FILE_NOT_FOUND);
|
||||
}
|
||||
p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
|
||||
ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror()));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue