diff --git a/Jenkinsfile b/Jenkinsfile index aeb225ea0fa..f06da509bdc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,6 +53,18 @@ def getNativeJdkUrl(String os, String arch){ // To update the used JDK version u return "https://download.eclipse.org/justj/jres/17/downloads/20230428_1804/org.eclipse.justj.openjdk.hotspot.jre.minimal.stripped-17.0.7-${os}-${arch}.tar.gz" } +def getLatestGitTag() { + return sh(script: 'git describe --abbrev=0 --tags --match v[0-9][0-9][0-9][0-9]*', returnStdout: true).strip() +} + +def getSWTVersions() { // must be called from the repository root + def props = readProperties(file: 'bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak') + props['new_rev'] = props['rev'].toInteger() + 1 + props['swt_version'] = props['maj_ver'] + props['min_ver'] + 'r' + props['rev'] + props['new_version'] = props['maj_ver'] + props['min_ver'] + 'r' + props['new_rev'] + return props +} + pipeline { options { skipDefaultCheckout() // Specialiced checkout is performed below @@ -104,15 +116,66 @@ pipeline { } stage('Check if SWT-binaries build is needed') { steps { - withAnt(installation: 'apache-ant-latest', jdk: 'openjdk-jdk11-latest') { // nashorn javascript-engine required in ant-scripts + dir('eclipse.platform.swt') { sh''' java -version git config --global user.email 'eclipse-releng-bot@eclipse.org' git config --global user.name 'Eclipse Releng Bot' - - ant -f eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml check_preprocessing - ant -f eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml new_build_with_create_file -DTAG=HEAD ''' + script { + def swtTag = getLatestGitTag() + echo "Current tag=${swtTag}." + boolean nativesChanged = false + dir('bundles/org.eclipse.swt') { + // Check preprocessing is completed + sh ''' + notProcessed=$(grep -R --include='*.java' --line-number --fixed-strings -e 'int /*long*/' -e 'float /*double*/' -e 'int[] /*long[]*/' -e 'float[] /*double[]*/' .) + if [[ -n "$notProcessed" ]]; then + echo There are files with the wrong long /*int*/ preprocessing: + echo $notProcessed + exit 1 + fi + ''' + def sourceFoldersProps = readProperties(file: 'nativeSourceFolders.properties') + def sources = sourceFoldersProps.collectEntries{ k, src -> [ k, src.split(',').collect{ f -> '\'' + f + '\''}.join(' ') ] } + def diff = sh(script: "git diff HEAD ${swtTag} ${sources.values().join(' ')}", returnStdout: true) + nativesChanged = !diff.trim().isEmpty() + echo "Natives changed: ${nativesChanged}, since ${swtTag}" + } + if (nativesChanged) { + def swtVersions = getSWTVersions() + def swt_version = swtVersions['swt_version'] + // Delete native binaries to be replaced + sh """ + rm -f binaries/org.eclipse.swt.gtk.*/lib*-${swt_version}.so + rm -f binaries/org.eclipse.swt.win32.*/*-${swt_version}.dll + rm -f binaries/org.eclipse.swt.cocoa.*/lib*-${swt_version}.jnilib + """ + + def rev = swtVersions['rev'] + def new_rev = swtVersions['new_rev'] + def comma_ver = swtVersions['comma_ver'] + def new_comma_ver = swtVersions['maj_ver'] + ',' + swtVersions['min_ver'] + ',' + new_rev + ',0' + echo "Incrementing version from ${swt_version} to ${swtVersions['new_version']}; new comma_ver=${new_comma_ver}" + + def libraryFile = 'bundles/org.eclipse.swt/Eclipse SWT PI/common/org/eclipse/swt/internal/Library.java' + def libraryFileContentUpdated = readFile(file: libraryFile) + .replace("REVISION = ${rev}","REVISION = ${new_rev}") + writeFile(file: libraryFile, text: libraryFileContentUpdated) + + def makeCommonFile = 'bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak' + def makeCommonFileContentUpdated = readFile(file: makeCommonFile) + .replace("rev=${rev}", "rev=${new_rev}") + .replace("comma_ver=${comma_ver}", "comma_ver=${new_comma_ver}") + writeFile(file: makeCommonFile, text: makeCommonFileContentUpdated) + + sh """ + git add '${file_library}' '${file_version}' '${file_make_common} + git status + """ + writeFile(file: '../tmp/natives_changed.txt', text:'true') + } + } } } } @@ -252,22 +315,35 @@ pipeline { expression { return params.forceNativeBuilds || fileExists('tmp/natives_changed.txt') } } steps { - withAnt(installation: 'apache-ant-latest', jdk: 'openjdk-jdk11-latest') { // nashorn javascript-engine required in ant-scripts - //The maven build reads the git-history so we should have to commit the native-binaries before building + dir('eclipse.platform.swt') { + script { + def swt_version = getSWTVersions()['swt_version'] // versions are read from updated file + sh """ + find binaries -name "*${swt_version}*" -type f -exec chmod 644 {} + + git add --all * + echo "git status after git add" + 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}" + } + } + } sh ''' - pushd eclipse.platform.swt - git add --all * - echo "git status after add" - git status - popd - - ant -f eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml commit_binaries - ant -f eclipse.platform.swt/bundles/org.eclipse.swt/buildSWT.xml tag_projects - - pushd eclipse.platform.swt git status git log -p -2 - popd ''' } } @@ -300,23 +376,17 @@ pipeline { } steps { sshagent(['github-bot-ssh']) { - script { - def newSWTNativesTag = null; - dir('eclipse.platform.swt') { - newSWTNativesTag = sh(script: 'git describe --abbrev=0 --tags --match v[0-9][0-9][0-9][0-9]*', returnStdout: true).strip() - } - echo "newSWTNativesTag: ${newSWTNativesTag}" + dir('eclipse.platform.swt') { sh """ + newSWTNativesTag = ${getLatestGitTag()} # Check for the master-branch as late as possible to have as much of the same behaviour as possible if [[ '${BRANCH_NAME}' == master ]] || [[ '${BRANCH_NAME}' =~ R[0-9]+_[0-9]+(_[0-9]+)?_maintenance ]]; then if [[ ${params.skipCommit} != true ]]; then #Don't rebase and just fail in case another commit has been pushed to the master/maintanance branch in the meantime - pushd eclipse.platform.swt git push origin HEAD:refs/heads/${BRANCH_NAME} git push origin refs/tags/${newSWTNativesTag} - popd exit 0 else @@ -326,9 +396,7 @@ pipeline { 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. - pushd eclipse.platform.swt git log -n 2 - popd """ } } diff --git a/bundles/org.eclipse.swt/buildSWT.xml b/bundles/org.eclipse.swt/buildSWT.xml deleted file mode 100644 index 9ddced45955..00000000000 --- a/bundles/org.eclipse.swt/buildSWT.xml +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - Checking ${fragment} - - - - - - - - Matched files ${toString:match} - - - - - - - - - - Found ${match_count} libraries with version ${swt_version} and ${not_match_count} libraries with old versions - - - - - - - - - - Success - - - - - - - - - - - - - - ${badfiles} - - - - - - - - - - - - - - - - - - - Incrementing version from ${swt_version} to ${new_version}... - - - - - - - - - - - - - - - - - Current tag=${swt_tag}. - - - - - - - - - - - - - - - - New tag=${swt_new_tag}. - - - - - - - - - Version=${swt_version}; New=${new_version}; New comma_ver=${new_comma_ver} - - - - - - - - - - - - - - Natives changed: ${natives_changed} since ${swt_tag} - - - - - - - - - - - - - - - swt_version is ${swt_version} - - - - - - - Files to remove is ${toString:removeid} - - - - - - - - - - - - - - - - - Files to add is ${toString:addid} - - - - - - - - Removing files - - - Adding files - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Creating file ${fileName}" - true - - -