From 95b6f459ca0e9c2a687c3443b29494a406b9f8d1 Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Sat, 14 Sep 2024 09:15:05 +0500 Subject: [PATCH 1/7] 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/7] 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/7] 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/7] 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/7] 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<>(); From 15f1d50bb006294cab690aa3aedb74c381d2e1a6 Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Sun, 9 Mar 2025 15:55:44 +0500 Subject: [PATCH 6/7] Apply dos2unix automatically; --- .../target/AndroidTargetConfiguration.java | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java index f6c2744a5..7ddf66843 100644 --- a/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java @@ -97,7 +97,7 @@ public class AndroidTargetConfiguration extends PosixTargetConfiguration { private final String capLocation = ANDROID_NATIVE_FOLDER + "cap/"; public AndroidTargetConfiguration(ProcessPaths paths, InternalProjectConfiguration configuration) throws IOException { - super(paths,configuration); + super(paths, configuration); this.sdk = fileDeps.getAndroidSDKPath().toString(); this.ndk = fileDeps.getAndroidNDKPath().toString(); @@ -152,17 +152,17 @@ public boolean packageApp() throws IOException, InterruptedException { fileDeps.checkAndroidPackages(sdk); // create apk for installing on device ProcessRunner assembleRunner = new ProcessRunner( - getAndroidProjectPath().resolve("gradlew").toString(), - "-p", getAndroidProjectPath().toString(), - "assemble" + configuration); + getAndroidProjectPath().resolve("gradlew").toString(), + "-p", getAndroidProjectPath().toString(), + "assemble" + configuration); assembleRunner.addToEnv("ANDROID_HOME", sdk); if (assembleRunner.runProcess("package-task") != 0) { return false; } Path generatedApk = getAndroidProjectPath().resolve("app").resolve("build") - .resolve("outputs").resolve("apk").resolve(configuration.toLowerCase(Locale.ROOT)) - .resolve("app-"+configuration.toLowerCase(Locale.ROOT)+".apk"); - Path targetApk = paths.getGvmPath().resolve(projectConfiguration.getAppName()+".apk"); + .resolve("outputs").resolve("apk").resolve(configuration.toLowerCase(Locale.ROOT)) + .resolve("app-" + configuration.toLowerCase(Locale.ROOT) + ".apk"); + Path targetApk = paths.getGvmPath().resolve(projectConfiguration.getAppName() + ".apk"); if (Files.exists(generatedApk)) { FileOps.copyFile(generatedApk, targetApk); } @@ -178,8 +178,8 @@ public boolean packageApp() throws IOException, InterruptedException { } Path generatedAAB = getAndroidProjectPath().resolve("app").resolve("build") .resolve("outputs").resolve("bundle").resolve(configuration.toLowerCase(Locale.ROOT)) - .resolve("app-"+configuration.toLowerCase(Locale.ROOT)+".aab"); - Path targetAAB = paths.getGvmPath().resolve(projectConfiguration.getAppName()+".aab"); + .resolve("app-" + configuration.toLowerCase(Locale.ROOT) + ".aab"); + Path targetAAB = paths.getGvmPath().resolve(projectConfiguration.getAppName() + ".aab"); if (Files.exists(generatedAAB)) { FileOps.copyFile(generatedAAB, targetAAB); } @@ -190,9 +190,9 @@ public boolean packageApp() throws IOException, InterruptedException { public boolean install() throws IOException, InterruptedException { String configuration = generateSigningConfiguration(); ProcessRunner installDebug = new ProcessRunner( - getAndroidProjectPath().resolve("gradlew").toString(), - "-p", getAndroidProjectPath().toString(), - "install" + configuration); + getAndroidProjectPath().resolve("gradlew").toString(), + "-p", getAndroidProjectPath().toString(), + "install" + configuration); installDebug.addToEnv("ANDROID_HOME", sdk); installDebug.addToEnv("JAVA_HOME", projectConfiguration.getGraalPath().toString()); return installDebug.runProcess("install-task") == 0; @@ -247,7 +247,7 @@ List getTargetSpecificAOTCompileFlags() throws IOException { @Override List getTargetSpecificObjectFiles() throws IOException { if (projectConfiguration.isUseLLVM()) { - return FileOps.findFile(paths.getGvmPath(), "llvm.o").map( objectFile -> + return FileOps.findFile(paths.getGvmPath(), "llvm.o").map(objectFile -> Collections.singletonList(objectFile.toAbsolutePath().toString()) ).orElseThrow(); } @@ -351,7 +351,7 @@ List copyAdditionalSourceFiles(Path workDir) throws IOException { } List files = new ArrayList<>(); for (String fileName : getAdditionalSourceFiles()) { - Path resource = FileOps.copyResource(getAdditionalSourceFileLocation() + fileName, workDir.resolve(fileName)); + Path resource = FileOps.copyResource(getAdditionalSourceFileLocation() + fileName, workDir.resolve(fileName)); if ("launcher.c".equals(fileName)) { FileOps.replaceInFile(resource, "// USER_RUNTIME_ARGS", runtimeArgs); } @@ -494,7 +494,7 @@ private Path getCapCacheDir() throws IOException { * @return Path of the Android project * @throws IOException */ - private Path prepareAndroidProject() throws IOException { + private Path prepareAndroidProject() throws IOException, InterruptedException { Path androidProject = getAndroidProjectPath(); if (Files.exists(androidProject)) { FileOps.deleteDirectory(androidProject); @@ -503,8 +503,20 @@ private Path prepareAndroidProject() throws IOException { if (!projectConfiguration.hasWeb()) { Files.deleteIfExists(Path.of(androidProject.toString(), "app", "src", "main", "java", "com", "gluonhq", "helloandroid", "NativeWebView.java")); } - androidProject.resolve("gradlew").toFile().setExecutable(true); - return androidProject; + Path gradlewPath = androidProject.resolve("gradlew"); + gradlewPath.toFile().setExecutable(true); + + // Run 'dos2unix' on the gradlew file + ProcessBuilder processBuilder = new ProcessBuilder("dos2unix", gradlewPath.toString()); + processBuilder.redirectErrorStream(true); + Process process = processBuilder.start(); + int exitCode = process.waitFor(); + + if (exitCode != 0) { + throw new IOException("Failed to run dos2unix on gradlew. Exit code: " + exitCode); + } + + return androidProject; } /** From 004dabbe82a6dcf93d0591a11f99899cddd5fe5a Mon Sep 17 00:00:00 2001 From: Abid Maqbool Date: Tue, 13 May 2025 16:36:56 +0500 Subject: [PATCH 7/7] tmp --- .../target/AndroidTargetConfiguration.java | 30 +++++------ .../target/WindowsTargetConfiguration.java | 4 +- .../com/gluonhq/substrate/util/FileDeps.java | 50 +++++++++---------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java index bb78938a6..e31aad16e 100644 --- a/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/AndroidTargetConfiguration.java @@ -97,7 +97,7 @@ public class AndroidTargetConfiguration extends PosixTargetConfiguration { private final String capLocation = ANDROID_NATIVE_FOLDER + "cap/"; public AndroidTargetConfiguration(ProcessPaths paths, InternalProjectConfiguration configuration) throws IOException { - super(paths, configuration); + super(paths,configuration); this.sdk = fileDeps.getAndroidSDKPath().toString(); this.ndk = fileDeps.getAndroidNDKPath().toString(); @@ -152,18 +152,18 @@ public boolean packageApp() throws IOException, InterruptedException { fileDeps.checkAndroidPackages(sdk); // create apk for installing on device ProcessRunner assembleRunner = new ProcessRunner( - getAndroidProjectPath().resolve("gradlew").toString(), - "-p", getAndroidProjectPath().toString(), - "assemble" + configuration); + getAndroidProjectPath().resolve("gradlew").toString(), + "-p", getAndroidProjectPath().toString(), + "assemble" + configuration); assembleRunner.addToEnv("ANDROID_HOME", sdk); assembleRunner.addToEnv("JAVA_HOME", projectConfiguration.getGraalPath().toString()); if (assembleRunner.runProcess("package-task") != 0) { return false; } Path generatedApk = getAndroidProjectPath().resolve("app").resolve("build") - .resolve("outputs").resolve("apk").resolve(configuration.toLowerCase(Locale.ROOT)) - .resolve("app-" + configuration.toLowerCase(Locale.ROOT) + ".apk"); - Path targetApk = paths.getGvmPath().resolve(projectConfiguration.getAppName() + ".apk"); + .resolve("outputs").resolve("apk").resolve(configuration.toLowerCase(Locale.ROOT)) + .resolve("app-"+configuration.toLowerCase(Locale.ROOT)+".apk"); + Path targetApk = paths.getGvmPath().resolve(projectConfiguration.getAppName()+".apk"); if (Files.exists(generatedApk)) { FileOps.copyFile(generatedApk, targetApk); } @@ -179,8 +179,8 @@ public boolean packageApp() throws IOException, InterruptedException { } Path generatedAAB = getAndroidProjectPath().resolve("app").resolve("build") .resolve("outputs").resolve("bundle").resolve(configuration.toLowerCase(Locale.ROOT)) - .resolve("app-" + configuration.toLowerCase(Locale.ROOT) + ".aab"); - Path targetAAB = paths.getGvmPath().resolve(projectConfiguration.getAppName() + ".aab"); + .resolve("app-"+configuration.toLowerCase(Locale.ROOT)+".aab"); + Path targetAAB = paths.getGvmPath().resolve(projectConfiguration.getAppName()+".aab"); if (Files.exists(generatedAAB)) { FileOps.copyFile(generatedAAB, targetAAB); } @@ -191,9 +191,9 @@ public boolean packageApp() throws IOException, InterruptedException { public boolean install() throws IOException, InterruptedException { String configuration = generateSigningConfiguration(); ProcessRunner installDebug = new ProcessRunner( - getAndroidProjectPath().resolve("gradlew").toString(), - "-p", getAndroidProjectPath().toString(), - "install" + configuration); + getAndroidProjectPath().resolve("gradlew").toString(), + "-p", getAndroidProjectPath().toString(), + "install" + configuration); installDebug.addToEnv("ANDROID_HOME", sdk); installDebug.addToEnv("JAVA_HOME", projectConfiguration.getGraalPath().toString()); return installDebug.runProcess("install-task") == 0; @@ -254,7 +254,7 @@ List getTargetSpecificAOTCompileFlags() throws IOException { @Override List getTargetSpecificObjectFiles() throws IOException { if (projectConfiguration.isUseLLVM()) { - return FileOps.findFile(paths.getGvmPath(), "llvm.o").map(objectFile -> + return FileOps.findFile(paths.getGvmPath(), "llvm.o").map( objectFile -> Collections.singletonList(objectFile.toAbsolutePath().toString()) ).orElseThrow(); } @@ -366,7 +366,7 @@ List copyAdditionalSourceFiles(Path workDir) throws IOException { } List files = new ArrayList<>(); for (String fileName : getAdditionalSourceFiles()) { - Path resource = FileOps.copyResource(getAdditionalSourceFileLocation() + fileName, workDir.resolve(fileName)); + Path resource = FileOps.copyResource(getAdditionalSourceFileLocation() + fileName, workDir.resolve(fileName)); if ("launcher.c".equals(fileName)) { FileOps.replaceInFile(resource, "// USER_RUNTIME_ARGS", runtimeArgs); } @@ -531,7 +531,7 @@ private Path prepareAndroidProject() throws IOException, InterruptedException { throw new IOException("Failed to run dos2unix on gradlew. Exit code: " + exitCode); } - return androidProject; + return androidProject; } /** diff --git a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java index e916e7b6b..80188f75d 100644 --- a/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java +++ b/src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java @@ -64,8 +64,8 @@ public class WindowsTargetConfiguration extends AbstractTargetConfiguration { "comdlg32", "dwmapi", "gdi32", "imm32", "shell32", "uiautomationcore", "urlmon", "winmm"); private static final List staticJavaFxLibs = List.of( - "javafx_font", "javafx_iio", - "prism_common"); + "glass", "javafx_font", "javafx_iio", + "prism_common", "prism_d3d"); private static final List staticJavaFxSwLibs = List.of( "prism_sw"); diff --git a/src/main/java/com/gluonhq/substrate/util/FileDeps.java b/src/main/java/com/gluonhq/substrate/util/FileDeps.java index 49f291da1..3765c86b9 100644 --- a/src/main/java/com/gluonhq/substrate/util/FileDeps.java +++ b/src/main/java/com/gluonhq/substrate/util/FileDeps.java @@ -216,39 +216,39 @@ private boolean setupDependencies() throws IOException { Logger.logDebug("Processing JavaStatic dependencies at " + javaStaticLibs.toString()); if ((configuration.isUseJNI()) && (!configuration.getHostTriplet().equals(configuration.getTargetTriplet()))) { - if (!Files.isDirectory(javaStaticLibs)) { - if (customJavaLocation) { - throw new IOException ("A location for the static sdk libs was supplied, but it doesn't exist: "+javaStaticLibs); - } - downloadJavaStatic = true; - } else { - String path = javaStaticLibs.toString(); - if (JAVA_FILES.stream() - .map(s -> new File(path, s)) - .anyMatch(f -> !f.exists())) { - Logger.logDebug("jar file not found"); - System.err.println("jar not found"); + if (!Files.isDirectory(javaStaticLibs)) { if (customJavaLocation) { - throw new IOException ("A location for the static sdk libs was supplied, but the java libs are missing "+javaStaticLibs); + throw new IOException ("A location for the static sdk libs was supplied, but it doesn't exist: "+javaStaticLibs); } downloadJavaStatic = true; - } else if (!customJavaLocation && configuration.isEnableCheckHash()) { - // when the directory for the libs is found, and it is not a user-supplied one, check for its validity - Logger.logDebug("Checking java static sdk hashes"); - String md5File = getChecksumFileName(defaultJavaStaticPath, "javaStaticSdk", target); - Map hashes = FileOps.getHashMap(md5File); - if (hashes == null) { - Logger.logDebug(md5File+" not found"); - downloadJavaStatic = true; - } else if (JAVA_FILES.stream() + } else { + String path = javaStaticLibs.toString(); + if (JAVA_FILES.stream() .map(s -> new File(path, s)) - .anyMatch(f -> !hashes.get(f.getName()).equals(FileOps.calculateCheckSum(f)))) { - Logger.logDebug("jar file has invalid hashcode"); + .anyMatch(f -> !f.exists())) { + Logger.logDebug("jar file not found"); + System.err.println("jar not found"); + if (customJavaLocation) { + throw new IOException ("A location for the static sdk libs was supplied, but the java libs are missing "+javaStaticLibs); + } downloadJavaStatic = true; + } else if (!customJavaLocation && configuration.isEnableCheckHash()) { + // when the directory for the libs is found, and it is not a user-supplied one, check for its validity + Logger.logDebug("Checking java static sdk hashes"); + String md5File = getChecksumFileName(defaultJavaStaticPath, "javaStaticSdk", target); + Map hashes = FileOps.getHashMap(md5File); + if (hashes == null) { + Logger.logDebug(md5File+" not found"); + downloadJavaStatic = true; + } else if (JAVA_FILES.stream() + .map(s -> new File(path, s)) + .anyMatch(f -> !hashes.get(f.getName()).equals(FileOps.calculateCheckSum(f)))) { + Logger.logDebug("jar file has invalid hashcode"); + downloadJavaStatic = true; + } } } } - } // JavaFX Static if (configuration.isUseJavaFX()) {