[4011b98] | 1 | #!groovy
|
---|
| 2 |
|
---|
| 3 | import groovy.transform.Field
|
---|
| 4 |
|
---|
| 5 | //===========================================================================================================
|
---|
| 6 | // Main loop of the compilation
|
---|
| 7 | //===========================================================================================================
|
---|
| 8 |
|
---|
[e018546] | 9 | // Globals
|
---|
[d198551] | 10 | @Field def BuildDir = null
|
---|
| 11 | @Field def SrcDir = null
|
---|
| 12 | @Field def Settings = null
|
---|
| 13 | @Field def Version = ''
|
---|
[4011b98] | 14 |
|
---|
[e018546] | 15 | // Local variables
|
---|
| 16 | def err = null
|
---|
| 17 | def log_needed = false
|
---|
[4011b98] | 18 |
|
---|
[e018546] | 19 | currentBuild.result = "SUCCESS"
|
---|
| 20 |
|
---|
| 21 | final commit, build
|
---|
| 22 | node {
|
---|
[8e58264] | 23 | //Wrap build to add timestamp to command line
|
---|
| 24 | wrap([$class: 'TimestamperBuildWrapper']) {
|
---|
| 25 | (commit, build) = prepare_build()
|
---|
[e018546] | 26 | }
|
---|
| 27 | }
|
---|
[4011b98] | 28 |
|
---|
[e018546] | 29 | node('x64') {
|
---|
| 30 | //Wrap build to add timestamp to command line
|
---|
| 31 | wrap([$class: 'TimestamperBuildWrapper']) {
|
---|
| 32 | BuildDir = pwd tmp: true
|
---|
| 33 | SrcDir = pwd tmp: false
|
---|
[8e58264] | 34 |
|
---|
[e018546] | 35 | Tools.Clean()
|
---|
| 36 | Tools.Checkout( commit )
|
---|
| 37 | Version = GetVersion( build )
|
---|
| 38 | Configure()
|
---|
| 39 | Package()
|
---|
| 40 | Test()
|
---|
| 41 | Archive()
|
---|
[4011b98] | 42 | }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | //===========================================================================================================
|
---|
| 46 | // Main compilation routines
|
---|
| 47 | //===========================================================================================================
|
---|
[8fe6040] | 48 | def GetVersion(build) {
|
---|
[7e366bd] | 49 | final pver = sh(
|
---|
| 50 | returnStdout: true,
|
---|
[ad915e0] | 51 | script: "sed 's/AC_INIT(\\[cfa-cc\\],\\[\\(.*\\)\\],\\[cforall@plg.uwaterloo.ca\\])/\\1/;t;d' ${SrcDir}/configure.ac"
|
---|
[7e366bd] | 52 | ).trim()
|
---|
| 53 |
|
---|
[8fe6040] | 54 | final version = "${pver}.${build}"
|
---|
[f78ead5] | 55 |
|
---|
[8fe6040] | 56 | echo "Package Version: ${pver}"
|
---|
| 57 | echo "Build Version: ${build}"
|
---|
| 58 | echo "Long Version: ${version}"
|
---|
| 59 | return version
|
---|
| 60 | }
|
---|
[4011b98] | 61 |
|
---|
[8e58264] | 62 | def Configure() {
|
---|
| 63 | Tools.BuildStage('Configure', true) {
|
---|
| 64 | // Configure must be run inside the tree
|
---|
| 65 | dir (SrcDir) {
|
---|
| 66 | // Generate the necessary build files
|
---|
| 67 | sh './autogen.sh'
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | // Build outside of the src tree to ease cleaning
|
---|
| 71 | dir (BuildDir) {
|
---|
| 72 | // Configure the compilation (Output is not relevant)
|
---|
| 73 | // Use the current directory as the installation target so nothing escapes the sandbox
|
---|
| 74 | // Also specify the compiler by hand
|
---|
| 75 | sh "${SrcDir}/configure CXX=g++-9 CC=gcc-9 AR=gcc-ar RANLIB=gcc-ranlib --quiet"
|
---|
| 76 |
|
---|
| 77 | // Configure libcfa
|
---|
| 78 | sh 'make -j 8 --no-print-directory configure-libcfa'
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | def Package() {
|
---|
| 84 | Tools.BuildStage('Package', true) {
|
---|
| 85 | dir (BuildDir) {
|
---|
| 86 | sh "make VERSION=${Version} dist"
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | def Test() {
|
---|
[8089fde] | 92 | Tools.BuildStage('Test', true) {
|
---|
[8e58264] | 93 | dir (BuildDir) {
|
---|
| 94 | sh "make VERSION=${Version} distcheck -j 8"
|
---|
| 95 | }
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | def Archive() {
|
---|
[8089fde] | 100 | Tools.BuildStage('Archive', true) {
|
---|
| 101 | dir (BuildDir) {
|
---|
| 102 | archiveArtifacts artifacts: "cfa-cc-*.tar.gz", fingerprint: true
|
---|
| 103 | }
|
---|
[8e58264] | 104 | }
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[4011b98] | 107 |
|
---|
| 108 | //===========================================================================================================
|
---|
| 109 | // Helper classes/variables/routines
|
---|
| 110 | //===========================================================================================================
|
---|
| 111 | def prepare_build() {
|
---|
| 112 | // prepare the properties
|
---|
[0a10dc8] | 113 | properties ([ \
|
---|
| 114 | buildDiscarder(logRotator( \
|
---|
| 115 | artifactDaysToKeepStr: '', \
|
---|
| 116 | artifactNumToKeepStr: '', \
|
---|
| 117 | daysToKeepStr: '730', \
|
---|
| 118 | numToKeepStr: '1000' \
|
---|
| 119 | )), \
|
---|
| 120 | [$class: 'ParametersDefinitionProperty', \
|
---|
| 121 | parameterDefinitions: [ \
|
---|
| 122 | [$class: 'StringParameterDefinition', \
|
---|
| 123 | description: 'The git commit to checkout', \
|
---|
| 124 | name: 'GitRef', \
|
---|
| 125 | defaultValue: '', \
|
---|
| 126 | ], \
|
---|
| 127 | [$class: 'StringParameterDefinition', \
|
---|
| 128 | description: 'Build Number to put into the version', \
|
---|
| 129 | name: 'Build', \
|
---|
| 130 | defaultValue: '0', \
|
---|
| 131 | ], \
|
---|
[4011b98] | 132 | ],
|
---|
| 133 | ]])
|
---|
| 134 |
|
---|
[4b138dd] | 135 | // It's unfortunate but it looks like we need to checkout the entire repo just to get
|
---|
| 136 | // - the pretty git printer
|
---|
| 137 | // - Jenkins.tools
|
---|
| 138 | checkout scm
|
---|
| 139 |
|
---|
[c2f6b79] | 140 | Tools = load "Jenkins/tools.groovy"
|
---|
[4b138dd] | 141 |
|
---|
[c3d3c22] | 142 | currentBuild.description = "Distributing Tarball"
|
---|
| 143 | def ref = params.GitRef ? params.GitRef : "HEAD"
|
---|
| 144 | echo "Distributing git commit ${ref}"
|
---|
[f78ead5] | 145 |
|
---|
[8fe6040] | 146 | return [params.GitRef, params.Build]
|
---|
[6855d14] | 147 | }
|
---|
[4011b98] | 148 |
|
---|