Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2006-11-16 16:57:47 -0500
committerAndrew Niefer2006-11-16 16:57:47 -0500
commit668b8fce79343693be9dbfbebf2aaa66418aefb9 (patch)
tree6162b64c0bb6cc03f2cbed3db791ebcadd969572
parent425fa7102539eca3469bdee8ee597547b8471171 (diff)
downloadrt.equinox.framework-668b8fce79343693be9dbfbebf2aaa66418aefb9.tar.gz
rt.equinox.framework-668b8fce79343693be9dbfbebf2aaa66418aefb9.tar.xz
rt.equinox.framework-668b8fce79343693be9dbfbebf2aaa66418aefb9.zip
executable/library separation on linux/gtk
-rw-r--r--bundles/org.eclipse.equinox.launcher/.cdtproject20
-rw-r--r--bundles/org.eclipse.equinox.launcher/library/eclipse.c2
-rw-r--r--bundles/org.eclipse.equinox.launcher/library/eclipseCommon.h2
-rw-r--r--bundles/org.eclipse.equinox.launcher/library/eclipseMain.c2
-rw-r--r--bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtk.c210
-rw-r--r--bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtkCommon.c98
-rw-r--r--bundles/org.eclipse.equinox.launcher/library/gtk/make_linux.mak50
7 files changed, 162 insertions, 222 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/.cdtproject b/bundles/org.eclipse.equinox.launcher/.cdtproject
index 1f808cd5f..8f09e0faa 100644
--- a/bundles/org.eclipse.equinox.launcher/.cdtproject
+++ b/bundles/org.eclipse.equinox.launcher/.cdtproject
@@ -58,21 +58,35 @@
</item>
<item id="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
-<target name="all-win32" path="library/win32" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
+<target name="all-mingw" targetID="org.eclipse.cdt.make.MakeTargetBuilder" path="library/win32">
<buildCommand>make</buildCommand>
<buildArguments>-f make_mingw.mak</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
</target>
-<target name="clean" path="library/win32" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
+<target name="clean" targetID="org.eclipse.cdt.make.MakeTargetBuilder" path="library/win32">
<buildCommand>make</buildCommand>
<buildArguments>-f make_mingw.mak</buildArguments>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
</target>
-<target name="all-linux" path="library/gtk" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
+<target name="linux-all" targetID="org.eclipse.cdt.make.MakeTargetBuilder" path="library/gtk">
+<buildCommand>make</buildCommand>
+<buildArguments>-f make_linux.mak</buildArguments>
+<buildTarget>all</buildTarget>
+<stopOnError>false</stopOnError>
+<useDefaultCommand>false</useDefaultCommand>
+</target>
+<target name="clean" targetID="org.eclipse.cdt.make.MakeTargetBuilder" path="library/gtk">
+<buildCommand>make</buildCommand>
+<buildArguments>-f make_linux.mak</buildArguments>
+<buildTarget>clean</buildTarget>
+<stopOnError>false</stopOnError>
+<useDefaultCommand>false</useDefaultCommand>
+</target>
+<target name="linux-all" targetID="org.eclipse.cdt.make.MakeTargetBuilder" path="library/motif">
<buildCommand>make</buildCommand>
<buildArguments>-f make_linux.mak</buildArguments>
<buildTarget>all</buildTarget>
diff --git a/bundles/org.eclipse.equinox.launcher/library/eclipse.c b/bundles/org.eclipse.equinox.launcher/library/eclipse.c
index 1069177bb..b0c52a8d3 100644
--- a/bundles/org.eclipse.equinox.launcher/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.launcher/library/eclipse.c
@@ -297,7 +297,7 @@ static _TCHAR* formatVmCommandMsg( _TCHAR* args[] );
static _TCHAR* getDefaultOfficialName();
/*int main( int argc, _TCHAR* argv[] )*/
-__declspec(dllexport) int run(int argc, _TCHAR* argv[])
+JNIEXPORT run(int argc, _TCHAR* argv[])
{
_TCHAR* splashBitmap;
_TCHAR* ch;
diff --git a/bundles/org.eclipse.equinox.launcher/library/eclipseCommon.h b/bundles/org.eclipse.equinox.launcher/library/eclipseCommon.h
index 3a4959da4..5265d633b 100644
--- a/bundles/org.eclipse.equinox.launcher/library/eclipseCommon.h
+++ b/bundles/org.eclipse.equinox.launcher/library/eclipseCommon.h
@@ -34,7 +34,7 @@
#define run runW
#endif
-#define RUN_METHOD STR(run)
+#define RUN_METHOD _T_ECLIPSE(STR(run))
extern _TCHAR dirSeparator; /* '/' or '\\' */
extern _TCHAR pathSeparator; /* separator used in PATH variable */
diff --git a/bundles/org.eclipse.equinox.launcher/library/eclipseMain.c b/bundles/org.eclipse.equinox.launcher/library/eclipseMain.c
index 6d98ac9dc..20619fd18 100644
--- a/bundles/org.eclipse.equinox.launcher/library/eclipseMain.c
+++ b/bundles/org.eclipse.equinox.launcher/library/eclipseMain.c
@@ -175,7 +175,7 @@ int main( int argc, _TCHAR* argv[] )
}
void * handle = loadLibrary(library);
- runMethod = findSymbol(library, RUN_METHOD);
+ runMethod = findSymbol(handle, "run");
exitCode = runMethod(argc, argv);
unloadLibrary(handle);
diff --git a/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtk.c b/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtk.c
index 53f9b03b9..f99772146 100644
--- a/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtk.c
+++ b/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtk.c
@@ -12,6 +12,7 @@
*******************************************************************************/
#include "eclipseMozilla.h"
+#include "eclipseCommon.h"
#include "eclipseOS.h"
#include "eclipseUtil.h"
@@ -21,6 +22,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
+#include <dlfcn.h>
#ifdef SOLARIS
#include <sys/filio.h>
#endif
@@ -34,8 +36,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
/* Global Variables */
-char dirSeparator = '/';
-char pathSeparator = ':';
char* consoleVM = "java";
char* defaultVM = "java";
char* shippedVMDir = "jre/bin/";
@@ -49,155 +49,10 @@ static char* argVM_J9[] = { "-jit", "-mca:1024", "-mco:1024", "-mn:256
/* Define local variables . */
static int saveArgc = 0;
static char** saveArgv = 0;
-static gboolean gtkInitialized = FALSE;
-
-static GtkWidget *label = NULL, *progress = NULL;
-static GdkColor foreground = {0, 0, 0, 0};
-static GdkRectangle progressRect = {0, 0, 0, 0}, messageRect = {0, 0, 0, 0};
-static int value = 0, maximum = 100;
/* Local functions */
static gboolean splashTimeout(gpointer data);
-/* Display a Message */
-void displayMessage(char* title, char* message)
-{
- GtkWidget* dialog;
-
- /* If GTK has not been initialized yet, do it now. */
- if (!gtkInitialized)
- {
- initWindowSystem( &saveArgc, saveArgv, 1 );
- }
-
- dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- "%s", message);
- gtk_window_set_title(GTK_WINDOW (dialog), title);
- gtk_dialog_run(GTK_DIALOG (dialog));
- gtk_widget_destroy(dialog);
-}
-
-
-/* Initialize the Window System */
-void initWindowSystem(int* pArgc, char* argv[], int showSplash)
-{
-
- /* Save the arguments in case displayMessage() is called in the main launcher. */
- if (saveArgv == 0)
- {
- saveArgc = *pArgc;
- saveArgv = argv;
- }
-
-
- /* If the splash screen is going to be displayed by this process */
- if (showSplash)
- {
- /* Initialize GTK. */
- gtk_set_locale();
- gtk_init(pArgc, &argv);
- gdk_set_program_class(officialName);
- gtkInitialized = TRUE;
- }
-}
-
-static void readRect(char *str, GdkRectangle *rect) {
- int x, y, width, height;
- char *temp = str, *comma;
- comma = strchr(temp, ',');
- if (comma == NULL) return;
- comma[0] = 0;
- x = atoi(temp);
- temp = comma + 1;
- comma = strchr(temp, ',');
- if (comma == NULL) return;
- comma[0] = 0;
- y = atoi(temp);
- temp = comma + 1;
- comma = strchr(temp, ',');
- if (comma == NULL) return;
- comma[0] = 0;
- width = atoi(temp);
- temp = comma + 1;
- height = atoi(temp);
- rect->x = x;
- rect->y = y;
- rect->width = width;
- rect->height = height;
-}
-
-static void readColor(char *str, GdkColor *color) {
- int value = atoi(str);
- color->red = ((value & 0xFF0000) >> 16) * 0xFF;
- color->green = ((value & 0xFF00) >> 8) * 0xFF;
- color->blue = ((value & 0xFF) >> 0) * 0xFF;
-}
-
-static void readInput() {
- int available;
- FILE *fd = stdin;
- char *buffer = NULL, *equals = NULL, *end, *line;
- ioctl(fileno(fd), FIONREAD, &available);
- if (available <= 0) return;
- buffer = malloc(available + 1);
- available = fread(buffer, 1, available, fd);
- buffer[available] = 0;
- line = buffer;
- while (line != NULL) {
- end = strchr(line, '\n');
- equals = strchr(line, '=');
- if (end != NULL) end[0] = 0;
- if (equals != NULL) {
- char *str = (char *)equals + 1;
- equals[0] = 0;
- if (strcmp(line, "maximum") == 0) {
- maximum = atoi(str);
- if (progress) {
- double fraction = maximum == 0 ? 1 : (double)(value / maximum);
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), fraction);
- }
- } else if (strcmp(line, "value") == 0) {
- value = atoi(str);
- if (progress) {
- double fraction = maximum == 0 ? 1 : (double)value / maximum;
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), fraction);
- }
- } else if (strcmp(line, "progressRect") == 0) {
- readRect(str, &progressRect);
- if (progress) {
- gtk_fixed_move(GTK_FIXED(gtk_widget_get_parent(progress)), progress, progressRect.x, progressRect.y);
- gtk_widget_set_size_request(GTK_WIDGET(progress), progressRect.width, progressRect.height);
- }
- } else if (strcmp(line, "messageRect") == 0) {
- readRect(str, &messageRect);
- if (label) {
- gtk_fixed_move(GTK_FIXED(gtk_widget_get_parent(label)), label, messageRect.x, messageRect.y);
- gtk_widget_set_size_request(GTK_WIDGET(label), messageRect.width, messageRect.height);
- }
- } else if (strcmp(line, "foreground") == 0) {
- readColor(str, &foreground);
- if (label) {
- gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &foreground);
- }
- } else if (strcmp(line, "message") == 0) {
- if (label) {
- gtk_label_set_text(GTK_LABEL(label), str);
- }
- }
-
- }
- if (end != NULL) line = end + 1;
- else line = NULL;
- }
- free(buffer);
-}
-
-static gboolean timerProc(gpointer data) {
- readInput();
- return TRUE;
-}
-
/* Create and Display the Splash Window */
int showSplash( char* timeoutString, char* featureImage )
{
@@ -225,8 +80,6 @@ int showSplash( char* timeoutString, char* featureImage )
/* Create the image from its data. */
fixed = gtk_fixed_new();
image = gtk_image_new_from_pixbuf(imageData);
- label = gtk_label_new("");
- progress = gtk_progress_bar_new();
/* Create a top level window for the image. */
main = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
@@ -234,21 +87,6 @@ int showSplash( char* timeoutString, char* featureImage )
gtk_container_add(GTK_CONTAINER(main), GTK_WIDGET(fixed));
gtk_container_add(GTK_CONTAINER(fixed), GTK_WIDGET(image));
- gtk_container_add(GTK_CONTAINER(fixed), GTK_WIDGET(label));
- gtk_container_add(GTK_CONTAINER(fixed), GTK_WIDGET(progress));
-
- gtk_misc_set_alignment (GTK_MISC(label), 0.0f, 0.0f);
- gtk_label_set_justify (GTK_LABEL(label), GTK_JUSTIFY_LEFT);
- gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &foreground);
-
- readInput();
- gtk_timeout_add(50, timerProc, NULL);
-
- gtk_fixed_move(GTK_FIXED(fixed), label, messageRect.x, messageRect.y);
- gtk_widget_set_size_request(GTK_WIDGET(label), messageRect.width, messageRect.height);
- gtk_fixed_move(GTK_FIXED(fixed), progress, progressRect.x, progressRect.y);
- gtk_widget_set_size_request(GTK_WIDGET(progress), progressRect.width, progressRect.height);
- gtk_widget_set_size_request(GTK_WIDGET(fixed), gdk_pixbuf_get_width(imageData), gdk_pixbuf_get_height(imageData));
/* Remove window decorations and centre the window on the display. */
gtk_window_set_decorated(main, FALSE);
@@ -269,9 +107,6 @@ int showSplash( char* timeoutString, char* featureImage )
/* Show the window and wait for the timeout (or until the process is terminated). */
gtk_widget_show_all(GTK_WIDGET (main));
gtk_main ();
-
- label = progress = NULL;
-
return 0;
}
@@ -290,43 +125,6 @@ char** getArgVM( char* vm )
return result;
}
-
-/* Start the Java VM
- *
- * This method is called to start the Java virtual machine and to wait until it
- * terminates. The function returns the exit code from the JVM.
- */
-int startJavaVM( char* args[] )
-{
- int jvmExitCode = 1;
- pid_t jvmProcess;
- int exitCode;
-
-#ifdef MOZILLA_FIX
- fixEnvForMozilla();
-#endif /* MOZILLA_FIX */
-
- jvmProcess = fork();
- if (jvmProcess == 0)
- {
- /* Child process ... start the JVM */
- execv(args[0], args);
-
- /* The JVM would not start ... return error code to parent process. */
- _exit(errno);
- }
-
- /* If the JVM is still running, wait for it to terminate. */
- if (jvmProcess != 0)
- {
- wait(&exitCode);
- if (WIFEXITED(exitCode))
- jvmExitCode = WEXITSTATUS(exitCode);
- }
-
- return jvmExitCode;
-}
-
/* Splash Timeout - Hide the main window and exit the main loop. */
static gboolean splashTimeout(gpointer data)
{
@@ -335,3 +133,7 @@ static gboolean splashTimeout(gpointer data)
gtk_main_quit();
return FALSE;
}
+
+char * findVMLibrary( _TCHAR * command ) {
+ return NULL;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtkCommon.c b/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtkCommon.c
new file mode 100644
index 000000000..9d204f1ff
--- /dev/null
+++ b/bundles/org.eclipse.equinox.launcher/library/gtk/eclipseGtkCommon.c
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Andrew Niefer
+ *******************************************************************************/
+
+#include "eclipseCommon.h"
+#include "eclipseOS.h"
+
+#include <locale.h>
+#include <dlfcn.h>
+#include <gtk/gtk.h>
+
+#define ECLIPSE_ICON 401
+
+char dirSeparator = '/';
+char pathSeparator = ':';
+
+void initWindowSystem( int* pArgc, _TCHAR* argv[], int showSplash );
+
+/* Global Main Window*/
+/*#ifdef UNICODE
+extern HWND topWindow;
+#else
+HWND topWindow = 0;
+#endif*/
+
+/* Define local variables for the main window. */
+static int saveArgc = 0; /* arguments after they were parsed, for window system */
+static char** saveArgv = 0;
+
+gboolean gtkInitialized = FALSE;
+
+/* Display a Message */
+void displayMessage(char* title, char* message)
+{
+ GtkWidget* dialog;
+
+ /* If GTK has not been initialized yet, do it now. */
+ if (!gtkInitialized)
+ {
+ initWindowSystem( &saveArgc, saveArgv, 1 );
+ }
+
+ dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ "%s", message);
+ gtk_window_set_title(GTK_WINDOW (dialog), title);
+ gtk_dialog_run(GTK_DIALOG (dialog));
+ gtk_widget_destroy(dialog);
+}
+
+/* Initialize the Window System */
+void initWindowSystem(int* pArgc, char* argv[], int showSplash)
+{
+ if(gtkInitialized)
+ return;
+ /* Save the arguments in case displayMessage() is called in the main launcher. */
+ if (saveArgv == 0)
+ {
+ saveArgc = *pArgc;
+ saveArgv = argv;
+ }
+
+ /* Initialize GTK. */
+ gtk_set_locale();
+ gtk_init(pArgc, &argv);
+ gdk_set_program_class(officialName);
+ gtkInitialized = TRUE;
+}
+
+/* Load the specified shared library
+ */
+void * loadLibrary( _TCHAR * library ){
+ void * result= dlopen(library, RTLD_NOW);
+ if(result == 0)
+ printf("%s\n",dlerror());
+ return result;
+}
+
+/* Unload the shared library
+ */
+void unloadLibrary( void * handle ){
+ dlclose(handle);
+}
+
+/* Find the given symbol in the shared library
+ */
+void * findSymbol( void * handle, char * symbol ){
+ return dlsym(handle, symbol);
+}
+
diff --git a/bundles/org.eclipse.equinox.launcher/library/gtk/make_linux.mak b/bundles/org.eclipse.equinox.launcher/library/gtk/make_linux.mak
index bb074aa98..848eb111d 100644
--- a/bundles/org.eclipse.equinox.launcher/library/gtk/make_linux.mak
+++ b/bundles/org.eclipse.equinox.launcher/library/gtk/make_linux.mak
@@ -21,13 +21,26 @@
# DEFAULT_OS - the default value of the "-os" switch
# DEFAULT_OS_ARCH - the default value of the "-arch" switch
# DEFAULT_WS - the default value of the "-ws" switch
+# JAVA_JNI
+#default value for PROGRAM_OUTPUT
+ifeq ($(PROGRAM_OUTPUT),)
+ PROGRAM_OUTPUT=eclipse
+endif
+ifeq ($(PROGRAM_LIBRARY),)
+ PROGRAM_LIBRARY=$(PROGRAM_OUTPUT)_1.so
+endif
# Define the object modules to be compiled and flags.
CC=gcc
-OBJS = eclipse.o eclipseUtil.o eclipseShm.o eclipseConfig.o eclipseMozilla.o eclipseGtk.o
+MAIN_OBJS = eclipseMain.o
+COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseGtkCommon.o
+DLL_OBJS = eclipse.o eclipseGtk.o eclipseUtil.o eclipseJNI.o
+
EXEC = $(PROGRAM_OUTPUT)
+DLL = $(PROGRAM_LIBRARY)
LIBS = `pkg-config --libs-only-L gtk+-2.0` -lgtk-x11-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lgdk-x11-2.0
-CFLAGS = -O -s \
+LFLAGS = -shared -fpic -Wl,--export-dynamic
+CFLAGS = -g \
-fpic \
-DLINUX \
-DMOZILLA_FIX \
@@ -36,31 +49,44 @@ CFLAGS = -O -s \
-DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
-I. \
-I.. \
+ -I$(JAVA_JNI) \
`pkg-config --cflags gtk+-2.0`
-all: $(EXEC)
+all: $(EXEC) $(DLL)
-eclipse.o: ../eclipse.c ../eclipseOS.h
+eclipse.o: ../eclipse.c ../eclipseOS.h ../eclipseCommon.h
$(CC) $(CFLAGS) -c ../eclipse.c -o eclipse.o
+eclipseMain.o: ../eclipseUnicode.h ../eclipseCommon.h ../eclipseMain.c
+ $(CC) $(CFLAGS) -c ../eclipseMain.c
+
+eclipseCommon.o: ../eclipseCommon.h ../eclipseUnicode.h ../eclipseCommon.c
+ $(CC) $(CFLAGS) -c ../eclipseCommon.c
+
+eclipseGtkCommon.o: ../eclipseCommon.h eclipseGtkCommon.c
+ $(CC) $(CFLAGS) -c eclipseGtkCommon.c
+
eclipseUtil.o: ../eclipseUtil.c ../eclipseUtil.h ../eclipseOS.h
$(CC) $(CFLAGS) -c ../eclipseUtil.c -o eclipseUtil.o
-eclipseShm.o: ../eclipseShm.c ../eclipseShm.h ../eclipseOS.h
- $(CC) $(CFLAGS) -c ../eclipseShm.c -o eclipseShm.o
-
+eclipseJNI.o: ../eclipseJNI.c ../eclipseJNI.h
+ $(CC) $(CFLAGS) -c ../eclipseJNI.c -o eclipseJNI.o
+
eclipseConfig.o: ../eclipseConfig.c ../eclipseConfig.h ../eclipseOS.h
$(CC) $(CFLAGS) -c ../eclipseConfig.c -o eclipseConfig.o
eclipseMozilla.o: ../eclipseMozilla.c ../eclipseMozilla.h ../eclipseOS.h
$(CC) $(CFLAGS) -c ../eclipseMozilla.c -o eclipseMozilla.o
-$(EXEC): $(OBJS)
- $(CC) -o $(EXEC) $(OBJS) $(LIBS)
+$(EXEC): $(MAIN_OBJS) $(COMMON_OBJS)
+ $(CC) -o $(EXEC) $(MAIN_OBJS) $(COMMON_OBJS) $(LIBS)
+
+$(DLL): $(DLL_OBJS) $(COMMON_OBJS)
+ $(CC) $(LFLAGS) -o $(DLL) $(DLL_OBJS) $(COMMON_OBJS) $(LIBS)
install: all
- cp $(EXEC) $(OUTPUT_DIR)
- rm -f $(EXEC) $(OBJS)
+ cp $(EXEC) $(DLL) $(OUTPUT_DIR)
+ rm -f $(EXEC) $(DLL) $(MAIN_OBJS) $(COMMON_OBJS) $(DLL_OBJS)
clean:
- rm -f $(EXEC) $(OBJS)
+ rm -f $(EXEC) $(MAIN_OBJS) $(COMMON_OBJS) $(DLL_OBJS)

Back to the top