mirror of
https://github.com/mupen64plus/mupen64plus-ui-console.git
synced 2025-04-02 10:52:34 -04:00
on macOS systems, use corefoundation framework to get the absolute path to the frameworks folder in the bundle, and look for the core library and plugins there
This commit is contained in:
parent
78d3d6c955
commit
a105ae0c6f
3 changed files with 54 additions and 2 deletions
|
@ -76,8 +76,10 @@ ifeq ($(OS), MINGW)
|
|||
CFLAGS += -lpthread
|
||||
LDLIBS += -lpthread
|
||||
else
|
||||
CFLAGS += -pthread
|
||||
LDLIBS += -pthread
|
||||
ifneq ($(OS), OSX)
|
||||
CFLAGS += -pthread
|
||||
LDLIBS += -pthread
|
||||
endif
|
||||
endif
|
||||
|
||||
# set special flags per-system
|
||||
|
@ -86,6 +88,7 @@ ifeq ($(OS), LINUX)
|
|||
endif
|
||||
ifeq ($(OS), OSX)
|
||||
OSX_SDK_PATH = $(shell xcrun --sdk macosx --show-sdk-path)
|
||||
LDLIBS += -framework CoreFoundation
|
||||
|
||||
ifeq ($(CPU), X86)
|
||||
ifeq ($(ARCH_DETECTED), 64BITS)
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
* library and pointers to the core functions
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "core_interface.h"
|
||||
|
@ -130,6 +134,24 @@ m64p_error AttachCoreLib(const char *CoreLibFilepath)
|
|||
{
|
||||
rval = osal_dynlib_open(&CoreHandle, COREDIR OSAL_DEFAULT_DYNLIB_FILENAME);
|
||||
}
|
||||
#endif
|
||||
/* for MacOS, look for the library in the Frameworks folder of the app bundle */
|
||||
#if defined(__APPLE__)
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
if (mainBundle != NULL)
|
||||
{
|
||||
CFURLRef frameworksURL = CFBundleCopyPrivateFrameworksURL(mainBundle);
|
||||
if (frameworksURL != NULL)
|
||||
{
|
||||
char libPath[1024 + 32];
|
||||
if (CFURLGetFileSystemRepresentation(frameworksURL, TRUE, (uint8_t *) libPath, 1024))
|
||||
{
|
||||
strcat(libPath, "/" OSAL_DEFAULT_DYNLIB_FILENAME);
|
||||
rval = osal_dynlib_open(&CoreHandle, libPath);
|
||||
}
|
||||
CFRelease(frameworksURL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* then try just the filename of the shared library, to let dlopen() look through the system lib dirs */
|
||||
if (rval != M64ERR_SUCCESS || CoreHandle == NULL)
|
||||
|
|
27
src/plugin.c
27
src/plugin.c
|
@ -23,6 +23,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
#include "core_interface.h"
|
||||
#include "m64p_common.h"
|
||||
#include "m64p_types.h"
|
||||
|
@ -124,6 +128,29 @@ m64p_error PluginSearchLoad(m64p_handle ConfigUI)
|
|||
lib_filelist = osal_library_search(plugindir);
|
||||
}
|
||||
|
||||
/* for MacOS, look for plugins in the Frameworks folder of the app bundle */
|
||||
#if defined(__APPLE__)
|
||||
if (lib_filelist == NULL)
|
||||
{
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
if (mainBundle != NULL)
|
||||
{
|
||||
CFURLRef frameworksURL = CFBundleCopyPrivateFrameworksURL(mainBundle);
|
||||
if (frameworksURL != NULL)
|
||||
{
|
||||
char libPath[1024];
|
||||
if (CFURLGetFileSystemRepresentation(frameworksURL, TRUE, (uint8_t *) libPath, 1024))
|
||||
{
|
||||
strcat(libPath, "/");
|
||||
DebugMessage(M64MSG_INFO, "Searching for plugins at: %s", libPath);
|
||||
lib_filelist = osal_library_search(libPath);
|
||||
}
|
||||
CFRelease(frameworksURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if still no plugins found, search some common system folders */
|
||||
if (lib_filelist == NULL)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue