Merge pull request #15344 from bruvzg/osx_dylib_export
[GDnative] macOS `dylib` export fixes
This commit is contained in:
commit
51709cd8c8
3 changed files with 47 additions and 2 deletions
|
@ -358,6 +358,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
|
|||
err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/MacOS");
|
||||
}
|
||||
|
||||
if (err == OK) {
|
||||
print_line("Creating " + tmp_app_path_name + "/Contents/Frameworks");
|
||||
err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Frameworks");
|
||||
}
|
||||
|
||||
if (err == OK) {
|
||||
print_line("Creating " + tmp_app_path_name + "/Contents/Resources");
|
||||
err = tmp_app_path->make_dir_recursive(tmp_app_path_name + "/Contents/Resources");
|
||||
|
@ -502,10 +507,23 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
|
|||
|
||||
if (use_dmg()) {
|
||||
String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
|
||||
err = save_pack(p_preset, pack_path);
|
||||
Vector<SharedObject> shared_objects;
|
||||
Error err = save_pack(p_preset, pack_path, &shared_objects);
|
||||
|
||||
// see if we can code sign our new package
|
||||
String identity = p_preset->get("codesign/identity");
|
||||
|
||||
if (err == OK) {
|
||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
for (int i = 0; i < shared_objects.size(); i++) {
|
||||
da->copy(shared_objects[i].path, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
|
||||
if (err == OK && identity != "") {
|
||||
err = _code_sign(p_preset, tmp_app_path_name + "/Contents/Frameworks/" + shared_objects[i].path.get_file());
|
||||
}
|
||||
}
|
||||
memdelete(da);
|
||||
}
|
||||
|
||||
if (err == OK && identity != "") {
|
||||
ep.step("Code signing bundle", 2);
|
||||
|
||||
|
@ -582,7 +600,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
|
|||
ERR_CONTINUE(file.empty());
|
||||
|
||||
zipOpenNewFileInZip(dst_pkg_zip,
|
||||
(pkg_name + ".app/Contents/MacOS/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(),
|
||||
(pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(),
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
|
|
|
@ -139,6 +139,8 @@ public:
|
|||
|
||||
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
|
||||
|
||||
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
|
||||
|
||||
virtual void set_cursor_shape(CursorShape p_shape);
|
||||
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "servers/visual/visual_server_raster.h"
|
||||
#include "version_generated.gen.h"
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
|
@ -49,6 +51,7 @@
|
|||
#include <os/log.h>
|
||||
#endif
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <libproc.h>
|
||||
#include <stdio.h>
|
||||
|
@ -1262,6 +1265,28 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) {
|
|||
[window release];
|
||||
}
|
||||
|
||||
Error OS_OSX::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
|
||||
|
||||
String path = 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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW);
|
||||
if (!p_library_handle) {
|
||||
ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
|
||||
ERR_FAIL_V(ERR_CANT_OPEN);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
void OS_OSX::set_cursor_shape(CursorShape p_shape) {
|
||||
|
||||
if (cursor_shape == p_shape)
|
||||
|
|
Loading…
Reference in a new issue