Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/dbeaver#35080 Add support for specifying additional JVM arguments #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 15 additions & 62 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- { name: Linux, runner-os: ubuntu-latest, ws: gtk, os: linux, native-extension: so }
- { name: Windows, runner-os: windows-2019, ws: win32, os: win32, native-extension: dll }
- { name: MacOS, runner-os: macos-13, ws: cocoa, os: macosx, native-extension: so }
name: Build ${{ matrix.config.name }}
- { name: Linux, runner-os: ubuntu-20.04, ws: gtk, os: linux, arch: x86_64, native-extension: so }
- { name: Windows, runner-os: windows-2019, ws: win32, os: win32, arch: x86_64, native-extension: dll }
- { name: macOS, runner-os: macos-13, ws: cocoa, os: macosx, arch: x86_64, native-extension: so }
- { name: macOS, runner-os: macos-14, ws: cocoa, os: macosx, arch: aarch64, native-extension: so }
name: Build ${{ matrix.config.name }} ${{ matrix.config.arch }}
runs-on: ${{ matrix.config.runner-os }}
defaults:
run: # Run on cmd on Windows because powershell interprets dots in arguments differently
Expand All @@ -43,10 +45,10 @@ jobs:
mvn-toolchain-id: |
JavaSE-1.8
JavaSE-17
distribution: 'temurin'
distribution: 'liberica'
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
uses: dbeaver/setup-maven@master
with:
maven-version: 3.9.9
- name: Install GTK requirements
Expand All @@ -63,72 +65,23 @@ jobs:
--batch-mode
-Pbree-libs
-Papi-check
-Dcompare-version-with-baselines.skip=false
-Dcompare-version-with-baselines.skip=true
-Dmaven.test.failure.ignore=true
-Dnative=${{ matrix.config.ws }}.${{ matrix.config.os }}.x86_64
-Dnative=${{ matrix.config.ws }}.${{ matrix.config.os }}.${{ matrix.config.arch }}
-Dequinox.binaries.loc=${{ github.workspace }}/equinox.binaries
clean verify
- name: Upload native artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: ${{ matrix.config.name }} launcher artifacts
name: ${{ matrix.config.name }} ${{ matrix.config.arch }} launcher artifacts
path: |
equinox.binaries/org.eclipse.equinox.executable/bin/${{ matrix.config.ws }}/${{ matrix.config.os }}/x86_64/**/eclipse*
equinox.binaries/org.eclipse.equinox.launcher.${{ matrix.config.ws }}.${{ matrix.config.os }}.x86_64/eclipse_*.${{ matrix.config.native-extension }}
equinox.binaries/org.eclipse.equinox.executable/bin/${{ matrix.config.ws }}/${{ matrix.config.os }}/${{ matrix.config.arch }}/**/eclipse*
equinox.binaries/org.eclipse.equinox.launcher.${{ matrix.config.ws }}.${{ matrix.config.os }}.${{ matrix.config.arch }}/eclipse_*.${{ matrix.config.native-extension }}
if-no-files-found: error
- name: Upload ${{ matrix.config.name }} Test Results
- name: Upload ${{ matrix.config.name }} ${{ matrix.config.arch }} Test Results
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.config.name }}64
name: test-results-${{ matrix.config.name }}${{ matrix.config.arch }}
if-no-files-found: error
path: '**/target/*-reports/*.xml'

tck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: |
8
17
mvn-toolchain-id: |
JavaSE-1.8
JavaSE-17
distribution: 'temurin'
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
- name: Run OSGi TCKs
run: >-
mvn
-U
--batch-mode
--threads 1C
-Pbuild-individual-bundles
-Pbree-libs
-Ptck
-Dskip-default-modules=true
-Dtycho.resolver.classic=false
-fn
clean verify
- name: Upload TCK Results
uses: actions/upload-artifact@v4
if: always()
with:
name: tck-results
if-no-files-found: error
path: '**/target/tck-results/TEST-*.xml'
event_file:
name: "Upload Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
34 changes: 30 additions & 4 deletions features/org.eclipse.equinox.executable.feature/library/eclipse.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ static _TCHAR* defaultAction = NULL; /* default action for non '-' command li
static _TCHAR* iniFile = NULL; /* the launcher.ini file set if --launcher.ini was specified */
static _TCHAR* gtkVersionString = NULL; /* GTK+ version specified by --launcher.GTK_version */
static _TCHAR* protectMode = NULL; /* Process protectMode specified via -protect, to trigger the reading of eclipse.ini in the configuration (Mac specific currently) */
static _TCHAR** additionalVmargsPath = NULL; /* List of locations of files with extra vmargs that have higher priority over other vmargs */

/* variables for ee options */
static _TCHAR* eeExecutable = NULL;
Expand All @@ -282,6 +283,7 @@ typedef struct
#define ADJUST_PATH 4 /* value is a path, do processing on relative paths to try and make them absolute */
#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 */
#define INVERT_FLAG 16 /* invert the meaning of a flag, i.e. reset it */
#define EXPAND_PATH 32 /* value is a path, expands patterns like %name% with environment-variable strings */

static Option options[] = {
{ CONSOLE, &needConsole, VALUE_IS_FLAG, 0 },
Expand All @@ -307,7 +309,8 @@ static Option options[] = {
{ DEFAULTACTION,&defaultAction, 0, 2 },
{ WS, &wsArg, 0, 2 },
{ GTK_VERSION, &gtkVersionString, 0, 2 },
{ PROTECT, &protectMode, 0, 2 } };
{ PROTECT, &protectMode, 0, 2 },
{ ADDITIONAL_VMARGS, &additionalVmargsPath, ADJUST_PATH | EXPAND_PATH | VALUE_IS_LIST, -1 } };

static int optionsSize = (sizeof(options) / sizeof(options[0]));

Expand Down Expand Up @@ -864,6 +867,8 @@ static void parseArgs(int* pArgc, _TCHAR* argv[]) {
_TCHAR * next = argv[index + i + 1];
if (option->flag & ADJUST_PATH)
next = checkPath(next, getProgramDir(), 0);
if (option->flag & EXPAND_PATH)
next = expandPath(next);
if (next[0] != _T_ECLIPSE('-')) {
if (option->flag & VALUE_IS_LIST)
(*((_TCHAR***) option->value))[i] = next;
Expand Down Expand Up @@ -996,15 +1001,36 @@ static _TCHAR** extractVMArgs(_TCHAR** launcherIniValues) {
return NULL;
}

/** Attempts to read the first configuration file
* If the file is not found, it will try the next one in the list
* Returns the arguments read from the file or NULL if no file was found */
static _TCHAR** getAdditionalVMArgs() {
if (additionalVmargsPath == NULL) {
return NULL;
}

int argc = 0;
_TCHAR** argv = NULL;

for (_TCHAR** path = additionalVmargsPath; *path; path++) {
if (readConfigFile(*path, &argc, &argv) == 0) {
break;
}
}

return argv;
}

//Reads the installation eclipse.ini file, reads a eclipse.ini from the configuration location,
//and merge the VM arguments
static _TCHAR** mergeConfigurationFilesVMArgs() {
_TCHAR** userLauncherIniVMArgs = extractVMArgs(getLauncherIniFileFromConfiguration());
_TCHAR** configVMArgs = extractVMArgs(getConfigArgs());
_TCHAR** additionalVMArgs = getAdditionalVMArgs();

/* This always allocates new memory so we don't need to guess if it is safe
* to free later */
return concatArgs(configVMArgs, userLauncherIniVMArgs);
/* This always allocates new memory so we don't need to guess if it is safe
* to free later */
return concatArgs(concatArgs(configVMArgs, userLauncherIniVMArgs), additionalVMArgs);
}

static void adjustVMArgs(_TCHAR *javaVM, _TCHAR *jniLib, _TCHAR **vmArgv[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,44 @@ _TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder )
return result != NULL ? result : path;
}

_TCHAR* expandPath(_TCHAR* inPath) {
_TCHAR buffer[MAX_PATH_LENGTH];
_TCHAR variable[MAX_PATH_LENGTH];

_TCHAR* dstCur = &buffer[0];
_TCHAR* srcCur = &inPath[0];

for(;;) {
_TCHAR* start = _tcschr(srcCur, _T_ECLIPSE('%'));
if (start == NULL) {
// No more variables
_tcscpy(dstCur, srcCur);
return _tcsdup(buffer);
}
_TCHAR* end = _tcschr(start + 1, _T_ECLIPSE('%'));
if (end == NULL) {
// Not a variable
*dstCur++ = *srcCur++;
continue;
}
_tcsncpy(variable, start + 1, end - start);
variable[end - start - 1] = _T_ECLIPSE('\0');
_TCHAR* value = _tgetenv(variable);
if (value != NULL) {
// Found a variable
_tcsncpy(dstCur, srcCur, start - srcCur);
dstCur += start - srcCur;
_tcscpy(dstCur, value);
dstCur += _tcslen(value);
} else {
// Variable is not found
_tcsncpy(dstCur, srcCur, end - srcCur + 1);
dstCur += end - srcCur + 1;
}
srcCur = end + 1;
}
}

_TCHAR * lastDirSeparator(_TCHAR* str) {
#ifndef _WIN32
return _tcsrchr(str, dirSeparator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define OLD_ARGS_START _T_ECLIPSE("--launcher.oldUserArgsStart")
#define OLD_ARGS_END _T_ECLIPSE("--launcher.oldUserArgsEnd")
#define SKIP_OLD_ARGS _T_ECLIPSE("--launcher.skipOldUserArgs")
#define ADDITIONAL_VMARGS _T_ECLIPSE("--launcher.additionalVmargs")
ShadelessFox marked this conversation as resolved.
Show resolved Hide resolved

#define XXPERMGEN _T_ECLIPSE("-XX:MaxPermSize=")
#define ADDMODULES _T_ECLIPSE("--add-modules")
Expand Down Expand Up @@ -153,6 +154,14 @@ extern void * findSymbol( void * handle, _TCHAR * symbol );
/* check the given path and attempt to make it absolute if it is relative */
extern _TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder );

/**
* Expands environment-variable strings and replaces
* them with the values defined for the current user.
*
* Regardless of the platform, the same syntax is used: %VariableName%.
*/
extern _TCHAR* expandPath(_TCHAR* path);

extern _TCHAR * lastDirSeparator(_TCHAR* str);

extern _TCHAR * firstDirSeparator(_TCHAR* str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,21 @@ _TCHAR* getIniFile(_TCHAR* program, int consoleLauncher){
extension = config_file + _tcslen(config_file);
}
_tcscpy(extension, _T_ECLIPSE(".ini"));
if(consoleLauncher){
struct _stat stats;
if(consoleLauncher && _tstat(config_file, &stats) != 0){
/* We are the console version, if the ini file does not exist, try
* removing the 'c' from the end of the program name */
struct _stat stats;
if (_tstat( config_file, &stats ) != 0 && *(extension - 1) == _T('c')) {
_tcscpy(extension - 1, extension);
* removing the suffix from the end of the program name */
static const _TCHAR* consoleLauncherSuffixes[] = {
_T_ECLIPSE("c"), // eclipsec.exe
_T_ECLIPSE("-cli"), // eclipse-cli.exe
NULL
};
for (const _TCHAR** suffix = consoleLauncherSuffixes; *suffix; suffix++) {
size_t suffixLen = _tcslen(*suffix);
if (_tcsncmp(extension - suffixLen, *suffix, suffixLen) == 0) {
_tcscpy(extension - suffixLen, extension);
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ LIBS = kernel32.lib user32.lib comctl32.lib libcmt.lib \
libvcruntime.lib libucrt.lib ole32.lib windowscodecs.lib
DLL_LIBS = kernel32.lib user32.lib comctl32.lib gdi32.lib Advapi32.lib libcmt.lib version.lib \
libvcruntime.lib libucrt.lib ole32.lib windowscodecs.lib
LFLAGS = /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO -subsystem:windows -entry:wmainCRTStartup
CONSOLEFLAGS = /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO -subsystem:console -entry:wmainCRTStartup
LFLAGS = /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA /NODEFAULTLIB /INCREMENTAL:NO /GUARD:CF /RELEASE /NOLOGO -subsystem:windows -entry:wmainCRTStartup
CONSOLEFLAGS = /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA /NODEFAULTLIB /INCREMENTAL:NO /GUARD:CF /RELEASE /NOLOGO -subsystem:console -entry:wmainCRTStartup
#DLL_LFLAGS = /NODEFAULTLIB /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO -entry:_DllMainCRTStartup@12 -dll /BASE:0x72000000 /DLL
DLL_LFLAGS = /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA /NODEFAULTLIB /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO -dll /BASE:0x140000000 /DLL
DLL_LFLAGS = /DYNAMICBASE /NXCOMPAT /HIGHENTROPYVA /NODEFAULTLIB /INCREMENTAL:NO /GUARD:CF /PDB:NONE /RELEASE /NOLOGO -dll /BASE:0x140000000 /DLL
RES = $(PROGRAM_NAME).res
EXEC = $(PROGRAM_OUTPUT)
CONSOLE = $(PROGRAM_NAME)c.exe
Expand Down
Loading