Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    re11957e rabc2a643  
    22
    33import groovy.transform.Field
    4 
    5 // For skipping stages
    6 import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
    74
    85//===========================================================================================================
     
    1512        SrcDir    = pwd tmp: false
    1613        Settings  = null
    17         StageName = ''
     14        Tools     = null
    1815
    1916        // Local variables
     
    3330                                SrcDir    = pwd tmp: false
    3431
    35                                 clean()
    36 
    37                                 checkout()
     32                                Tools.Clean()
     33
     34                                Tools.Checkout()
    3835
    3936                                build()
     
    5754        //attach the build log to the email
    5855        catch (Exception caughtError) {
    59                 //rethrow error later
     56                // Store the result of the build log
     57                currentBuild.result = "FAILURE"
     58
     59                // An error has occured, the build log is relevent
     60                log_needed = true
     61
     62                // rethrow error later
    6063                err = caughtError
    6164
     65                // print the error so it shows in the log
    6266                echo err.toString()
    63 
    64                 //An error has occured, the build log is relevent
    65                 log_needed = true
    66 
    67                 //Store the result of the build log
    68                 currentBuild.result = "${StageName} FAILURE".trim()
    6967        }
    7068
     
    8482// Main compilation routines
    8583//===========================================================================================================
    86 def clean() {
    87         build_stage('Cleanup', true) {
    88                 // clean the build by wipping the build directory
    89                 dir(BuildDir) {
    90                         deleteDir()
    91                 }
    92         }
    93 }
    94 
    95 //Compilation script is done here but environnement set-up and error handling is done in main loop
    96 def checkout() {
    97         build_stage('Checkout', true) {
    98                 //checkout the source code and clean the repo
    99                 final scmVars = checkout scm
    100                 Settings.GitNewRef = scmVars.GIT_COMMIT
    101                 Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT
    102 
    103                 echo GitLogMessage()
    104 
    105                 // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles
    106                 // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles
    107                 // and these cause more problems.
    108                 sh 'find . -name Makefile.in -exec touch {} +'
    109         }
    110 }
    111 
    11284def build() {
    11385        debug = true
    11486        release = Settings.RunAllTests || Settings.RunBenchmark
    115         build_stage('Build : configure', true) {
     87        Tools.BuildStage('Build : configure', true) {
     88                // Configure must be run inside the tree
     89                dir (SrcDir) {
     90                        // Generate the necessary build files
     91                        sh './autogen.sh'
     92                }
     93
    11694                // Build outside of the src tree to ease cleaning
    11795                dir (BuildDir) {
    118                         //Configure the conpilation (Output is not relevant)
     96                        //Configure the compilation (Output is not relevant)
    11997                        //Use the current directory as the installation target so nothing escapes the sandbox
    12098                        //Also specify the compiler by hand
     
    126104                        }
    127105
    128                         sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} ${targets} --quiet"
     106                        ast = Settings.NewAST ? "--enable-new-ast" : "--disable-new-ast"
     107
     108                        sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} AR=gcc-ar RANLIB=gcc-ranlib ${targets} ${ast} --quiet --prefix=${BuildDir}"
    129109
    130110                        // Configure libcfa
     
    133113        }
    134114
    135         build_stage('Build : cfa-cpp', true) {
     115        Tools.BuildStage('Build : cfa-cpp', true) {
    136116                // Build outside of the src tree to ease cleaning
    137117                dir (BuildDir) {
     
    144124        }
    145125
    146         build_stage('Build : libcfa(debug)', debug) {
     126        Tools.BuildStage('Build : libcfa(debug)', debug) {
    147127                // Build outside of the src tree to ease cleaning
    148128                dir (BuildDir) {
     
    151131        }
    152132
    153         build_stage('Build : libcfa(nodebug)', release) {
     133        Tools.BuildStage('Build : libcfa(nodebug)', release) {
    154134                // Build outside of the src tree to ease cleaning
    155135                dir (BuildDir) {
    156136                        sh "make -j 8 --no-print-directory -C libcfa/${Settings.Architecture.name}-nodebug"
     137                }
     138        }
     139
     140        Tools.BuildStage('Build : install', true) {
     141                // Build outside of the src tree to ease cleaning
     142                dir (BuildDir) {
     143                        sh "make -j 8 --no-print-directory install"
    157144                }
    158145        }
     
    161148def test() {
    162149        try {
    163                 build_stage('Test: short', !Settings.RunAllTests) {
     150                Tools.BuildStage('Test: short', !Settings.RunAllTests) {
    164151                        dir (BuildDir) {
    165152                                //Run the tests from the tests directory
     
    168155                }
    169156
    170                 build_stage('Test: full', Settings.RunAllTests) {
     157                Tools.BuildStage('Test: full', Settings.RunAllTests) {
    171158                        dir (BuildDir) {
    172159                                        //Run the tests from the tests directory
     
    179166                echo "Archiving core dumps"
    180167                dir (BuildDir) {
    181                         archiveArtifacts artifacts: "tests/crashes/**/*", fingerprint: true
     168                        archiveArtifacts artifacts: "tests/crashes/**/*,lib/**/lib*.so*", fingerprint: true
    182169                }
    183170                throw err
     
    186173
    187174def benchmark() {
    188         build_stage('Benchmark', Settings.RunBenchmark) {
     175        Tools.BuildStage('Benchmark', Settings.RunBenchmark) {
    189176                dir (BuildDir) {
    190177                        //Append bench results
     
    195182
    196183def build_doc() {
    197         build_stage('Documentation', Settings.BuildDocumentation) {
     184        Tools.BuildStage('Documentation', Settings.BuildDocumentation) {
    198185                dir ('doc/user') {
    199186                        make_doc()
     
    207194
    208195def publish() {
    209         build_stage('Publish', true) {
     196        Tools.BuildStage('Publish', true) {
    210197
    211198                if( Settings.Publish && !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
     
    215202
    216203                //Then publish the results
    217                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'       , groupCompile    , false, 'Compilation')
    218                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'  , groupCompile    , true , 'Compilation (relative)')
    219                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'     , groupConcurrency, false, 'Context Switching')
    220                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff', groupConcurrency, true , 'Context Switching (relative)')
    221                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'         , groupConcurrency, false, 'Mutual Exclusion')
    222                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'    , groupConcurrency, true , 'Mutual Exclusion (relative)')
    223                 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal'        , groupConcurrency, false, 'Internal and External Scheduling')
    224                 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal.diff'   , groupConcurrency, true , 'Internal and External Scheduling (relative)')
     204                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'        , groupCompile    , false, 'Compilation')
     205                do_plot(Settings.RunBenchmark && Settings.Publish, 'compile.diff'   , groupCompile    , true , 'Compilation (relative)')
     206                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch'      , groupConcurrency, false, 'Context Switching')
     207                do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch.diff' , groupConcurrency, true , 'Context Switching (relative)')
     208                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'          , groupConcurrency, false, 'Mutual Exclusion')
     209                do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex.diff'     , groupConcurrency, true , 'Mutual Exclusion (relative)')
     210                do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling'     , groupConcurrency, false, 'Internal and External Scheduling')
     211                do_plot(Settings.RunBenchmark && Settings.Publish, 'scheduling.diff', groupConcurrency, true , 'Internal and External Scheduling (relative)')
    225212        }
    226213}
     
    229216//Routine responsible of sending the email notification once the build is completed
    230217//===========================================================================================================
    231 @NonCPS
    232 def SplitLines(String text) {
    233         def list = []
    234 
    235         text.eachLine {
    236                 list += it
    237         }
    238 
    239         return list
    240 }
    241 
    242 def GitLogMessage() {
    243         if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"
    244 
    245         def oldRef = Settings.GitOldRef
    246         def newRef = Settings.GitNewRef
    247 
    248         def revText = sh(returnStdout: true, script: "git rev-list ${oldRef}..${newRef}").trim()
    249         def revList = SplitLines( revText )
    250 
    251         def gitUpdate = ""
    252         revList.each { rev ->
    253                 def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
    254                 gitUpdate = gitUpdate + "       via  ${rev} (${type})"
    255         }
    256 
    257         def rev = oldRef
    258         def type = sh(returnStdout: true, script: "git cat-file -t ${rev}").trim()
    259         gitUpdate = gitUpdate + "      from  ${rev} (${type})"
    260 
    261         def gitLog    = sh(returnStdout: true, script: "git rev-list --format=short ${oldRef}...${newRef}").trim()
    262 
    263         def gitDiff   = sh(returnStdout: true, script: "git diff --stat --color ${newRef} ${oldRef}").trim()
    264         gitDiff = gitDiff.replace('[32m', '<span style="color: #00AA00;">')
    265         gitDiff = gitDiff.replace('[31m', '<span style="color: #AA0000;">')
    266         gitDiff = gitDiff.replace('[m', '</span>')
    267 
    268         return """
    269 <pre>
    270 The branch ${env.BRANCH_NAME} has been updated.
    271 ${gitUpdate}
    272 </pre>
    273 
    274 <p>Check console output at ${env.BUILD_URL} to view the results.</p>
    275 
    276 <p>- Status --------------------------------------------------------------</p>
    277 
    278 <p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p>
    279 
    280 <p>- Log -----------------------------------------------------------------</p>
    281 
    282 <pre>
    283 ${gitLog}
    284 </pre>
    285 
    286 <p>-----------------------------------------------------------------------</p>
    287 <pre>
    288 Summary of changes:
    289 ${gitDiff}
    290 </pre>
    291 """
    292 }
    293 
    294218//Standard build email notification
    295219def email(boolean log) {
     
    303227generated because of a git hooks/post-receive script following
    304228a ref change which was pushed to the C\u2200 repository.</p>
    305 """ + GitLogMessage()
     229""" + Tools.GitLogMessage()
    306230
    307231        def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
     
    325249        public String CXX
    326250        public String CC
    327 
    328         CC_Desc(String name, String CXX, String CC) {
     251        public String lto
     252
     253        CC_Desc(String name, String CXX, String CC, String lto) {
    329254                this.name = name
    330255                this.CXX = CXX
    331                 this.CC = CC
     256                this.CC  = CC
     257                this.lto = lto
    332258        }
    333259}
     
    349275        public final CC_Desc Compiler
    350276        public final Arch_Desc Architecture
     277        public final Boolean NewAST
    351278        public final Boolean RunAllTests
    352279        public final Boolean RunBenchmark
     
    364291                switch( param.Compiler ) {
    365292                        case 'gcc-9':
    366                                 this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9')
     293                                this.Compiler = new CC_Desc('gcc-9', 'g++-9', 'gcc-9', '-flto=auto')
    367294                        break
    368295                        case 'gcc-8':
    369                                 this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8')
     296                                this.Compiler = new CC_Desc('gcc-8', 'g++-8', 'gcc-8', '-flto=auto')
    370297                        break
    371298                        case 'gcc-7':
    372                                 this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7')
     299                                this.Compiler = new CC_Desc('gcc-7', 'g++-7', 'gcc-7', '-flto=auto')
    373300                        break
    374301                        case 'gcc-6':
    375                                 this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
     302                                this.Compiler = new CC_Desc('gcc-6', 'g++-6', 'gcc-6', '-flto=auto')
    376303                        break
    377304                        case 'gcc-5':
    378                                 this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
     305                                this.Compiler = new CC_Desc('gcc-5', 'g++-5', 'gcc-5', '-flto=auto')
    379306                        break
    380307                        case 'gcc-4.9':
    381                                 this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
     308                                this.Compiler = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9', '-flto=auto')
    382309                        break
    383310                        case 'clang':
    384                                 this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6')
     311                                this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-9', '-flto=thin -flto-jobs=0')
    385312                        break
    386313                        default :
     
    400327
    401328                this.IsSandbox          = (branch == "jenkins-sandbox")
     329                this.NewAST             = param.NewAST
    402330                this.RunAllTests        = param.RunAllTests
    403331                this.RunBenchmark       = param.RunBenchmark
     
    409337                this.DescShort = "${ this.Compiler.name }:${ this.Architecture.name }${full}"
    410338
     339                final ast = this.NewAST ? "New AST" : "Old AST"
    411340                this.DescLong = """Compiler              : ${ this.Compiler.name } (${ this.Compiler.CXX }/${ this.Compiler.CC })
     341AST Version             : ${ ast.toString() }
    412342Architecture            : ${ this.Architecture.name }
    413343Arc Flags               : ${ this.Architecture.flags }
     
    439369        // prepare the properties
    440370        properties ([                                                                                                   \
     371                buildDiscarder(logRotator(                                                                              \
     372                        artifactDaysToKeepStr: '',                                                                      \
     373                        artifactNumToKeepStr: '',                                                                       \
     374                        daysToKeepStr: '730',                                                                           \
     375                        numToKeepStr: '1000'                                                                            \
     376                )),                                                                                                             \
    441377                [$class: 'ParametersDefinitionProperty',                                                                \
    442378                        parameterDefinitions: [                                                                         \
     
    444380                                        description: 'Which compiler to use',                                   \
    445381                                        name: 'Compiler',                                                                       \
    446                                         choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',                                   \
     382                                        choices: 'gcc-9\ngcc-8\ngcc-7\ngcc-6\ngcc-5\ngcc-4.9\nclang',   \
    447383                                        defaultValue: 'gcc-8',                                                          \
    448384                                ],                                                                                              \
     
    454390                                ],                                                                                              \
    455391                                [$class: 'BooleanParameterDefinition',                                                  \
     392                                        description: 'If true, build compiler using new AST',           \
     393                                        name: 'NewAST',                                                                         \
     394                                        defaultValue: true,                                                             \
     395                                ],                                                                                              \
     396                                [$class: 'BooleanParameterDefinition',                                                  \
    456397                                        description: 'If false, only the quick test suite is ran',              \
    457398                                        name: 'RunAllTests',                                                            \
     
    481422                ]])
    482423
    483         // It's unfortunate but it looks like we need to checkout the entire repo just to get the pretty git printer
     424        // It's unfortunate but it looks like we need to checkout the entire repo just to get
     425        // - the pretty git printer
     426        // - Jenkins.tools
    484427        checkout scm
     428
     429        Tools = load "Jenkins/tools.groovy"
    485430
    486431        final settings = new BuildSettings(params, env.BRANCH_NAME)
     
    490435
    491436        return settings
    492 }
    493 
    494 def build_stage(String name, boolean run, Closure block ) {
    495         StageName = name
    496         echo " -------- ${StageName} -------- "
    497         if(run) {
    498                 stage(name, block)
    499         } else {
    500                 stage(name) { Utils.markStageSkippedForConditional(STAGE_NAME) }
    501         }
    502437}
    503438
Note: See TracChangeset for help on using the changeset viewer.