Skip to content

Commit

Permalink
[Build] Further simplifications
Browse files Browse the repository at this point in the history
Increment the Library revision also for enforced native binary
re-builds. Besides allowing simplifications of the build, this ensures
there is a git-qualifier update and we don't need to have letter
suffixes for git tags.

Part of eclipse-platform#513
  • Loading branch information
HannesWell committed Jan 18, 2024
1 parent bd81b48 commit 8d7580d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 44 deletions.
69 changes: 25 additions & 44 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Mickael Istria (Red Hat Inc.) - initial API and implementation
* Hannes Wellmann - Build SWT-natives as part of master- and verification-builds
* Hannes Wellmann - Move SWT native binaries in this repository using Git-LFS
* Hannes Wellmann - Replace ANT-scripts by Maven, Jenkins-Pipeline and single-source Java scripts
*******************************************************************************/

def nativeBuildAgent(String platform, Closure body) {
Expand Down Expand Up @@ -65,6 +66,8 @@ def getSWTVersions() { // must be called from the repository root
return props
}

boolean NATIVES_CHANGED = false

pipeline {
options {
skipDefaultCheckout() // Specialiced checkout is performed below
Expand Down Expand Up @@ -127,7 +130,7 @@ pipeline {
echo "Current tag=${swtTag}."
boolean nativesChanged = false
dir('bundles/org.eclipse.swt') {
// Check preprocessing is completed
// Verify preprocessing is completed
sh '''
if grep -R --include='*.java' --line-number --fixed-strings -e 'int /*long*/' -e 'float /*double*/' -e 'int[] /*long[]*/' -e 'float[] /*double[]*/' .; then
echo There are files with the wrong long /*int*/ preprocessing.
Expand All @@ -140,7 +143,8 @@ pipeline {
nativesChanged = !diff.strip().isEmpty()
echo "Natives changed since ${swtTag}: ${nativesChanged}"
}
if (nativesChanged) {
if (nativesChanged || params.forceNativeBuilds) {
NATIVES_CHANGED = true
def swtVersions = getSWTVersions()
withEnv(['swt_version='+swtVersions['swt_version'], 'new_version='+swtVersions['new_version'], 'rev='+swtVersions['rev'], 'new_rev='+swtVersions['new_rev'],
'comma_ver='+swtVersions['comma_ver'], "new_comma_ver=${swtVersions['maj_ver']},${swtVersions['min_ver']},${swtVersions['new_rev']},0" ]) {
Expand All @@ -158,11 +162,6 @@ pipeline {
commonMakeFile='bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak'
sed -i -e "s/rev=${rev}/rev=${new_rev}/g" "$commonMakeFile"
sed -i -e "s/comma_ver=${comma_ver}/comma_ver=${new_comma_ver}/g" "$commonMakeFile"
git add "${libraryFile}" "${commonMakeFile}"
git status
mkdir ../tmp; echo 'true' > '../tmp/natives_changed.txt'
'''
}
}
Expand All @@ -172,10 +171,7 @@ pipeline {
}
stage('Build SWT-binaries, if needed') {
when {
anyOf {
expression { return params.forceNativeBuilds }
expression { return fileExists('tmp/natives_changed.txt') }
}
expression { NATIVES_CHANGED }
}
matrix {
axes {
Expand Down Expand Up @@ -214,8 +210,10 @@ pipeline {
}
nativeBuildAgent("${PLATFORM}") {
cleanWs() // Workspace is not cleaned up by default, so we do it explicitly
echo "OS: ${os}"
echo "ARCH: ${arch}"
echo """
OS: ${os}
ARCH: ${arch}
"""
unstash "swt.binaries.sources.${PLATFORM}"
dir('jdk.resources') {
unstash "jdk.resources.${os}.${arch}"
Expand Down Expand Up @@ -248,7 +246,7 @@ pipeline {
steps {
dir("libs/${PLATFORM}") {
unstash "swt.binaries.${PLATFORM}"

//TODO: just do all the signing in the maven-build. TODO: think about how to activate properly?
sh '''#!/bin/bash -x
fn-sign-files()
{
Expand Down Expand Up @@ -303,53 +301,38 @@ pipeline {
}
stage('Commit SWT-native binaries, if build') {
when {
expression { return params.forceNativeBuilds || fileExists('tmp/natives_changed.txt') }
expression { NATIVES_CHANGED }
}
steps {
dir('eclipse.platform.swt') {
script {
def swt_version = getSWTVersions()['swt_version'] // versions are read from updated file
sh """
withEnv(["swt_version=${getSWTVersions()['swt_version']}"]) { // versions are read from updated file
sh '''
find binaries -name "*${swt_version}*" -type f -exec chmod 755 {} +
git add --all *
git status
git status
git commit -m 'v${swt_version}'
"""
try {
sh "git tag v${swt_version}"
} catch (ex) { // May fail in case this is a forced native re-build without revision increment
def tagged = ('a'..'z').any{ suffix ->
try {
sh "git tag v${swt_version + suffix}"
return true
}catch (ex1) {
return false
}
}
if(!tagged) {
fail "Fail to create tag for v${swt_version}"
}
}
git tag v${swt_version}
git status
git log --patch -2
'''
}
sh '''
git status
git log -p -2
'''
}
}
}
stage('Build') {
steps {
xvnc(useXauthority: true) {
dir('eclipse.platform.swt') {
sh '''
sh """
mvn clean verify \
${NATIVES_CHANGED?'-Psign-native-binaries':''} \
--batch-mode -DforkCount=0 \
-Dcompare-version-with-baselines.skip=false -Dmaven.compiler.failOnWarning=true \
-Dorg.eclipse.swt.tests.junit.disable.test_isLocal=true \
-Dmaven.test.failure.ignore=true -Dmaven.test.error.ignore=true
'''
"""
}
}
}
Expand All @@ -364,7 +347,7 @@ pipeline {
}
stage('Push SWT-native binaries, if build') {
when {
expression { return params.forceNativeBuilds || fileExists('tmp/natives_changed.txt') }
expression { NATIVES_CHANGED }
}
steps {
sshagent(['github-bot-ssh']) {
Expand All @@ -385,8 +368,6 @@ pipeline {
else
echo Skip pushing changes of native-binaries for branch '${BRANCH_NAME}'
fi
# The commits are not pushed. At least list them, so one can check if the result is as expected.
git log -n 2
"""
}
}
Expand Down
36 changes: 36 additions & 0 deletions binaries/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,41 @@
</plugins>
</build>
</profile>
<profile>
<id>sign-native-binaries</id>
<pluginRepositories>
<pluginRepository>
<id>eclipse-cbi-releases</id>
<url>https://repo.eclipse.org/content/repositories/cbi-releases/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.cbi.maven.plugins</groupId>
<artifactId>eclipse-winsigner-plugin</artifactId>
<version>1.4.3</version>
<executions>
<execution>
<id>sign</id>
<goals>
<goal>sign</goal>
</goals>
<phase>package</phase>
<configuration>
<signerUrl>https://cbi.eclipse.org/authenticode/sign</signerUrl>
<baseSearchDir>${project.basedir}</baseSearchDir>
<fileNames>*.dll</fileNames> <!-- TODO: define this in sub-product to effectivly disable it for gtk?-->
<signFiles>
<signFile>${project.build.directory}/products/org.eclipse.sdk.ide/win32/win32/x86/eclipse/eclipse.exe</signFile>
<signFile>${project.build.directory}/products/org.eclipse.sdk.ide/win32/win32/x86/eclipse/eclipsec.exe</signFile>
</signFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 8d7580d

Please sign in to comment.