Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.executable/library/photon')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/photon/.cvsignore2
-rw-r--r--bundles/org.eclipse.equinox.executable/library/photon/build.sh78
-rw-r--r--bundles/org.eclipse.equinox.executable/library/photon/build.xml21
-rw-r--r--bundles/org.eclipse.equinox.executable/library/photon/eclipsePhoton.c290
-rw-r--r--bundles/org.eclipse.equinox.executable/library/photon/make_qnx.mak57
5 files changed, 448 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/photon/.cvsignore b/bundles/org.eclipse.equinox.executable/library/photon/.cvsignore
new file mode 100644
index 000000000..5535df034
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/photon/.cvsignore
@@ -0,0 +1,2 @@
+*.o
+eclipse
diff --git a/bundles/org.eclipse.equinox.executable/library/photon/build.sh b/bundles/org.eclipse.equinox.executable/library/photon/build.sh
new file mode 100644
index 000000000..2166d19ff
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/photon/build.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#*******************************************************************************
+# Copyright (c) 2000, 2005 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
+# Kevin Cornell (Rational Software Corporation)
+#*******************************************************************************
+#
+# Usage: sh build.sh [<optional switches>] [clean]
+#
+# where the optional switches are:
+# -output <PROGRAM_OUTPUT> - executable filename ("eclipse")
+# -os <DEFAULT_OS> - default Eclipse "-os" value
+# -arch <DEFAULT_OS_ARCH> - default Eclipse "-arch" value
+# -ws <DEFAULT_WS> - default Eclipse "-ws" value
+#
+#
+# This script can also be invoked with the "clean" argument.
+
+cd `dirname $0`
+
+# Define default values for environment variables used in the makefiles.
+programOutput="eclipse"
+defaultOS="qnx"
+defaultOSArch="x86"
+defaultWS="photon"
+makefile="make_qnx.mak"
+if [ "$OS" = "" ]; then
+ OS=`uname -s`
+fi
+
+# Parse the command line arguments and override the default values.
+extraArgs=""
+while [ "$1" != "" ]; do
+ if [ "$1" = "-os" ] && [ "$2" != "" ]; then
+ defaultOS="$2"
+ shift
+ elif [ "$1" = "-arch" ] && [ "$2" != "" ]; then
+ defaultOSArch="$2"
+ shift
+ elif [ "$1" = "-ws" ] && [ "$2" != "" ]; then
+ defaultWS="$2"
+ shift
+ elif [ "$1" = "-output" ] && [ "$2" != "" ]; then
+ programOutput="$2"
+ shift
+ else
+ extraArgs="$extraArgs $1"
+ fi
+ shift
+done
+
+# Set up environment variables needed by the makefiles.
+PROGRAM_OUTPUT="$programOutput"
+DEFAULT_OS="$defaultOS"
+DEFAULT_OS_ARCH="$defaultOSArch"
+DEFAULT_WS="$defaultWS"
+OUTPUT_DIR="../../bin/$defaultWS/$defaultOS/$defaultOSArch"
+
+export OUTPUT_DIR PROGRAM_OUTPUT DEFAULT_OS DEFAULT_OS_ARCH DEFAULT_WS
+
+# If the OS is supported (a makefile exists)
+if [ "$makefile" != "" ]; then
+ if [ "$extraArgs" != "" ]; then
+ make -f $makefile $extraArgs
+ else
+ echo "Building $OS launcher. Defaults: -os $DEFAULT_OS -arch $DEFAULT_OS_ARCH -ws $DEFAULT_WS"
+ make -f $makefile clean
+ make -f $makefile all
+ fi
+else
+ echo "Unknown OS ($OS) -- build aborted"
+fi
diff --git a/bundles/org.eclipse.equinox.executable/library/photon/build.xml b/bundles/org.eclipse.equinox.executable/library/photon/build.xml
new file mode 100644
index 000000000..b4308a9a2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/photon/build.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project default="build_eclipse" basedir=".">
+
+<target name="build_eclipse">
+ <exec dir="." executable="sh">
+ <arg line="${basedir}/build.sh"/>
+ <arg line="install"/>
+ </exec>
+ <eclipse.refreshLocal resource="platform-launcher" depth="infinite" />
+</target>
+
+<target name="clean">
+ <tstamp/>
+ <exec dir="." executable="sh">
+ <arg line="${basedir}/build.sh"/>
+ <arg line="clean"/>
+ </exec>
+</target>
+
+</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.executable/library/photon/eclipsePhoton.c b/bundles/org.eclipse.equinox.executable/library/photon/eclipsePhoton.c
new file mode 100644
index 000000000..e45e2c0e2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/photon/eclipsePhoton.c
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * Kevin Cornell (Rational Software Corporation)
+ *******************************************************************************/
+
+/* Photon specific logic for displaying the splash screen. */
+
+#include "eclipseOS.h"
+#include "eclipseUtil.h"
+#include <Pt.h>
+
+#define PX_IMAGE_MODULES
+#define PX_BMP_SUPPORT
+
+#include <photon/PxImage.h>
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+#include <libgen.h>
+
+/* Global Variables */
+char dirSeparator = '/';
+char pathSeparator = ':';
+#ifndef J9VM
+char* consoleVM = "java";
+char* defaultVM = "java";
+char* shippedVMDir = "jre/bin/";
+#else
+char* consoleVM = "j9";
+char* defaultVM = "j9";
+char* shippedVMDir = "ive/bin/";
+#endif
+
+/* Define the window system arguments for the various Java VMs. */
+static char* argVM_JAVA[] = { NULL };
+static char* argVM_J9[] = { "-jit", "-ms:32", "-mso:256", NULL };
+
+
+/* Define local variables for the main window. */
+static PtWidget_t* topWindow = NULL;
+
+/* Define local variables for running the JVM and detecting its exit. */
+static pid_t jvmProcess = 0;
+static int jvmExitCode;
+
+/* Local functions */
+static void bringDownSplashWindow( int );
+static void centreWindow( PtWidget_t *widget, PtWidget_t *label);
+static int splashTimeout( PtWidget_t* widget, void* data, PtCallbackInfo_t* id );
+
+/* Display a Message */
+void displayMessage( char* title, char* message )
+{
+ if (topWindow == 0)
+ {
+ initWindowSystem( NULL, NULL, 0 );
+ }
+
+ PtNotice( NULL,NULL, title, NULL, message, NULL, NULL, NULL, Pt_CENTER | Pt_MODAL );
+}
+
+
+/* Initialize Window System
+ *
+ * Initialize Photon.
+ */
+void initWindowSystem( int* pArgc, char* argv[], int showSplash )
+{
+ PtArg_t arg[5];
+ int nArgs;
+
+ /* Create a top level window with no decorations. */
+ setlocale(LC_ALL, "");
+ PtInit( NULL );
+ nArgs = 0;
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_WINDOW_RENDER_FLAGS, 0, ~0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Ph_WM_TASKBAR | Ph_WM_CLOSE, ~0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_WINDOW_STATE, Ph_WM_STATE_ISFRONT, ~0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_WINDOW_TITLE, officialName, ~0 );
+ topWindow = PtCreateWidget( PtWindow, Pt_NO_PARENT, nArgs, arg );
+}
+
+
+/* Show the Splash Window
+ *
+ * Create the splash window, load the bitmap and display the splash window.
+ *
+ */
+int showSplash( char* timeoutString, char* featureImage )
+{
+ int timeout = 0;
+ PtWidget_t* label;
+ PtArg_t arg[10];
+ PhImage_t* image = NULL;
+ int nArgs;
+ int depth;
+ PgDisplaySettings_t settings;
+ PgVideoModeInfo_t mode_info;
+
+ /* Determine the splash timeout value (in seconds). */
+ if (timeoutString != NULL && strlen( timeoutString ) > 0)
+ {
+ sscanf( timeoutString, "%d", &timeout );
+ }
+
+ /* Install a signal handler to catch SIGUSR2 (which will shut down the window). */
+ signal( SIGUSR2, bringDownSplashWindow );
+
+ /* Load the splash image from the feature directory. */
+ PgGetVideoMode( &settings );
+ PgGetVideoModeInfo( settings.mode, &mode_info );
+ depth = mode_info.bits_per_pixel;
+ if (featureImage != NULL)
+ image = PxLoadImage( featureImage, NULL );
+
+ /* If the splash image could not be found, return an error. */
+ if (image == NULL)
+ return ENOENT;
+
+ /* Create a label widget (only child of top window) with the image. */
+ nArgs = 0;
+ image->flags |= Ph_RELEASE_IMAGE_ALL;
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_LABEL_TYPE, Pt_IMAGE, 0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_LABEL_IMAGE, image, 0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_TEXT_STRING, officialName, 0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_MARGIN_WIDTH, 0, 0 );
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0 );
+ label = PtCreateWidget( PtLabel, topWindow, nArgs, arg );
+
+ /* Free the image */
+ free( image );
+
+ /* Centre the splash window and display it. */
+ centreWindow( topWindow, label );
+
+ /* If a timeout for the splash window was given */
+ if (timeout != 0)
+ {
+ PtAddEventHandler( topWindow, Ph_EV_TIMER, splashTimeout, NULL );
+ PtTimerArm( topWindow, (timeout * 1000) );
+ }
+
+ /* Process messages until the splash window is closed or process is terminated. */
+ while (PtWidgetIsRealized( topWindow ))
+ {
+ PtProcessEvent();
+ }
+
+ /* Destroy the splash window. */
+ PtDestroyWidget( topWindow );
+ topWindow = 0;
+
+ return 0;
+}
+
+
+/* Get the window system specific VM arguments */
+char** getArgVM( char* vm )
+{
+ return (isJ9VM( vm ) ? argVM_J9 : argVM_JAVA);
+}
+
+void fixEnvForJ9( char* vm ) {
+ if (isJ9VM( vm )) {
+ char *ldpath;
+ char newpath[PATH_MAX+1];
+
+ ldpath = getenv( "LD_LIBRARY_PATH" );
+
+ /* Always dup the string so we can free later */
+ if( ldpath != NULL )
+ ldpath = strdup( ldpath );
+ else
+ ldpath = strdup( "" );
+
+ /* Get the j9 binary location */
+ strncpy( newpath, vm, PATH_MAX );
+ dirname( newpath );
+
+ /* Add j9 binary location to LD_LIBRARY_PATH */
+ ldpath = realloc( ldpath, strlen( ldpath ) + strlen( newpath ) + 2 );
+ if( ldpath != NULL )
+ {
+ strcat( ldpath, ":" );
+ strcat( ldpath, newpath );
+ }
+
+ setenv( "LD_LIBRARY_PATH", ldpath, 1 );
+
+ free( ldpath );
+ }
+}
+
+/* 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 exitCode;
+
+ fixEnvForJ9 (args [0]);
+
+ /* Create a child process for the JVM. */
+ 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. */
+ jvmExitCode = errno;
+ exit( jvmExitCode );
+ }
+
+ /* If the JVM is still running, wait for it to terminate. */
+ if (jvmProcess != 0)
+ {
+ wait( &exitCode );
+ jvmExitCode = ((exitCode & 0x00ff) == 0 ? (exitCode >> 8) : exitCode); /* see wait(2) */
+ }
+
+ /* Return the exit code from the JVM. */
+ return jvmExitCode;
+}
+
+/*------ Local functions -----*/
+
+
+/* Catch a signal that indicates the splash window is to be brought down. */
+static void bringDownSplashWindow( int sig )
+{
+ if (topWindow != 0)
+ {
+ PtUnrealizeWidget( topWindow );
+ }
+}
+
+
+/* Centre the top window on the screen. */
+
+static void centreWindow( PtWidget_t* window, PtWidget_t* expose )
+{
+ PtArg_t arg[2];
+ int nArgs;
+ PhPoint_t pos;
+ PhArea_t area;
+ PhRect_t rect;
+ int width, height;
+
+ /* Realize the top window to calculate its width/height. */
+ PtExtentWidgetFamily( window );
+
+ /* Get the desired dimensions of the window. */
+ PtWidgetArea( window, &area );
+
+ /* Calculate the X and Y position for the window. */
+ PhWindowQueryVisible( Ph_QUERY_WORKSPACE, 0, PhInputGroup(0), &rect );
+ width = rect.lr.x - rect.ul.x + 1;
+ height = rect.lr.y - rect.ul.y + 1;
+ pos.x = rect.ul.x + (width - area.size.w) / 2;
+ pos.y = rect.ul.y + (height - area.size.h) / 2;
+
+ /* Set the new shell position and display it. */
+ nArgs = 0;
+ PtSetArg( &arg[ nArgs++ ], Pt_ARG_POS, &pos, 0 );
+ PtSetResources( window, nArgs, arg );
+ PtRealizeWidget( window );
+}
+
+
+/* Splash Timeout */
+static int splashTimeout( PtWidget_t* widget, void* data, PtCallbackInfo_t* info )
+{
+ bringDownSplashWindow( 0 );
+ return 1;
+}
diff --git a/bundles/org.eclipse.equinox.executable/library/photon/make_qnx.mak b/bundles/org.eclipse.equinox.executable/library/photon/make_qnx.mak
new file mode 100644
index 000000000..fac6918db
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/photon/make_qnx.mak
@@ -0,0 +1,57 @@
+#*******************************************************************************
+# Copyright (c) 2000, 2005 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
+# Kevin Cornell (Rational Software Corporation)
+#*******************************************************************************
+
+# Makefile for creating the Photon eclipse launcher program.
+
+# This makefile expects the following environment variables set:
+#
+# PROGRAM_OUTPUT - the filename of the output executable
+# 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
+
+# Define the object modules to be compiled and flags.
+OBJS = eclipse.o eclipseUtil.o eclipseShm.o eclipseConfig.o eclipsePhoton.o
+EXEC = $(PROGRAM_OUTPUT)
+LIBS = -lph -lphrender -lphexlib
+CFLAGS = -O -s -Wall \
+ -DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
+ -DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
+ -DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
+ -DJ9VM -I.. -DPHOTON
+
+all: $(EXEC)
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
+
+eclipse.o: ../eclipse.c ../eclipseOS.h
+ $(CC) $(CFLAGS) -c ../eclipse.c -o $@
+
+eclipseShm.o: ../eclipseShm.c ../eclipseShm.h ../eclipseOS.h
+ $(CC) $(CFLAGS) -c ../eclipseShm.c -o $@
+
+eclipseConfig.o: ../eclipseConfig.c ../eclipseConfig.h ../eclipseOS.h
+ $(CC) $(CFLAGS) -c ../eclipseConfig.c -o $@
+
+eclipseUtil.o: ../eclipseUtil.c ../eclipseUtil.h ../eclipseOS.h
+ $(CC) $(CFLAGS) -c ../eclipseUtil.c -o $@
+
+$(EXEC): $(OBJS)
+ $(CC) -o $(EXEC) $(OBJS) $(LIBS)
+
+install: all
+ cp $(EXEC) $(OUTPUT_DIR)
+ rm -f $(EXEC) $(OBJS)
+
+clean:
+ rm -f $(EXEC) $(OBJS)

Back to the top