diff --git a/Jenkinsfile b/Jenkinsfile index 8b24f026395..851c5755622 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,6 +81,11 @@ spec: environment { MAVEN_OPTS = "-Xmx4G" } + parameters { + booleanParam(name: 'forceTagging', defaultValue: false) + booleanParam(name: 'forceNativeBuilds', defaultValue: false, description: 'This supercedes forceTagging parameter') + booleanParam(name: 'skipCommit', defaultValue: false, description: 'Stops committing to swt and swt binaries repo at the end. Useful in debugging') + } stages { stage('Prepare environment') { steps { @@ -97,6 +102,466 @@ spec: } } } + stage('Check if SWT-binaries build is needed') { + agent 'centos-8' + tools { + jdk 'openjdk-jdk11-latest' + } + steps { + withAnt(installation: 'apache-ant-latest', jdk: 'openjdk-jdk11-latest') { + sh''' + java -version + + ant -f ${WORKSPACE}/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml check_compilation + ant -f ${WORKSPACE}/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml new_build_with_create_file + + if [[ "${params.forceNativeBuilds}" == "true" ]] + then + touch "${WORKSPACE}/tmp/build_changed.txt" + touch "${WORKSPACE}/tmp/natives_changed.txt" + NATIVES_CHANGED=true + fi + + if [[ " ${params.forceTagging}" == "true" ]] + then + touch "${WORKSPACE}/tmp/build_changed.txt" + fi + + if [ -f "${WORKSPACE}/tmp/build_changed.txt" ] + then + BUILD_CHANGED=true + else + echo "Nothing to build, exiting...." + exit 0 + fi + ''' + } + } + } + stage('Collect SWT-binaries sources if needed') { + when { + expression { return fileExists ('${WORKSPACE}/tmp/build_changed.txt') && fileExists ('${WORKSPACE}/tmp/natives_changed.txt') } + } + agent 'centos-8' + tools { + jdk 'openjdk-jdk11-latest' + } + steps { + withAnt(installation: 'apache-ant-latest', jdk: 'openjdk-jdk11-latest') { + sh ''' + ant -f eclipse.platform.swt.binaries/bundles/binaries-parent/build.xml copy_library_src_and_create_zip -Dws=cocoa -Dos=macosx -Darch=aarch64 + ant -f eclipse.platform.swt.binaries/bundles/binaries-parent/build.xml copy_library_src_and_create_zip -Dws=cocoa -Dos=macosx -Darch=x86_64 + ant -f eclipse.platform.swt.binaries/bundles/binaries-parent/build.xml copy_library_src_and_create_zip -Dws=gtk -Dos=linux -Darch=aarch64 + ant -f eclipse.platform.swt.binaries/bundles/binaries-parent/build.xml copy_library_src_and_create_zip -Dws=gtk -Dos=linux -Darch=ppc64le + ant -f eclipse.platform.swt.binaries/bundles/binaries-parent/build.xml copy_library_src_and_create_zip -Dws=gtk -Dos=linux -Darch=x86_64 + ant -f eclipse.platform.swt.binaries/bundles/binaries-parent/build.xml copy_library_src_and_create_zip -Dws=win32 -Dos=win32 -Darch=x86_64 + ''' + } + dir('eclipse.platform.swt.binaries/bundles'){ + dir('org.eclipse.swt.cocoa.macosx.aarch64/tmpdir'){ + stash name:'swt.binaries.sources.cocoa.macosx.aarch64', includes: 'org.eclipse.swt.cocoa.macosx.aarch64.master.zip' + } + dir('org.eclipse.swt.cocoa.macosx.x86_64/tmpdir'){ + stash name:'swt.binaries.sources.cocoa.macosx.x86_64', includes: 'org.eclipse.swt.cocoa.macosx.x86_64.master.zip' + } + dir('org.eclipse.swt.gtk.linux.aarch64/tmpdir'){ + stash name:'swt.binaries.sources.gtk.linux.aarch64', includes: 'org.eclipse.swt.gtk.linux.aarch64.master.zip' + } + dir('org.eclipse.swt.gtk.linux.ppc64le/tmpdir'){ + stash name:'swt.binaries.sources.gtk.linux.ppc64le', includes: 'org.eclipse.swt.gtk.linux.ppc64le.master.zip' + } + dir('org.eclipse.swt.gtk.linux.x86_64/tmpdir'){ + stash name:'swt.binaries.sources.gtk.linux.x86_64', includes: 'org.eclipse.swt.gtk.linux.x86_64.master.zip' + } + dir('org.eclipse.swt.win32.win32.x86_64/tmpdir'){ + stash name:'swt.binaries.sources.win32.win32.x86_64', includes: 'org.eclipse.swt.win32.win32.x86_64.master.zip' + } + } + } + } + stage('Build SWT-binaries if needed') { + when { + expression { return fileExists ('${WORKSPACE}/tmp/build_changed.txt') && fileExists ('${WORKSPACE}/tmp/natives_changed.txt') } + } + failFast true + parallel { + stage ('Build SWT-binaries for Mac OS X (Cocoa) aarch64'){ + options { + timestamps() + skipDefaultCheckout() + timeout(time: 15, unit: 'MINUTES') + } + agent 'b9h15-macos10.15' + steps { + dir('build') { + unstash 'swt.binaries.sources.cocoa.macosx.aarch64' + sh '''#!/bin/bash -x + sw_vers -productVersion + + unzip org.eclipse.swt.cocoa.macosx.aarch64.master.zip + rm org.eclipse.swt.cocoa.macosx.aarch64.master.zip + + mkdir libs + + export MODEL=aarch64 + export OUTPUT_DIR=${WORKSPACE}/build/libs + sh build.sh install + + ls -1R libs + ''' + dir('libs') { + stash 'swt.binaries.cocoa.macosx.aarch64' + } + } + } + } + stage ('Build SWT-binaries for Mac OS X (Cocoa) x86_64'){ + options { + timestamps() + skipDefaultCheckout() + timeout(time: 15, unit: 'MINUTES') + } + agent 'b9h15-macos10.15' + steps { + dir('build') { + unstash 'swt.binaries.sources.cocoa.macosx.x86_64' + sh '''#!/bin/bash -x + sw_vers -productVersion + + unzip org.eclipse.swt.cocoa.macosx.x86_64.master.zip + rm org.eclipse.swt.cocoa.macosx.x86_64.master.zip + + mkdir libs + + export MODEL=x86_64 + export OUTPUT_DIR=${WORKSPACE}/build/libs + sh build.sh install + + ls -1R libs + ''' + dir('libs') { + stash 'swt.binaries.cocoa.macosx.x86_64' + } + } + } + } + stage ('Build SWT-binaries for Linux GTK aarch64'){ + options { + timestamps() + skipDefaultCheckout() + timeout(time: 15, unit: 'MINUTES') + } + agent 'arm64||aarch64-swt' + steps { + dir('build') { + unstash 'swt.binaries.sources.gtk.linux.aarch64' + sh '''#!/bin/bash -x + unzip -aa org.eclipse.swt.gtk.linux.aarch64.master.zip + rm org.eclipse.swt.gtk.linux.aarch64.master.zip + + mkdir libs + + export MODEL=aarch64 + export OUTPUT_DIR=${WORKSPACE}/build/libs + if [ -d /usr/lib/jvm/java-11-openjdk-arm64 ] + then + export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64 + else + export JAVA_HOME=/usr/lib/jvm/java-11-openjdk + fi + sh build.sh clean install + + if [ $? -ne 0 ] + then + exit 1 + fi + ''' + dir('libs') { + stash 'swt.binaries.gtk.linux.aarch64' + } + } + } + } + stage ('Build SWT-binaries for Linux GTK ppc64le'){ + options { + timestamps() + skipDefaultCheckout() + timeout(time: 15, unit: 'MINUTES') + } + agent 'ppcbuild' + steps { + dir('build') { + unstash 'swt.binaries.sources.gtk.linux.ppc64le' + sh '''#!/bin/bash -x + unzip -aa org.eclipse.swt.gtk.linux.ppc64le.master.zip + rm org.eclipse.swt.gtk.linux.ppc64le.master.zip + + mkdir libs + + export MODEL=ppc64le + export OUTPUT_DIR=${WORKSPACE}/build/libs + sh build.sh clean install + + if [ $? -ne 0 ] + then + exit 1 + fi + ''' + dir('libs') { + stash 'swt.binaries.gtk.linux.ppc64le' + } + } + } + } + stage ('Build SWT-binaries for Linux GTK x86_64'){ + options { + timestamps() + skipDefaultCheckout() + timeout(time: 15, unit: 'MINUTES') + } + agent { + kubernetes { + label 'swt-build-pod' + yaml """ +apiVersion: v1 +kind: Pod +spec: + containers: + - name: "swtbuild" + image: "eclipse/platformreleng-centos-swt-build:8" + imagePullPolicy: "Always" + resources: + limits: + memory: "4096Mi" + cpu: "2000m" + requests: + memory: "512Mi" + cpu: "1000m" + command: + - cat + tty: true + volumeMounts: + - name: tools + mountPath: /opt/tools + volumes: + - name: tools + persistentVolumeClaim: + claimName: tools-claim-jiro-releng +""" + } + } + tools { + jdk 'temurin-jdk11-latest' + } + steps { + container('swtbuild') { + dir('build') { + unstash 'swt.binaries.sources.gtk.linux.x86_64' + withEnv(["JAVA_HOME=${ tool 'temurin-jdk11-latest' }"]) { + sh '''#!/bin/bash -x + alias cc=gcc + + unzip org.eclipse.swt.gtk.linux.x86_64.master.zip + + mkdir libs + + export MODEL=x86_64 + export OUTPUT_DIR=${WORKSPACE}/build/libs + sh build.sh clean install + + ls -1R libs/ + ''' + } + dir('libs') { + stash 'swt.binaries.gtk.linux.x86_64' + } + } + } + } + } + stage ('Build SWT-binaries for Windows x86_64'){ + options { + timestamps() + skipDefaultCheckout() + timeout(time: 15, unit: 'MINUTES') + } + agent 'rs68g-win10' + steps { + dir('build') { + unstash 'swt.binaries.sources.win32.win32.x86_64' + bat ''' + PATH=C:/tools/cygwin/bin;%PATH%" + unzip org.eclipse.swt.win32.win32.x86_64.master.zip + mkdir libs + + set MODEL=x86_64 + set OUTPUT_DIR=libs\ + + @rem rustup show + cmd /c build.bat x86_64 all install + + ls libs + ''' + dir('libs') { + stash 'swt.binaries.win32.win32.x86_64' + } + } + } + } + } + } + stage('Collect and sign SWT-binaries if build') { + when { + expression { return fileExists ('${WORKSPACE}/tmp/build_changed.txt') && fileExists ('${WORKSPACE}/tmp/natives_changed.txt') } + } + //TODO: consider one axis matrix 'cocoa.macosx.aarch64', 'cocoa.macosx.x86_64', ... that performs mac signing for name starting with cocoa.macosx and win-signing for those starting with win32.win32... + // then do the git staging at the very end if necessary? But it is also nice to see what has changed + steps { + dir('libs') { + dir('macosx.aarch64') { + unstash 'swt.binaries.cocoa.macosx.aarch64' + } + dir('macosx.x86_64') { + unstash 'swt.binaries.cocoa.macosx.x86_64' + } + dir('linux.aarch64'){ + unstash 'swt.binaries.gtk.linux.aarch64' + } + dir('linux.ppc64le'){ + unstash 'swt.binaries.gtk.linux.ppc64le' + } + dir('linux.x86_64'){ + unstash 'swt.binaries.gtk.linux.x86_64' + } + dir('win32.x86_64'){ + unstash 'swt.binaries.win32.win32.x86_64' + } + } + sh ''' + fn-win-sign () + { + filename=$1 + mv ${filename} unsigned-${filename} + curl -f -o ${filename} -F file=@unsigned-${filename} https://cbi.eclipse.org/authenticode/sign + if [ $? -ne 0 ] + then + echo "Signing of ${filename} failed" + exit 1 + else + rm unsigned-${filename} + fi + } + + fn-mac-sign () + { + filename=$1 + mv ${filename} unsigned-${filename} + curl -f -o ${filename} -F file=@unsigned-${filename} https://cbi.eclipse.org/macos/codesign/sign + if [ $? -ne 0 ] + then + echo "Signing of ${filename} failed" + exit 1 + else + rm unsigned-${filename} + fi + } + + fn-mac-sign-exe () + { + filename=$1 + mv ${filename} unsigned-${filename} + wget https://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/plain/eclipse.platform.releng.tychoeclipsebuilder/entitlement/sdk.entitlement + curl -f -o ${filename} -F file=@unsigned-${filename} -F entitlements=@sdk.entitlement https://cbi.eclipse.org/macos/codesign/sign + if [ $? -ne 0 ] + then + echo "Signing of ${filename} failed" + exit 1 + else + rm unsigned-${filename} + rm sdk.entitlement + fi + } + binaryFragmentsRoot=${WORKSPACE}/eclipse.platform.swt.binaries/bundles + pushd ${WORKSPACE}/libs + + #Mac-x86_64-start + pushd macosx.x86_64 + + echo "Sign mac x86_64 libraries" + for i in $(ls *.jnilib) + do + fn-mac-sign $i + done + + cp *.jnilib ${binaryFragmentsRoot}/org.eclipse.swt.cocoa.macosx.x86_64/ + popd + #Mac-x86_64-end + + #Mac-aarch64-start + pushd macosx.aarch64 + + echo "Sign mac aarch64 libraries" + for i in $(ls *.jnilib) + do + fn-mac-sign $i + done + + cp *.jnilib ${binaryFragmentsRoot}/org.eclipse.swt.cocoa.macosx.aarch64/ + popd + #Mac-aarch64-end + + #Linux-x86-64-start + echo "Removing existing webkitextensions" + rm -r ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.x86_64/webkit*/ + + pushd linux.x86_64 + cp *.so ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.x86_64/ + cp -r webkitextensions* ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.x86_64/ + popd + #Linux-86-64-end + + #Linux-ppc64le-start + echo "Removing existing webkitextensions" + rm -r ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.ppc64le/webkit*/ + + pushd linux.ppc64le + cp *.so ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.ppc64le/ + cp -r webkitextensions* ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.ppc64le/ + popd + #Linux-ppc64le-end + + #Linux-aarch64-start + echo "Removing existing webkitextensions" + rm -r ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.aarch64/webkit*/ + + pushd linux.aarch64 + cp *.so ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.aarch64/ + cp -r webkitextensions* ${binaryFragmentsRoot}/org.eclipse.swt.gtk.linux.aarch64/ + popd + #Linux-aarch64-end + + #Windows-start + pushd win32.x86_64 + + echo "Sign Windows x86_64 libraries" + for i in $(ls *.dll) + do + fn-win-sign $i + done + + cp *.dll ${binaryFragmentsRoot}/org.eclipse.swt.win32.win32.x86_64/ + popd + #Windows-end + + cd ${WORKSPACE}/eclipse.platform.swt.binaries + echo "git status before add" + git status + git add --all * + echo "git status after add" + git status + ''' + } + } stage('Build') { steps { container('container') { @@ -129,5 +594,40 @@ spec: } } } + stage('SWT-Commit binaries_if_needed') { + when { + allOf { + branch 'master' + expression { return fileExists ('${WORKSPACE}/tmp/build_changed.txt') } + } + } + steps { + withAnt(installation: 'apache-ant-latest', jdk: 'openjdk-jdk11-latest') { + sh ''' + git config --global user.email "eclipse-releng-bot@eclipse.org" + git config --global user.name "Eclipse Releng Bot" + + ant -f ${WORKSPACE}/eclipse.platform.swt/bundles/org.eclipse.swt/buildInternal.xml write_qualifier -Dlib.dir=${WORKSPACE} -Dbuild_changed=true + ant -f ${WORKSPACE}/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml commit_poms_and_binaries + ant -f ${WORKSPACE}/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml tag_projects + + pushd ${WORKSPACE}/eclipse.platform.swt + git status + git log -p -2 + popd + + pushd ${WORKSPACE}/eclipse.platform.swt.binaries + git status + git log -p -1 + popd + + if [[ "${params.skipCommit}" != "true" ]] + then + ant -f ${WORKSPACE}/eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml push_remote_from_workspace + fi + ''' + } + } + } } }