mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
The proper extension for Mac JNI libraries is .jnilib. Hard-coded constants
have been factored to common locations. Furthermore, the LD_LIBRARY_PATH environment variable is DYLD_LIBRARY_PATH on Mac OS X.
This commit is contained in:
parent
a688a6f61a
commit
36f1d3206e
@ -6,6 +6,12 @@
|
|||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "jni-util.h"
|
#include "jni-util.h"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define SO_SUFFIX ".jnilib"
|
||||||
|
#else
|
||||||
|
#define SO_SUFFIX ".so"
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef JNIEXPORT
|
#undef JNIEXPORT
|
||||||
#define JNIEXPORT __attribute__ ((visibility("default")))
|
#define JNIEXPORT __attribute__ ((visibility("default")))
|
||||||
|
|
||||||
@ -54,9 +60,9 @@ Java_java_lang_System_doMapLibraryName(JNIEnv* e, jclass, jstring name)
|
|||||||
const char* chars = e->GetStringUTFChars(name, 0);
|
const char* chars = e->GetStringUTFChars(name, 0);
|
||||||
if (chars) {
|
if (chars) {
|
||||||
unsigned nameLength = strlen(chars);
|
unsigned nameLength = strlen(chars);
|
||||||
unsigned size = nameLength + 7;
|
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
|
||||||
char buffer[size];
|
char buffer[size];
|
||||||
snprintf(buffer, size, "lib%s.so", chars);
|
snprintf(buffer, size, "lib%s" SO_SUFFIX, chars);
|
||||||
r = e->NewStringUTF(buffer);
|
r = e->NewStringUTF(buffer);
|
||||||
|
|
||||||
e->ReleaseStringUTFChars(name, chars);
|
e->ReleaseStringUTFChars(name, chars);
|
||||||
|
6
makefile
6
makefile
@ -13,12 +13,14 @@ ifeq ($(platform),Darwin)
|
|||||||
rdynamic =
|
rdynamic =
|
||||||
thread-cflags =
|
thread-cflags =
|
||||||
shared = -dynamiclib
|
shared = -dynamiclib
|
||||||
so-extension = dylib
|
so-extension = jnilib
|
||||||
|
ld-library-path = DYLD_LIBRARY_PATH
|
||||||
else
|
else
|
||||||
rdynamic = -rdynamic
|
rdynamic = -rdynamic
|
||||||
thread-cflags = -pthread
|
thread-cflags = -pthread
|
||||||
shared = -shared
|
shared = -shared
|
||||||
so-extension = so
|
so-extension = so
|
||||||
|
ld-library-path = LD_LIBRARY_PATH
|
||||||
endif
|
endif
|
||||||
|
|
||||||
mode = debug
|
mode = debug
|
||||||
@ -154,7 +156,7 @@ $(input): $(classpath-objects)
|
|||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: $(executable) $(input)
|
run: $(executable) $(input)
|
||||||
LD_LIBRARY_PATH=$(bld) $(<) $(args)
|
$(ld-library-path)=$(bld) $(<) $(args)
|
||||||
|
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
debug: $(executable) $(input)
|
debug: $(executable) $(input)
|
||||||
|
@ -25,6 +25,12 @@
|
|||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define SO_SUFFIX ".jnilib"
|
||||||
|
#else
|
||||||
|
#define SO_SUFFIX ".so"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NO_RETURN __attribute__((noreturn))
|
#define NO_RETURN __attribute__((noreturn))
|
||||||
|
|
||||||
#define LIKELY(v) __builtin_expect((v) != 0, true)
|
#define LIKELY(v) __builtin_expect((v) != 0, true)
|
||||||
|
@ -597,15 +597,9 @@ class MySystem: public System {
|
|||||||
void* p;
|
void* p;
|
||||||
unsigned nameLength = (name ? strlen(name) : 0);
|
unsigned nameLength = (name ? strlen(name) : 0);
|
||||||
if (mapName) {
|
if (mapName) {
|
||||||
#ifdef __APPLE__
|
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
|
||||||
unsigned size = nameLength + 10;
|
|
||||||
char buffer[size];
|
char buffer[size];
|
||||||
snprintf(buffer, size, "lib%s.dylib", name);
|
snprintf(buffer, size, "lib%s" SO_SUFFIX, name);
|
||||||
#else
|
|
||||||
unsigned size = nameLength + 7;
|
|
||||||
char buffer[size];
|
|
||||||
snprintf(buffer, size, "lib%s.so", name);
|
|
||||||
#endif
|
|
||||||
p = dlopen(buffer, RTLD_LAZY);
|
p = dlopen(buffer, RTLD_LAZY);
|
||||||
} else {
|
} else {
|
||||||
p = dlopen(name, RTLD_LAZY);
|
p = dlopen(name, RTLD_LAZY);
|
||||||
|
Loading…
Reference in New Issue
Block a user