From 95b6f459ca0e9c2a687c3443b29494a406b9f8d1 Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Sat, 14 Sep 2024 09:15:05 +0500 Subject: [PATCH 1/5] switch to my own vmone fork and enable window action runner --- .github/workflows/build.yml | 32 +-- gradlew.bat | 200 +++++++++--------- .../java/com/gluonhq/substrate/Constants.java | 2 +- .../com/gluonhq/substrate/util/FileDeps.java | 2 +- 4 files changed, 118 insertions(+), 118 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78710995e..563d9e155 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Substrate Build on: push: branches: - - master + - '*' pull_request: branches: - master @@ -14,14 +14,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] # windows-latest] + os: [ubuntu-latest, macos-latest, windows-latest] include: - os: ubuntu-latest ARCH: "x86_64" - os: macos-latest ARCH: "aarch64" -# - os: windows-latest -# ARCH: "x86_64" + - os: windows-latest + ARCH: "x86_64" steps: - name: Install packages (Linux) if: runner.os == 'Linux' @@ -83,16 +83,16 @@ jobs: - name: Build project run: ./gradlew -i build -x test - - name: Deploy Snapshot - if: runner.os == 'Linux' && github.ref == 'refs/heads/master' - run: ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + # - name: Deploy Snapshot + # if: runner.os == 'Linux' && github.ref == 'refs/heads/master' + # run: ./gradlew publish -PsonatypeUsername=$SONATYPE_USERNAME -PsonatypePassword=$SONATYPE_PASSWORD + # env: + # SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + # SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - - name: Draft release - if: runner.os == 'Linux' && github.ref == 'refs/heads/master' - # Drafts your next Release notes as Pull Requests are merged into "master" - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Draft release + # if: runner.os == 'Linux' && github.ref == 'refs/heads/master' + # # Drafts your next Release notes as Pull Requests are merged into "master" + # uses: release-drafter/release-drafter@v5 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gradlew.bat b/gradlew.bat index 15e1ee37a..9991c5032 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem http://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/com/gluonhq/substrate/Constants.java b/src/main/java/com/gluonhq/substrate/Constants.java index ee55e4156..ba0af612b 100644 --- a/src/main/java/com/gluonhq/substrate/Constants.java +++ b/src/main/java/com/gluonhq/substrate/Constants.java @@ -134,7 +134,7 @@ public static VMONE_TARGET fromTriplet(String triplet) { public static final String PROFILE_LINUX_AARCH64 = "linux-aarch64"; public static final String PROFILE_WEB = "web"; - public static final String DEFAULT_JAVA_STATIC_SDK_VERSION = "24-2"; + public static final String DEFAULT_JAVA_STATIC_SDK_VERSION = "24-3"; public static final String DEFAULT_JAVAFX_STATIC_SDK_VERSION = "24-ea+7.1"; public static final String DEFAULT_JAVAFX_JS_SDK_VERSION = "18-internal+0-2021-09-02-165800"; public static final String DEFAULT_SYSROOT_VERSION = "20210424"; diff --git a/src/main/java/com/gluonhq/substrate/util/FileDeps.java b/src/main/java/com/gluonhq/substrate/util/FileDeps.java index e2ec612a5..8956a5347 100644 --- a/src/main/java/com/gluonhq/substrate/util/FileDeps.java +++ b/src/main/java/com/gluonhq/substrate/util/FileDeps.java @@ -49,7 +49,7 @@ public final class FileDeps { private static final String JAVA_STATIC_ZIP = "gvm-${version}/vmone-${target}.zip"; - private static final String JAVA_STATIC_URL = "https://github.com/gluonhq/vmone/releases/download/"; + private static final String JAVA_STATIC_URL = "https://github.com/ctoabidmaqbool/vmone-fork/releases/download/"; private static final String JAVAFX_STATIC_ZIP = "openjfx-${version}-${target}-static${variant}.zip"; private static final String JAVAFX_STATIC_URL = "https://download2.gluonhq.com/substrate/javafxstaticsdk/"; From 11e4eea4bece9c1c35d1179899baefb7191558a5 Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Sat, 14 Sep 2024 22:07:10 +0500 Subject: [PATCH 2/5] Switch to my latest vmone e.g. 24-4; --- src/main/java/com/gluonhq/substrate/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gluonhq/substrate/Constants.java b/src/main/java/com/gluonhq/substrate/Constants.java index ba0af612b..fc308492a 100644 --- a/src/main/java/com/gluonhq/substrate/Constants.java +++ b/src/main/java/com/gluonhq/substrate/Constants.java @@ -134,7 +134,7 @@ public static VMONE_TARGET fromTriplet(String triplet) { public static final String PROFILE_LINUX_AARCH64 = "linux-aarch64"; public static final String PROFILE_WEB = "web"; - public static final String DEFAULT_JAVA_STATIC_SDK_VERSION = "24-3"; + public static final String DEFAULT_JAVA_STATIC_SDK_VERSION = "24-4"; public static final String DEFAULT_JAVAFX_STATIC_SDK_VERSION = "24-ea+7.1"; public static final String DEFAULT_JAVAFX_JS_SDK_VERSION = "18-internal+0-2021-09-02-165800"; public static final String DEFAULT_SYSROOT_VERSION = "20210424"; From 24f2b05d7d7b077622b7b115a2a605222a504d9f Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Thu, 19 Sep 2024 03:34:20 +0500 Subject: [PATCH 3/5] Partial implement run-tests.bat, linux alternative is too not working fine! --- run-tests.bat | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 run-tests.bat diff --git a/run-tests.bat b/run-tests.bat new file mode 100644 index 000000000..9b7e1383e --- /dev/null +++ b/run-tests.bat @@ -0,0 +1,103 @@ +@echo off + +rem Removing 'out' directory +rmdir /S /Q out + +set JAVAFX_PLATFORM=win +set JAVAFX_VERSION=13.0.1 + +set JAVAFX_STATIC_PLATFORM=win-x86_64 +set JAVAFX_STATIC_VERSION=14-ea+gvm1 + +echo Downloading JavaFX %JAVAFX_VERSION%-%JAVAFX_PLATFORM% jars... +mkdir libs\javafx +for %%j in (base controls graphics) do ( + if not exist libs\javafx\javafx-%%j-%JAVAFX_VERSION%-%JAVAFX_PLATFORM%.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.openjfx:javafx-%%j:%JAVAFX_VERSION%:jar:%JAVAFX_PLATFORM% + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.openjfx:javafx-%%j:%JAVAFX_VERSION%:jar:%JAVAFX_PLATFORM% -DoutputDirectory=libs\javafx + ) +) +echo Downloading JavaFX jars completed! + +echo Downloading JavaFX static SDK %JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%... +mkdir libs\javafxstatic +if not exist libs\javafxstatic\openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip ( + powershell -Command "Invoke-WebRequest -OutFile libs\javafxstatic\openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip https://download2.gluonhq.com/substrate/javafxstaticsdk/openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip" + tar -xf libs\javafxstatic\openjfx-%JAVAFX_STATIC_VERSION%-%JAVAFX_STATIC_PLATFORM%-static.zip -C libs\javafxstatic +) +echo Downloading JavaFX static SDK completed! + +echo Downloading substrate dependencies... +mkdir libs\substrate +if not exist libs\substrate\dd-plist-1.22.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=com.googlecode.plist:dd-plist:1.22 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=com.googlecode.plist:dd-plist:1.22 -DoutputDirectory=libs\substrate +) +if not exist libs\substrate\jnr-ffi-2.1.11.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=com.github.jnr:jnr-ffi:2.1.11 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=com.github.jnr:jnr-ffi:2.1.11 -DoutputDirectory=libs\substrate +) +if not exist libs\substrate\bcpkix-jdk15on-1.49.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.bouncycastle:bcpkix-jdk15on:1.49 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.bouncycastle:bcpkix-jdk15on:1.49 -DoutputDirectory=libs\substrate +) +if not exist libs\substrate\bcprov-jdk15on-1.49.jar ( + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=org.bouncycastle:bcprov-jdk15on:1.49 + mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy -Dartifact=org.bouncycastle:bcprov-jdk15on:1.49 -DoutputDirectory=libs\substrate +) +echo Downloading substrate dependencies completed! + +echo Compiling substrate... +set SUBSTRATE_SOURCES= +for /r %%f in (src\main\java\*.java) do ( + set SUBSTRATE_SOURCES=!SUBSTRATE_SOURCES! %%f +) + +set SUBSTRATE_MODULE_PATH= +for /r %%f in (libs\substrate\*.jar) do ( + if "%SUBSTRATE_MODULE_PATH%"=="" ( + set SUBSTRATE_MODULE_PATH=%%f + ) else ( + set SUBSTRATE_MODULE_PATH=%%f;%SUBSTRATE_MODULE_PATH% + ) +) +javac -source 11 -target 11 -d out\substrate -g -proc:none -XDuseUnsharedTable=true --module-path %SUBSTRATE_MODULE_PATH% %SUBSTRATE_SOURCES% +echo Substrate compilation done! + +echo Compiling test HelloWorld... +set TEST_HELLOWORLD_SOURCES= +for /r %%f in (test-project\helloWorld\src\main\java\*.java) do ( + set TEST_HELLOWORLD_SOURCES=!TEST_HELLOWORLD_SOURCES! %%f +) +javac -source 11 -target 11 -d out\helloWorld -g -proc:none -XDuseUnsharedTable=true %TEST_HELLOWORLD_SOURCES% +echo Test HelloWorld compilation done! + +echo Running test HelloWorld... +java -classpath %SUBSTRATE_MODULE_PATH%;out\substrate;src\main\resources ^ + -Dimagecp="%cd%\out\helloWorld" ^ + -Dgraalvm=%GRAALVM_HOME% ^ + -Dmainclass=com.gluonhq.substrate.test.Main ^ + com.gluonhq.substrate.SubstrateDispatcher +echo Test HelloWorld completed + +echo Compiling test HelloFX... +set TEST_HELLOFX_SOURCES= +for /r %%f in (test-project\helloFX\src\main\java\*.java) do ( + set TEST_HELLOFX_SOURCES=!TEST_HELLOFX_SOURCES! %%f +) +set TEST_HELLOFX_MODULE_PATH= +for /r %%f in (libs\javafx\*.jar) do ( + set TEST_HELLOFX_MODULE_PATH=!cd!\%%f;%TEST_HELLOFX_MODULE_PATH% +) +javac -source 11 -target 11 -d out\helloFX -g -proc:none -XDuseUnsharedTable=true --module-path %TEST_HELLOFX_MODULE_PATH% --add-modules javafx.controls %TEST_HELLOFX_SOURCES% +echo Test HelloFX compilation done! + +echo Running test HelloFX... +java -classpath %SUBSTRATE_MODULE_PATH%;out\substrate;src\main\resources ^ + -Dimagecp="%cd%\out\helloFX;%TEST_HELLOFX_MODULE_PATH%" ^ + -Dgraalvm=%GRAALVM_HOME% ^ + -Dmainclass=com.gluonhq.substrate.test.Main ^ + -Djavafxsdk=libs\javafxstatic\sdk ^ + -Dprism.sw=true ^ + com.gluonhq.substrate.SubstrateDispatcher +echo Test HelloFX completed From d99663a17cde954913b5da647ce6ed79b83001d1 Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Thu, 19 Sep 2024 03:57:13 +0500 Subject: [PATCH 4/5] Revert, at native compile, show warning, As it's in progress! --- .../substrate/target/WindowsTargetConfiguration.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java index f9e585cb8..61b1a274a 100644 --- a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java @@ -205,12 +205,6 @@ private List asListOfWholeArchiveLinkFlags(List libraries) { return linkFlags; } - @Override - public boolean compile() throws IOException, InterruptedException { - Logger.logSevere("Error: Building a native image is not yet supported on Windows with this version.\nPlease use GluonFX plugin version 1.0.23 instead."); - return false; - } - @Override public boolean link() throws IOException, InterruptedException { createIconResource(); From 886f29b31692f028fbf9f1c07a3701bccc09359a Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Thu, 19 Sep 2024 23:33:30 +0500 Subject: [PATCH 5/5] Adding java native Windows Libs which was mistakenly removed in git commit e.g. f93489a4e6706552c8aeebb9482e2cbbc03f9a37 Removed glass.lib and prism_d3d.lib which was conflicting with vmone.lib --- .../target/WindowsTargetConfiguration.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java index 61b1a274a..d8eec766b 100644 --- a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java @@ -46,12 +46,19 @@ public class WindowsTargetConfiguration extends AbstractTargetConfiguration { + private static final List javaWindowsLibs = List.of( + "advapi32", "iphlpapi", "secur32", "userenv", + "version", "ws2_32", "winhttp", "ncrypt", + "crypt32", "mswsock", + "shlwapi", "comctl32" + ); + private static final List javaFxWindowsLibs = List.of( "comdlg32", "dwmapi", "gdi32", "imm32", "shell32", "uiautomationcore", "urlmon", "winmm"); private static final List staticJavaFxLibs = List.of( - "glass", "javafx_font", "javafx_iio", - "prism_common", "prism_d3d"); + "javafx_font", "javafx_iio", + "prism_common"); private static final List staticJavaFxSwLibs = List.of( "prism_sw"); @@ -128,6 +135,11 @@ String getLinkOutputName() { return appName + (projectConfiguration.isSharedLibrary() ? ".dll" : ".exe"); } + @Override + List getOtherStaticLibs() { + return javaWindowsLibs; + } + @Override List getTargetSpecificNativeLibsFlags(Path libPath, List libs) { List linkFlags = new ArrayList<>();