Lines 9-14
Link Here
|
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
10 |
* Kevin Cornell (Rational Software Corporation) |
10 |
* Kevin Cornell (Rational Software Corporation) |
11 |
* Markus Schorn (Wind River Systems), bug 193340 |
11 |
* Markus Schorn (Wind River Systems), bug 193340 |
|
|
12 |
* Martin Oberhuber (Wind River) - [149994] Add --launcher.appendVmargs |
12 |
*******************************************************************************/ |
13 |
*******************************************************************************/ |
13 |
|
14 |
|
14 |
/* Eclipse Program Launcher |
15 |
/* Eclipse Program Launcher |
Lines 233-238
Link Here
|
233 |
#define LIBRARY _T_ECLIPSE("--launcher.library") |
234 |
#define LIBRARY _T_ECLIPSE("--launcher.library") |
234 |
#define SUPRESSERRORS _T_ECLIPSE("--launcher.suppressErrors") |
235 |
#define SUPRESSERRORS _T_ECLIPSE("--launcher.suppressErrors") |
235 |
#define INI _T_ECLIPSE("--launcher.ini") |
236 |
#define INI _T_ECLIPSE("--launcher.ini") |
|
|
237 |
#define APPEND_VMARGS _T_ECLIPSE("--launcher.appendVmargs") |
238 |
#define OVERRIDE_VMARGS _T_ECLIPSE("--launcher.overrideVmargs") |
236 |
#define SECOND_THREAD _T_ECLIPSE("--launcher.secondThread") |
239 |
#define SECOND_THREAD _T_ECLIPSE("--launcher.secondThread") |
237 |
#define PERM_GEN _T_ECLIPSE("--launcher.XXMaxPermSize") |
240 |
#define PERM_GEN _T_ECLIPSE("--launcher.XXMaxPermSize") |
238 |
|
241 |
|
Lines 254-259
Link Here
|
254 |
static int noSplash = 0; /* True: do not show splash win */ |
257 |
static int noSplash = 0; /* True: do not show splash win */ |
255 |
static int suppressErrors = 0; /* True: do not display errors dialogs */ |
258 |
static int suppressErrors = 0; /* True: do not display errors dialogs */ |
256 |
int secondThread = 0; /* True: start the VM on a second thread */ |
259 |
int secondThread = 0; /* True: start the VM on a second thread */ |
|
|
260 |
static int appendVmargs = 0; /* True: append cmdline vmargs to launcher.ini vmargs */ |
257 |
|
261 |
|
258 |
static _TCHAR* showSplashArg = NULL; /* showsplash data (main launcher window) */ |
262 |
static _TCHAR* showSplashArg = NULL; /* showsplash data (main launcher window) */ |
259 |
static _TCHAR* splashBitmap = NULL; /* the actual splash bitmap */ |
263 |
static _TCHAR* splashBitmap = NULL; /* the actual splash bitmap */ |
Lines 289-294
Link Here
|
289 |
/* don't assign it and only remove (remove - 1) arguments */ |
293 |
/* don't assign it and only remove (remove - 1) arguments */ |
290 |
#define ADJUST_PATH 4 /* value is a path, do processing on relative paths to try and make them absolute */ |
294 |
#define ADJUST_PATH 4 /* value is a path, do processing on relative paths to try and make them absolute */ |
291 |
#define VALUE_IS_LIST 8 /* value is a pointer to a tokenized _TCHAR* string for EE files, or a _TCHAR** list for the command line */ |
295 |
#define VALUE_IS_LIST 8 /* value is a pointer to a tokenized _TCHAR* string for EE files, or a _TCHAR** list for the command line */ |
|
|
296 |
#define INVERT_FLAG 16 /* invert the meaning of a flag, i.e. reset it */ |
292 |
|
297 |
|
293 |
static Option options[] = { |
298 |
static Option options[] = { |
294 |
{ CONSOLE, &needConsole, VALUE_IS_FLAG, 0 }, |
299 |
{ CONSOLE, &needConsole, VALUE_IS_FLAG, 0 }, |
Lines 297-302
Link Here
|
297 |
{ NOSPLASH, &noSplash, VALUE_IS_FLAG, 1 }, |
302 |
{ NOSPLASH, &noSplash, VALUE_IS_FLAG, 1 }, |
298 |
{ SUPRESSERRORS, &suppressErrors, VALUE_IS_FLAG, 1}, |
303 |
{ SUPRESSERRORS, &suppressErrors, VALUE_IS_FLAG, 1}, |
299 |
{ SECOND_THREAD, &secondThread, VALUE_IS_FLAG, 1 }, |
304 |
{ SECOND_THREAD, &secondThread, VALUE_IS_FLAG, 1 }, |
|
|
305 |
{ APPEND_VMARGS, &appendVmargs, VALUE_IS_FLAG, 1 }, |
306 |
{ OVERRIDE_VMARGS, &appendVmargs, VALUE_IS_FLAG | INVERT_FLAG, 1 }, |
300 |
{ LIBRARY, NULL, 0, 2 }, /* library was parsed by exe, just remove it */ |
307 |
{ LIBRARY, NULL, 0, 2 }, /* library was parsed by exe, just remove it */ |
301 |
{ INI, NULL, 0, 2 }, /* same with ini */ |
308 |
{ INI, NULL, 0, 2 }, /* same with ini */ |
302 |
{ OS, &osArg, 0, 2 }, |
309 |
{ OS, &osArg, 0, 2 }, |
Lines 331-336
Link Here
|
331 |
/* Local methods */ |
338 |
/* Local methods */ |
332 |
static void parseArgs( int* argc, _TCHAR* argv[] ); |
339 |
static void parseArgs( int* argc, _TCHAR* argv[] ); |
333 |
static void processDefaultAction(int argc, _TCHAR* argv[]); |
340 |
static void processDefaultAction(int argc, _TCHAR* argv[]); |
|
|
341 |
static void mergeUserVMArgs( _TCHAR **vmArgs[] ); |
334 |
static void getVMCommand( int launchMode, int argc, _TCHAR* argv[], _TCHAR **vmArgv[], _TCHAR **progArgv[] ); |
342 |
static void getVMCommand( int launchMode, int argc, _TCHAR* argv[], _TCHAR **vmArgv[], _TCHAR **progArgv[] ); |
335 |
static int determineVM(_TCHAR** msg); |
343 |
static int determineVM(_TCHAR** msg); |
336 |
static int vmEEProps(_TCHAR* eeFile, _TCHAR** msg); |
344 |
static int vmEEProps(_TCHAR* eeFile, _TCHAR** msg); |
Lines 422-429
Link Here
|
422 |
exit( 1 ); |
430 |
exit( 1 ); |
423 |
} |
431 |
} |
424 |
|
432 |
|
425 |
/* platform specific processing of user's vmargs */ |
433 |
if (vmArgs != NULL) { |
426 |
processVMArgs(&vmArgs); |
434 |
/* reconcile VM Args from commandline with launcher.ini (append or override) */ |
|
|
435 |
mergeUserVMArgs(&vmArgs); |
436 |
/* platform specific processing of user's vmargs */ |
437 |
processVMArgs(&vmArgs); |
438 |
} |
427 |
launchMode = determineVM(&msg); |
439 |
launchMode = determineVM(&msg); |
428 |
if (launchMode == -1) { |
440 |
if (launchMode == -1) { |
429 |
/* problem */ |
441 |
/* problem */ |
Lines 720-726
Link Here
|
720 |
/* If the option requires a value and there is one, extract the value. */ |
732 |
/* If the option requires a value and there is one, extract the value. */ |
721 |
if (option->value != NULL) { |
733 |
if (option->value != NULL) { |
722 |
if (option->flag & VALUE_IS_FLAG) |
734 |
if (option->flag & VALUE_IS_FLAG) |
723 |
*((int *) option->value) = 1; |
735 |
*((int *) option->value) = (option->flag & INVERT_FLAG) ? 0 : 1; |
724 |
else { |
736 |
else { |
725 |
int count = 1; |
737 |
int count = 1; |
726 |
if (option->flag & VALUE_IS_LIST) { |
738 |
if (option->flag & VALUE_IS_LIST) { |
Lines 796-815
Link Here
|
796 |
return execArg; |
808 |
return execArg; |
797 |
} |
809 |
} |
798 |
|
810 |
|
|
|
811 |
/* Return the list of args from the launcher ini file (if it exists). Caller is responsible to free(). */ |
812 |
static _TCHAR** getConfigArgs() { |
813 |
_TCHAR* iniFile = NULL; |
814 |
_TCHAR** configArgv = NULL; |
815 |
int configArgc = 0; |
816 |
int ret = 0; |
817 |
int iniArg; |
818 |
|
819 |
/* Parse configuration file arguments */ |
820 |
iniArg = indexOf(INI, initialArgv); |
821 |
if (iniArg > 0) { |
822 |
iniFile = initialArgv[iniArg + 1]; |
823 |
ret = readConfigFile(iniFile, &configArgc, &configArgv); |
824 |
} else { |
825 |
ret = readIniFile(program, &configArgc, &configArgv); |
826 |
} |
827 |
if (ret == 0) { |
828 |
return configArgv; |
829 |
} |
830 |
return NULL; |
831 |
} |
832 |
|
833 |
/** Append Commandline VM Args to VM Args that came from the launcher.ini */ |
834 |
static void mergeUserVMArgs( _TCHAR **vmArgs[] ) { |
835 |
if (appendVmargs != 0 && indexOf(VMARGS, initialArgv) > 0) { |
836 |
/* Get vmargs from the launcher.ini, if any */ |
837 |
_TCHAR** configArgs = getConfigArgs(); |
838 |
if (configArgs != NULL) { |
839 |
int vmArg = indexOf(VMARGS, configArgs); |
840 |
if (vmArg >= 0) { |
841 |
_TCHAR** configVMArgs = configArgs + vmArg + 1; |
842 |
if (configVMArgs != NULL) { |
843 |
*vmArgv = concatArgs(configVMArgs, *vmArgv); |
844 |
} |
845 |
} |
846 |
free(configArgs); |
847 |
} |
848 |
/* else, no merge is necessary (there was only commandline vmargs) */ |
849 |
} |
850 |
} |
851 |
|
799 |
static void adjustVMArgs( _TCHAR *javaVM, _TCHAR *jniLib, _TCHAR **vmArgv[] ) { |
852 |
static void adjustVMArgs( _TCHAR *javaVM, _TCHAR *jniLib, _TCHAR **vmArgv[] ) { |
800 |
/* Sun VMs need some extra perm gen space */ |
853 |
/* Sun VMs need some extra perm gen space */ |
801 |
if (permGen != NULL && isSunVM(javaVM, jniLib)) { |
854 |
/* Detecting Sun VM is expensive - only do so if necessary */ |
|
|
855 |
if (permGen != NULL) { |
802 |
int specified = 0, i = -1; |
856 |
int specified = 0, i = -1; |
803 |
|
857 |
|
804 |
/* first check to see if it is already specified */ |
858 |
/* first check to see if it is already specified */ |
805 |
while ( (*vmArgv)[++i] != NULL) { |
859 |
while ((*vmArgv)[++i] != NULL) { |
806 |
/* we are also counting the number of args here */ |
860 |
/* we are also counting the number of args here */ |
807 |
if (!specified && _tcsncmp((*vmArgv)[i], XXPERMGEN, _tcslen(XXPERMGEN)) == 0) { |
861 |
if (!specified && _tcsncmp((*vmArgv)[i], XXPERMGEN, _tcslen(XXPERMGEN)) == 0) { |
808 |
specified = 1; |
862 |
specified = 1; |
809 |
} |
863 |
} |
810 |
} |
864 |
} |
811 |
|
865 |
|
812 |
if (!specified) { |
866 |
if (!specified && isSunVM(javaVM, jniLib)) { |
813 |
_TCHAR ** oldArgs = *vmArgv; |
867 |
_TCHAR ** oldArgs = *vmArgv; |
814 |
_TCHAR *newArg = malloc((_tcslen(XXPERMGEN) + _tcslen(permGen) + 1) * sizeof(_TCHAR)); |
868 |
_TCHAR *newArg = malloc((_tcslen(XXPERMGEN) + _tcslen(permGen) + 1) * sizeof(_TCHAR)); |
815 |
_stprintf(newArg, _T_ECLIPSE("%s%s"), XXPERMGEN, permGen); |
869 |
_stprintf(newArg, _T_ECLIPSE("%s%s"), XXPERMGEN, permGen); |