Skip to content

Commit

Permalink
[Build] Simplify collecting native sources in Jenkins pipeline
Browse files Browse the repository at this point in the history
Stash the native sources only once per OS, which reduces the runtime and
required storage-space on the Jenkins controller.
  • Loading branch information
HannesWell committed May 3, 2024
1 parent 6e47b06 commit b58f379
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
27 changes: 11 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pipeline {
booleanParam(name: 'skipCommit', defaultValue: false, description: 'Stops committing to swt and swt binaries repo at the end. Useful in debugging.')
}
stages {
stage('Checkout swt git repos') {
stage('Checkout SCM') {
steps {
dir('eclipse.platform.swt') {
checkout scm
Expand Down Expand Up @@ -176,6 +176,15 @@ pipeline {
sed -i -e "s/comma_ver=${comma_ver}/comma_ver=${new_comma_ver}/g" "$commonMakeFile"
'''
}
// Collect SWT-native's sources
dir('bundles/org.eclipse.swt') {
for (ws in ['cocoa', 'gtk', 'win32']) {
sh "java -Dws=${ws} build-scripts/CollectSources.java -nativeSources 'target/natives-build-temp/${ws}'"
dir("target/natives-build-temp/${ws}") {
stash(name:"swt.binaries.sources.${ws}")
}
}
}
}
}
}
Expand All @@ -193,20 +202,6 @@ pipeline {
}
}
stages {
stage("Collect SWT-native's sources") {
steps {
dir('eclipse.platform.swt/bundles/org.eclipse.swt') {
sh '''
pfSpec=(${PLATFORM//"."/ })
java -Dws=${pfSpec[0]} -Darch=${pfSpec[2]} build-scripts/CollectSources.java -nativeSources \
"${WORKSPACE}/eclipse.platform.swt/binaries/org.eclipse.swt.${PLATFORM}/target/natives-build-temp"
'''
}
dir("eclipse.platform.swt/binaries/org.eclipse.swt.${PLATFORM}/target/natives-build-temp") {
stash(name:"swt.binaries.sources.${PLATFORM}")
}
}
}
stage('Build SWT-natives') {
options {
timeout(time: 120, unit: 'MINUTES') // Some build agents are rare and it might take awhile until they are available.
Expand All @@ -223,7 +218,7 @@ pipeline {
nativeBuildAgent("${PLATFORM}") {
cleanWs() // Workspace is not cleaned up by default, so we do it explicitly
echo "OS: ${os}, ARCH: ${arch}"
unstash "swt.binaries.sources.${PLATFORM}"
unstash "swt.binaries.sources.${ws}"
dir('jdk.resources') {
unstash "jdk.resources.${os}.${arch}"
}
Expand Down
7 changes: 3 additions & 4 deletions bundles/org.eclipse.swt/build-scripts/CollectSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class CollectSources {

private record ScriptEnvironment(Path swtProjectRoot, Path binariesRoot, Path targetDirectory, String ws) {
private record ScriptEnvironment(Path swtProjectRoot, Path targetDirectory, String ws) {
private static ScriptEnvironment read(String[] args) {
if (args.length != 2) {
throw new IllegalArgumentException("task and target directory must be defined as only argument");
Expand All @@ -41,10 +41,9 @@ private static ScriptEnvironment read(String[] args) {
if (!swtProjectRoot.endsWith(Path.of("bundles/org.eclipse.swt"))) { // Consistency check
throw new IllegalStateException("Script must be executed from org.eclipse.swt project");
}
Path binariesRoot = swtProjectRoot.getParent().getParent().resolve("binaries").toAbsolutePath();
Path targetDirectory = Path.of(args[1]);
Path targetDirectory = Path.of(args[1]).toAbsolutePath();
String ws = System.getProperty("ws");
return new ScriptEnvironment(swtProjectRoot, binariesRoot, targetDirectory, ws);
return new ScriptEnvironment(swtProjectRoot, targetDirectory, ws);
}
}

Expand Down

0 comments on commit b58f379

Please sign in to comment.