mirror of
https://github.com/corda/corda.git
synced 2025-02-04 18:22:29 +00:00
Added in code to support os.version for Windows/Linux/OSX
The make file had to be modified to include the carbon framework in OSX
This commit is contained in:
parent
f4347dee70
commit
3367ac88e3
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
There is NO WARRANTY for this software. See license.txt for
|
There is NO WARRANTY for this software. See license.txt for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "sys/time.h"
|
#include "sys/time.h"
|
||||||
@ -32,11 +32,13 @@
|
|||||||
# define SO_PREFIX ""
|
# define SO_PREFIX ""
|
||||||
#else
|
#else
|
||||||
# define SO_PREFIX "lib"
|
# define SO_PREFIX "lib"
|
||||||
|
#include "sys/utsname.h"
|
||||||
#include "sys/wait.h"
|
#include "sys/wait.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# define SO_SUFFIX ".jnilib"
|
# define SO_SUFFIX ".jnilib"
|
||||||
|
#include "Gestalt.h"
|
||||||
#elif defined WIN32
|
#elif defined WIN32
|
||||||
# define SO_SUFFIX ".dll"
|
# define SO_SUFFIX ".dll"
|
||||||
#else
|
#else
|
||||||
@ -349,6 +351,14 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
|
|||||||
r = e->NewStringUTF("\\");
|
r = e->NewStringUTF("\\");
|
||||||
} else if (strcmp(chars, "os.name") == 0) {
|
} else if (strcmp(chars, "os.name") == 0) {
|
||||||
r = e->NewStringUTF("Windows");
|
r = e->NewStringUTF("Windows");
|
||||||
|
} else if (strcmp(chars, "os.version") == 0) {
|
||||||
|
unsigned size = 32;
|
||||||
|
char buffer[size];
|
||||||
|
OSVERSIONINFO OSversion;
|
||||||
|
OSversion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
|
||||||
|
::GetVersionEx(&OSversion);
|
||||||
|
snprintf(buffer, size, "%i.%i", (int)OSversion.dwMajorVersion, (int)OSversion.dwMinorVersion);
|
||||||
|
r = e->NewStringUTF(buffer);
|
||||||
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
|
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
|
||||||
TCHAR buffer[MAX_PATH];
|
TCHAR buffer[MAX_PATH];
|
||||||
GetTempPath(MAX_PATH, buffer);
|
GetTempPath(MAX_PATH, buffer);
|
||||||
@ -367,11 +377,27 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
|
|||||||
r = e->NewStringUTF("Mac OS X");
|
r = e->NewStringUTF("Mac OS X");
|
||||||
#else
|
#else
|
||||||
r = e->NewStringUTF("Linux");
|
r = e->NewStringUTF("Linux");
|
||||||
|
#endif
|
||||||
|
} else if (strcmp(chars, "os.version") == 0) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
unsigned size = 32;
|
||||||
|
char buffer[size];
|
||||||
|
long minorVersion, majorVersion;
|
||||||
|
|
||||||
|
Gestalt(gestaltSystemVersionMajor, &majorVersion);
|
||||||
|
Gestalt(gestaltSystemVersionMinor, &minorVersion);
|
||||||
|
|
||||||
|
snprintf(buffer, size, "%lld.%lld", majorVersion, minorVersion);
|
||||||
|
r = e->NewStringUTF(buffer);
|
||||||
|
#else
|
||||||
|
struct utsname system_id;
|
||||||
|
uname(&system_id);
|
||||||
|
r = e->NewStringUTF(system_id.release);
|
||||||
#endif
|
#endif
|
||||||
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
|
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
|
||||||
r = e->NewStringUTF("/tmp");
|
r = e->NewStringUTF("/tmp");
|
||||||
} else if (strcmp(chars, "user.home") == 0) {
|
} else if (strcmp(chars, "user.home") == 0) {
|
||||||
r = e->NewStringUTF(getenv("HOME"));
|
r = e->NewStringUTF(getenv("HOME"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
2
makefile
2
makefile
@ -123,7 +123,7 @@ endif
|
|||||||
|
|
||||||
ifeq ($(platform),darwin)
|
ifeq ($(platform),darwin)
|
||||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
||||||
lflags = $(common-lflags) -ldl -framework CoreFoundation
|
lflags = $(common-lflags) -ldl -framework CoreFoundation -framework Carbon
|
||||||
ifeq ($(bootimage),true)
|
ifeq ($(bootimage),true)
|
||||||
bootimage-lflags = -Wl,-segprot,__BOOT,rwx,rwx
|
bootimage-lflags = -Wl,-segprot,__BOOT,rwx,rwx
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user