vst3 macos bindir & datadir in BundleEntry

This commit is contained in:
Paolo Marrone 2024-06-20 15:58:05 +02:00
parent 064820841b
commit 9dcf07147d

View File

@ -53,7 +53,7 @@ typedef struct {
#include <math.h> #include <math.h>
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
# include <windows.h> # include <windows.h>
#elif !defined(__APPLE__) #else
# include <dlfcn.h> # include <dlfcn.h>
#endif #endif
@ -136,7 +136,7 @@ static const Steinberg_TUID Steinberg_IRunLoop_iid = SMTG_INLINE_UID (0x18C35366
# endif # endif
#endif #endif
#if defined(__linux__) #if defined(__linux__) || defined(__APPLE__)
static char *x_asprintf(const char * restrict format, ...) { static char *x_asprintf(const char * restrict format, ...) {
va_list args, tmp; va_list args, tmp;
va_start(args, format); va_start(args, format);
@ -2162,34 +2162,19 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
return 1; return 1;
} }
#elif defined(__APPLE__) #elif defined(__APPLE__) || defined(__linux__)
EXPORT EXPORT
# if defined(__APPLE__)
char bundleEntry(CFBundleRef ref) { char bundleEntry(CFBundleRef ref) {
(void)ref; # else
if (refs == 0) {
//XXX
}
refs++;
return 1;
}
EXPORT
char bundleExit(void) {
return vstExit();
}
#else
EXPORT
char ModuleEntry(void *handle) { char ModuleEntry(void *handle) {
(void)handle; # endif
(void)ref;
char *file; char *file;
if (refs == 0) { if (refs == 0) {
Dl_info info; Dl_info info;
union { void *d; char (*f)(void *); } v; if (dladdr((void*) bindir, &info) == 0)
v.f = ModuleEntry;
if (dladdr(v.d, &info) == 0)
return 0; return 0;
file = realpath(info.dli_fname, NULL); file = realpath(info.dli_fname, NULL);
if (file == NULL) if (file == NULL)
@ -2205,6 +2190,7 @@ char ModuleEntry(void *handle) {
if (datadir == NULL) if (datadir == NULL)
goto err_datadir; goto err_datadir;
free(file); free(file);
TRACE("bindir = %s \ndatadir = %s\n", bindir, datadir);
} }
refs++; refs++;
return 1; return 1;
@ -2217,7 +2203,11 @@ err_bindir:
} }
EXPORT EXPORT
# if defined(__APPLE__)
char bundleExit(void) {
# else
char ModuleExit(void) { char ModuleExit(void) {
# endif
return vstExit(); return vstExit();
} }