diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-10-01 15:24:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 15:24:52 +0200 |
commit | 928c002f223b67bd6fd1c55d65e37a6d5c4e3a94 (patch) | |
tree | 9b0ea4d9718fe694b2b22d9e09a66b32db8c2cb9 /platform | |
parent | 06c1b40b84645b4460dd49d95694a7779d636f92 (diff) | |
parent | 0c0b5c84b06e64de6cab301994ac9cd1f845dd35 (diff) |
Merge pull request #52192 from bruvzg/text_server_gdext
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/os_osx.mm | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 6ef1bdbd11..e9cb46ed21 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -314,17 +314,27 @@ String OS_OSX::get_name() const { return "macOS"; } +_FORCE_INLINE_ String _get_framework_executable(const String p_path) { + // Append framework executable name, or return as is if p_path is not a framework. + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + if (da->dir_exists(p_path) && da->file_exists(p_path.plus_file(p_path.get_file().get_basename()))) { + return p_path.plus_file(p_path.get_file().get_basename()); + } else { + return p_path; + } +} + Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { - String path = p_path; + String path = _get_framework_executable(p_path); if (!FileAccess::exists(path)) { - //this code exists so gdnative can load .dylib files from within the executable path - path = get_executable_path().get_base_dir().plus_file(p_path.get_file()); + // This code exists so gdnative can load .dylib files from within the executable path. + path = _get_framework_executable(get_executable_path().get_base_dir().plus_file(p_path.get_file())); } if (!FileAccess::exists(path)) { - //this code exists so gdnative can load .dylib files from a standard macOS location - path = get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file()); + // This code exists so gdnative can load .dylib files from a standard macOS location. + path = _get_framework_executable(get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(p_path.get_file())); } p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); |