Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2012-04-17 19:23:23 +0000
committerSilenio Quarti2012-04-17 19:23:23 +0000
commit3011e6a9c0142036bd38851224e8e030936dc858 (patch)
treed9d8e6c6bc52bbfa2e168212c3ec213b249c0480
parentc08dc80bcad08c1c77b1a4d065afed38ef576ae5 (diff)
downloadrt.equinox.framework-3011e6a9c0142036bd38851224e8e030936dc858.tar.gz
rt.equinox.framework-3011e6a9c0142036bd38851224e8e030936dc858.tar.xz
rt.equinox.framework-3011e6a9c0142036bd38851224e8e030936dc858.zip
Bug 374791 - Support bundling Oracle's JRE with Mac OS X builds
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/build.sh2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c82
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonCommon.c13
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseUtil.c2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseUtil.h4
-rw-r--r--bundles/org.eclipse.equinox.executable/library/make_version.mak2
6 files changed, 93 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/build.sh b/bundles/org.eclipse.equinox.executable/library/carbon/build.sh
index 078257ab1..dfd0cde8d 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/build.sh
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/build.sh
@@ -66,7 +66,7 @@ X86_64_OUTPUT_DIR="../../bin/$defaultWS/$defaultOS/x86_64/Eclipse.app/Contents/M
if [ "$DEFAULT_WS" == "cocoa" ]; then
makefile="make_cocoa.mak"
- export MACOSX_DEPLOYMENT_TARGET=10.4
+ export MACOSX_DEPLOYMENT_TARGET=10.5
else
export MACOSX_DEPLOYMENT_TARGET=10.3
fi
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
index 794395731..04e729860 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
@@ -45,7 +45,8 @@ char *findCommand(char *command);
/* Global Variables */
char* defaultVM = "java";
char* vmLibrary = "JavaVM";
-char* shippedVMDir = "jre/bin/";
+char* shippedVMDir = "../../../jre/Contents/Home/jre/bin/";
+int isSUN = 0;
static void adjustLibraryPath(char * vmLibrary);
static char * findLib(char * command);
@@ -469,10 +470,66 @@ char** getArgVM( char* vm )
return result;
}
+char * getJavaVersion(char* command) {
+ FILE *fp;
+ char buffer[4096];
+ char *version = NULL, *firstChar;
+ int numChars = 0;
+ sprintf(buffer,"%s -version 2>&1", command);
+ fp = popen(buffer, "r");
+ if (fp == NULL) {
+ return NULL;
+ }
+ while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
+ if (!version) {
+ firstChar = (char *) (strchr(buffer, '"') + 1);
+ if (firstChar != NULL)
+ numChars = (int) (strrchr(buffer, '"') - firstChar);
+
+ /* Allocate a buffer and copy the version string into it. */
+ if (numChars > 0)
+ {
+ version = malloc( numChars + 1 );
+ strncpy(version, firstChar, numChars);
+ version[numChars] = '\0';
+ }
+ }
+ if (strstr(buffer, "Java HotSpot(TM)") || strstr(buffer, "OpenJDK")) {
+ isSUN = 1;
+ break;
+ }
+ if (strstr(buffer, "IBM") != NULL) {
+ isSUN = 0;
+ break;
+ }
+ }
+ pclose(fp);
+ return version;
+}
+
+char * getJavaHome() {
+ FILE *fp;
+ char path[4096];
+ char *result, *start;
+ fp = popen("/usr/libexec/java_home", "r");
+ if (fp == NULL) {
+ return NULL;
+ }
+ while (fgets(path, sizeof(path)-1, fp) != NULL) {
+ }
+ result = strdup(path);
+ start = strchr(result, '\n');
+ if (start) {
+ start[0] = 0;
+ }
+ pclose(fp);
+ return result;
+}
+
char * findVMLibrary( char* command ) {
char *start, *end;
char *version;
- int length;
+ int length, isJDK7;
/*check first to see if command already points to the library */
if (strcmp(command, JAVA_FRAMEWORK) == 0) {
@@ -497,7 +554,23 @@ char * findVMLibrary( char* command ) {
free(version);
}
- } else if (strstr(command, "/JavaVM.framework/") == NULL) {
+ }
+ version = getJavaVersion(command);
+ isJDK7 = version && versionCmp(version, "1.7.0") >= 0;
+ if (version) free(version);
+ if (isJDK7) {
+ char *java_home = NULL, *cmd = command;
+ if (strstr(cmd, "/JavaVM.framework/") != NULL && (strstr(cmd, "/Current/") != NULL || strstr(cmd, "/A/") != NULL)) {
+ java_home = cmd = getJavaHome();
+ }
+ start = strstr(cmd, "/Contents/");
+ if (start != NULL){
+ start[0] = 0;
+ return cmd;
+ }
+ if (java_home) free(java_home);
+ }
+ if (strstr(command, "/JavaVM.framework/") == NULL) {
char * lib = findLib(command);
if (lib != NULL) {
adjustLibraryPath(lib);
@@ -815,6 +888,5 @@ void processVMArgs(char **vmargs[] )
}
int isSunVM( _TCHAR * javaVM, _TCHAR * jniLib ) {
- _TCHAR *vm = (jniLib != NULL) ? jniLib : javaVM;
- return (strncmp(vm, JAVA_FRAMEWORK, strlen(JAVA_FRAMEWORK)) == 0);
+ return isSUN;
}
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonCommon.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonCommon.c
index 017c691e6..2870c62e8 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonCommon.c
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonCommon.c
@@ -111,11 +111,20 @@ void displayMessage(char *title, char *message)
CFRelease(inDescription);
}
+static int isLibrary( _TCHAR* vm ){
+ _TCHAR *ch = NULL;
+ if (vm == NULL) return 0;
+ ch = _tcsrchr( vm, '.' );
+ if(ch == NULL)
+ return 0;
+ return (_tcsicmp(ch, _T_ECLIPSE(".so")) == 0) || (_tcsicmp(ch, _T_ECLIPSE(".jnilib")) == 0) || (_tcsicmp(ch, _T_ECLIPSE(".dylib")) == 0);
+}
+
/* Load the specified shared library
*/
void * loadLibrary( char * library ){
- if (strcmp(library, JAVA_FRAMEWORK) == 0) {
- CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)JAVA_FRAMEWORK, strlen(JAVA_FRAMEWORK), true);
+ if (!isLibrary(library)) {
+ CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)library, strlen(library), true);
javaVMBundle = CFBundleCreate(kCFAllocatorDefault, url);
CFRelease(url);
return (void*) &javaVMBundle;
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c
index 09eb9fd8b..130afb347 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.c
@@ -293,6 +293,7 @@ char* getVMVersion( char *vmPath )
return version;
}
+#endif /* AIX */
/* Compare JVM Versions of the form "x.x.x..."
*
@@ -330,4 +331,3 @@ int versionCmp(char *ver1, char *ver2)
return versionCmp((char*)(dot1 + 1), (char*)(dot2 + 1) );
}
-#endif /* AIX */
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h
index f9d500364..7843a3f9b 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseUtil.h
@@ -50,12 +50,12 @@ extern _TCHAR* concatPaths(_TCHAR** paths, _TCHAR pathSeparator);
/* check that the buffer contains all the given paths */
extern int containsPaths(_TCHAR * str, _TCHAR** paths);
-#ifdef AIX
+#ifdef AIX
/* Get the version of the VM */
extern char* getVMVersion( char* vm );
+#endif
/* Compare JVM Versions */
extern int versionCmp( char* ver1, char* ver2 );
-#endif
#endif /* ECLIPSE_UTIL_H */
diff --git a/bundles/org.eclipse.equinox.executable/library/make_version.mak b/bundles/org.eclipse.equinox.executable/library/make_version.mak
index 8212bb3c7..f5eab1ce4 100644
--- a/bundles/org.eclipse.equinox.executable/library/make_version.mak
+++ b/bundles/org.eclipse.equinox.executable/library/make_version.mak
@@ -10,5 +10,5 @@
#*******************************************************************************
maj_ver=1
-min_ver=501
+min_ver=502
LIB_VERSION = $(maj_ver)$(min_ver)

Back to the top