From 86076bcc67adc0d62991d6c83507452a6280144b Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Wed, 2 Oct 2024 18:31:47 +0200 Subject: [PATCH 1/8] Add support for specifying additional JVM arguments --- .../library/eclipse.c | 30 +++++++++++++-- .../library/eclipseCommon.c | 38 +++++++++++++++++++ .../library/eclipseCommon.h | 9 +++++ 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipse.c b/features/org.eclipse.equinox.executable.feature/library/eclipse.c index 9f826c09f23..d5574f8c1a9 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipse.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipse.c @@ -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; @@ -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 }, @@ -307,7 +309,8 @@ static Option options[] = { { DEFAULTACTION,&defaultAction, 0, 2 }, { WS, &wsArg, 0, 2 }, { GTK_VERSION, >kVersionString, 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])); @@ -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; @@ -996,15 +1001,32 @@ 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() { + 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[]) { diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c b/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c index 9da16644ff7..e301c7adb26 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.c @@ -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); diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.h b/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.h index 6c8cd2f8775..55938e71278 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.h +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseCommon.h @@ -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") #define XXPERMGEN _T_ECLIPSE("-XX:MaxPermSize=") #define ADDMODULES _T_ECLIPSE("--add-modules") @@ -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); From 72180682143cfc508b74f9f678bfd2679622d9f5 Mon Sep 17 00:00:00 2001 From: ShadelessFox <35821147+ShadelessFox@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:47:46 +0300 Subject: [PATCH 2/8] Add macOS ARM build; disable redundant workflows --- .github/workflows/build.yml | 75 +++++++------------------------------ 1 file changed, 14 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index edc492898bb..f3e40c7d8e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_dispatch: jobs: build: @@ -15,10 +16,11 @@ jobs: 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-latest, 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 @@ -43,7 +45,7 @@ jobs: mvn-toolchain-id: | JavaSE-1.8 JavaSE-17 - distribution: 'temurin' + distribution: 'liberica' cache: maven - name: Set up Maven uses: stCarolas/setup-maven@v5 @@ -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 }} From 97d186fd249f94e0840e801ac4d92b4e93a6363b Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Wed, 9 Oct 2024 12:34:00 +0200 Subject: [PATCH 3/8] Enable Control Flow Guard --- .../library/win32/make_win64.mak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/org.eclipse.equinox.executable.feature/library/win32/make_win64.mak b/features/org.eclipse.equinox.executable.feature/library/win32/make_win64.mak index cdeca6776b5..2554307d09f 100644 --- a/features/org.eclipse.equinox.executable.feature/library/win32/make_win64.mak +++ b/features/org.eclipse.equinox.executable.feature/library/win32/make_win64.mak @@ -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 From 558ee04b287f24517d16f3abaa78c61822f80ce4 Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Wed, 16 Oct 2024 18:26:09 +0200 Subject: [PATCH 4/8] Ensure the argument is actually present --- .../org.eclipse.equinox.executable.feature/library/eclipse.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipse.c b/features/org.eclipse.equinox.executable.feature/library/eclipse.c index d5574f8c1a9..a68868557b1 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipse.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipse.c @@ -1005,6 +1005,10 @@ static _TCHAR** extractVMArgs(_TCHAR** launcherIniValues) { * 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; From 6492f95d0b1d60465d29256f2c5a434dde813b3e Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Wed, 16 Oct 2024 18:47:22 +0200 Subject: [PATCH 5/8] Accept additional suffixes for console launcher --- .../library/eclipseConfig.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c b/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c index ebd6abaf377..5bbfe4fa97b 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c @@ -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; + } } } } From 77eb00b5e4465f9d6123f4876a46645fe5829274 Mon Sep 17 00:00:00 2001 From: ShadelessFox <35821147+ShadelessFox@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:02:07 +0300 Subject: [PATCH 6/8] Use ubuntu-20.04 runner --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3e40c7d8e6..e669ddf2000 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: config: - - { name: Linux, runner-os: ubuntu-latest, ws: gtk, os: linux, arch: x86_64, native-extension: so } + - { 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 } From 52c653e50c13ae0f3a826836cec38ba3d714aa3d Mon Sep 17 00:00:00 2001 From: ShadelessFox <35821147+ShadelessFox@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:08:18 +0300 Subject: [PATCH 7/8] Use dbeaver/setup-maven@v5 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e669ddf2000..6c9f262148f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: distribution: 'liberica' cache: maven - name: Set up Maven - uses: stCarolas/setup-maven@v5 + uses: dbeaver/setup-maven@v5 with: maven-version: 3.9.9 - name: Install GTK requirements From 6335a7695435df461446c0efb63463a3c2ec6627 Mon Sep 17 00:00:00 2001 From: ShadelessFox <35821147+ShadelessFox@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:51:20 +0100 Subject: [PATCH 8/8] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c9f262148f..eb5133ef6fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: distribution: 'liberica' cache: maven - name: Set up Maven - uses: dbeaver/setup-maven@v5 + uses: dbeaver/setup-maven@master with: maven-version: 3.9.9 - name: Install GTK requirements