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

[Build] Collect native sources in Jenkins pipeline with Java script #973

Conversation

HannesWell
Copy link
Member

@HannesWell HannesWell commented Jan 12, 2024

in order to replace ANT tasks with JavaScript (which require Java-11) in Jenkins pipeline.
Stash native sources not-zipped to save the zip and unzip steps.

Additionally move all remaining ANT tasks to run a native build in a local Maven for the running platform completely to the
maven-antrun-plugin configuration.

Furthermore move declaration of tools to the common Jenkins pipeline section to make them usable in all stages.
Since #633 the JDK on the native-build-agent's PATH is not used anymore when building the native binaries and thus it is not required anymore to keep the PATH untouched.

Part of

Copy link
Contributor

github-actions bot commented Jan 12, 2024

Test Results

   299 files  ±0     299 suites  ±0   5m 43s ⏱️ -18s
 4 098 tests ±0   4 090 ✅ ±0   8 💤 ±0  0 ❌ ±0 
12 206 runs  ±0  12 133 ✅ ±0  73 💤 ±0  0 ❌ ±0 

Results for commit ae48842. ± Comparison against base commit 968c813.

♻️ This comment has been updated with latest results.

@HannesWell HannesWell force-pushed the migrate-native-source-collection branch 3 times, most recently from 6b92179 to afe1743 Compare January 12, 2024 20:12
@HannesWell HannesWell marked this pull request as draft January 12, 2024 20:28
@HannesWell HannesWell force-pushed the migrate-native-source-collection branch 2 times, most recently from 23c1fae to 1c607b9 Compare January 13, 2024 18:33
@HannesWell HannesWell force-pushed the migrate-native-source-collection branch 4 times, most recently from 29db6cc to 0650d8c Compare January 14, 2024 09:39
@HannesWell HannesWell marked this pull request as ready for review January 14, 2024 09:39
in order to replace ANT tasks with JavaScript (which require Java-11) in
Jenkins pipeline.
Stash native sources not-zipped to save the zip and unzip steps.

Additionally move all remaining ANT tasks to run a native build in a
local Maven for the running platform completely to the
maven-antrun-plugin configuration.

Furthermore move declaration of tools to the common Jenkins pipeline
section to make them usable in all stages.
Since eclipse-platform#633
the JDK on the native-build-agent's PATH is not used anymore when
building the native binaries and thus it is not required anymore to keep
the PATH untouched.

Part of
- eclipse-platform#513
- eclipse-platform#626
@HannesWell HannesWell force-pushed the migrate-native-source-collection branch from 0650d8c to ae48842 Compare January 14, 2024 09:53
@HannesWell HannesWell merged commit 082c102 into eclipse-platform:master Jan 14, 2024
13 checks passed
@HannesWell HannesWell deleted the migrate-native-source-collection branch January 14, 2024 10:16
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this pull request Jan 15, 2024
Since eclipse-platform/eclipse.platform.swt#973
the I-build (like the SWT build) requires a java-17 (or later) jdk on
the PATH system environment-variable in order to launch a jdk>=17 with
the 'java' command from the CLI. Just setting the JAVA_HOME variable to
a path pointing to a jdk-17 is not sufficient since the the java
executable is usually located in '$JAVA_HOME/bin'. And while the maven
launch script searches in '$JAVA_HOME/bin' for a java executable to run
the build itself, a simple java command on the CLI isn't that smart.
Previously java would just run the default default java version on the
Jenkins executor.

In general this simplifies the build-configuration because the JDK to
use is only defined once and used everywhere.

Fixes eclipse-platform#1724
HannesWell added a commit to HannesWell/eclipse.platform.releng.aggregator that referenced this pull request Jan 15, 2024
Since eclipse-platform/eclipse.platform.swt#973
the I-build (like the SWT build) requires a java-17 (or later) jdk on
the PATH system environment-variable in order to launch a jdk>=17 with
the 'java' command from the CLI. Just setting the JAVA_HOME variable to
a path pointing to a jdk-17 is not sufficient since the the java
executable is usually located in '$JAVA_HOME/bin'. And while the maven
launch script searches in '$JAVA_HOME/bin' for a java executable to run
the build itself, a simple java command on the CLI isn't that smart.
Previously running the 'java' command would just run the default default
java version on the Jenkins executor.

In general this simplifies the build-configuration because the JDK to
use is only defined once and used everywhere.

Fixes eclipse-platform#1724
HannesWell added a commit to eclipse-platform/eclipse.platform.releng.aggregator that referenced this pull request Jan 15, 2024
Since eclipse-platform/eclipse.platform.swt#973
the I-build (like the SWT build) requires a java-17 (or later) jdk on
the PATH system environment-variable in order to launch a jdk>=17 with
the 'java' command from the CLI. Just setting the JAVA_HOME variable to
a path pointing to a jdk-17 is not sufficient since the the java
executable is usually located in '$JAVA_HOME/bin'. And while the maven
launch script searches in '$JAVA_HOME/bin' for a java executable to run
the build itself, a simple java command on the CLI isn't that smart.
Previously running the 'java' command would just run the default default
java version on the Jenkins executor.

In general this simplifies the build-configuration because the JDK to
use is only defined once and used everywhere.

Fixes #1724
@chirontt
Copy link
Contributor

@HannesWell with this commit, how do I manually (re)compile the SWT native binaries, especially the Windows .dll files, using Ant?

Or, is there now a different (new) way to (re)compile them using Maven? If so, how to do it with a manual mvn command?

Here's my use case: I've been using Ant to compile the SWT Windows .dll files for the Windows on Arm64 (WoA, in my WoA fork of this repo), with this specific command, manually run in the bundles/org.eclipse.swt directory, on my WoA box:

ant -f buildSWT.xml build_libraries -Dswt.os=win32 -Dswt.ws=win32 -Dswt.arch=aarch64 -Dtargets="aarch64 all install" -DSWT_JAVA_HOME=%JAVA_HOME%

With this commit, the above build_libraries target in the buildSWT.xml build file has been removed. How do I manually compile them for WoA now, to produce the relevant SWT .dll files?

@HannesWell
Copy link
Member Author

To compile the native binaries locally with maven it is sufficient to run

mvn clean generate-resources -Dnative=${ws}.${os}.${arch} -DskipTests

If you also want to build the jars you have to run the build up to a later phase like verify.

If that takes to long for you, you can just directly run two commands to collect the native sources and compile them as it is implemented in the build-native-binaries, without using ant.

@chirontt
Copy link
Contributor

chirontt commented Jan 18, 2024

Thanks, but it should be the process-resources phase to invoke, not generate-resources like your above command. So for my WoA .dll production, the command series should be (running on a WoA box):

cd binaries\org.eclipse.swt.win32.win32.aarch64
mvn clean process-resources -Dnative=win32.win32.aarch64 -DskipTests

The caveat: there must already exist the swtBuildQualifier.txt file in bundles\org.eclipse.swt\target directory. Not sure how this file was generated there in the first place, or whether it could be skipped...

And my ultimate goal is to cross-compile from a Windows x64 host to generate the binaries for the Arm64 target, so the command becomes:

mvn clean process-resources -Dnative=win32.win32.aarch64 -DskipTests -Dtargets="x64_arm64 all install" -DSWT_JAVA_HOME=\path\to\the\arm64-jdk

Thanks for your work to simplify these SWT build scripts.

@HannesWell
Copy link
Member Author

Thanks, but it should be the process-resources phase to invoke, not generate-resources like your above command.

That's right, sorry for the confusion.

So for my WoA .dll production, the command series should be (running on a WoA box):

cd binaries\org.eclipse.swt.win32.win32.aarch64
mvn clean process-resources -Dnative=win32.win32.aarch64 -DskipTests

The caveat: there must already exist the swtBuildQualifier.txt file in bundles\org.eclipse.swt\target directory. Not sure how this file was generated there in the first place, or whether it could be skipped...

If you just run the mvn command from the swt repository root, then that file is generated (that's done when the org.eclipse.swt project is built).

If you want to reduce your build time you could use the -pl and -am option of Maven:
clean process-resources -pl org.eclipse.swt:org.eclipse.swt.win32.win32.x86_64 -am -Dnative=win32.win32.x86_64 -DskipTests

And my ultimate goal is to cross-compile from a Windows x64 host to generate the binaries for the Arm64 target, so the command becomes:

mvn clean process-resources -Dnative=win32.win32.aarch64 -DskipTests -Dtargets="x64_arm64 all install" -DSWT_JAVA_HOME=\path\to\the\arm64-jdk

That should work yes. In order to avoid the need to specify the targets on the CLI you could simply create a org.eclipse.swt.win32.win32.aarch64 fragment as copy from the existing windows fragment basically replacing all x86_64 by aarch64 plus the adjustments of the make files (but you probably know them better than I).
But then you probably still need the SWT_JAVA_HOME argument.

@HannesWell
Copy link
Member Author

I thought about building only the natives again and found an even faster solution.
@chirontt please see #991 if you are interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants