Skip to content

Commit

Permalink
[Build] Further stream-lining and simplifications of SWT build pipeline
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.

Use the org.eclipse.cbi.maven.plugins:eclipse-winsigner-plugin Maven
plug-in to sign the built binaries instead of bash-scripts.

And remove superfluous steps.

Part of eclipse-platform#513
  • Loading branch information
HannesWell committed Jan 20, 2024
1 parent 5c9180b commit d5ee770
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 73 deletions.
101 changes: 28 additions & 73 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 - Streamline entire SWT build and 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,7 @@ 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,50 +243,28 @@ pipeline {
steps {
dir("libs/${PLATFORM}") {
unstash "swt.binaries.${PLATFORM}"

sh '''#!/bin/bash -x
fn-sign-files()
{
extension=$1
signingServiceAddress=$2
fn-sign-files() {
echo "Sign ${PLATFORM} libraries"
if [[ "${BRANCH_NAME}" == master ]] || [[ "${BRANCH_NAME}" =~ R[0-9]+_[0-9]+(_[0-9]+)?_maintenance ]]; then
for filename in $(ls *.${extension})
do
mv ${filename} unsigned-${filename}
curl -f -o ${filename} -F file=@unsigned-${filename} $signingServiceAddress
if [[ $? != 0 ]]; then
echo "Signing of ${filename} failed"
exit 1
else
rm unsigned-${filename}
fi
done
# Execute only the sign goal for only the binary-parent project and only search binaries to sign in the libs/<platform> directory
# Contratary to its name, with a suitable signer-service, the eclipse-winsigner plugin can be used to sign arbitrary files
mvn eclipse-winsigner:sign --file $binaryFragmentsRoot --projects . \
-Dcbi.winsigner.baseSearchDir=${WORKSPACE}/libs/${PLATFORM} -Dcbi.winsigner.fileNames=/*.$1 \
-Dcbi.winsigner.signerUrl=$2
fi
}
binaryFragmentsRoot=${WORKSPACE}/eclipse.platform.swt/binaries
if [[ ${PLATFORM} == cocoa.macosx.* ]]; then
#TODO: Instead use (with adjusted URL): https://github.com/eclipse-cbi/org.eclipse.cbi/tree/main/maven-plugins/eclipse-winsigner-plugin
# The mac-signer mojo only works for Mac-applications and not for jnilib files, but the winsigner-plugin with adjusted URL seems to do what we want.
echo "Sign ${PLATFORM} libraries"
fn-sign-files jnilib https://cbi.eclipse.org/macos/codesign/sign
fn-sign-files jnilib 'https://cbi.eclipse.org/macos/codesign/sign'
cp *.jnilib ${binaryFragmentsRoot}/org.eclipse.swt.${PLATFORM}/
elif [[ ${PLATFORM} == gtk.linux.* ]]; then
#TODO: can the webkit handling be removed?!
#echo "Removing existing webkitextensions"
#rm -r ${binaryFragmentsRoot}/org.eclipse.swt.${PLATFORM}/webkit*/
#cp -r webkitextensions* ${binaryFragmentsRoot}/org.eclipse.swt.${PLATFORM}/
cp *.so ${binaryFragmentsRoot}/org.eclipse.swt.${PLATFORM}/
elif [[ ${PLATFORM} == win32.win32.* ]]; then
#TODO: Instead use: https://github.com/eclipse-cbi/org.eclipse.cbi/tree/main/maven-plugins/eclipse-winsigner-plugin
echo "Sign ${PLATFORM} libraries"
fn-sign-files dll https://cbi.eclipse.org/authenticode/sign
fn-sign-files dll 'https://cbi.eclipse.org/authenticode/sign'
cp *.dll ${binaryFragmentsRoot}/org.eclipse.swt.${PLATFORM}/
fi
'''
Expand All @@ -303,39 +276,23 @@ 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 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 status
git commit -m "v${swt_version}"
git tag v${swt_version}
git status
git log --patch -2
'''
}
sh '''
git status
git log -p -2
'''
}
}
}
Expand Down Expand Up @@ -364,7 +321,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 +342,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
19 changes: 19 additions & 0 deletions binaries/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,23 @@
</build>
</profile>
</profiles>

<pluginRepositories>
<pluginRepository>
<id>eclipse-cbi-releases</id>
<url>https://repo.eclipse.org/content/repositories/cbi-releases/</url>
</pluginRepository>
</pluginRepositories>
<build>
<pluginManagement>
<plugins>
<plugin><!-- Executed explicitly in Jenkins pipeline-->
<groupId>org.eclipse.cbi.maven.plugins</groupId>
<artifactId>eclipse-winsigner-plugin</artifactId>
<version>1.4.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>

0 comments on commit d5ee770

Please sign in to comment.