Commit 3ccebf92 authored by Dominik Charousset's avatar Dominik Charousset

Follow Groovy coding style and archive builds

parent da9956ac
#!/usr/bin/env groovy #!/usr/bin/env groovy
// List of CMake arguments used by most builds. // Default CMake flags for most builds (except coverage).
defaultCmakeArgs = '-DCAF_MORE_WARNINGS:BOOL=yes' \ defaultBuildFlags = [
+ ' -DCAF_ENABLE_RUNTIME_CHECKS:BOOL=yes' \ 'CAF_MORE_WARNINGS:BOOL=yes',
+ ' -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl' \ 'CAF_ENABLE_RUNTIME_CHECKS:BOOL=yes',
+ ' -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include' \ 'CAF_NO_OPENCL:BOOL=yes',
'OPENSSL_ROOT_DIR=/usr/local/opt/openssl',
'OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include',
]
// CMake flags for release builds.
releaseBuildFlags = defaultBuildFlags + [
]
// CMake flags for debug builds.
debugBuildFlags = defaultBuildFlags + [
'CAF_ENABLE_RUNTIME_CHECKS:BOOL=yes',
'CAF_ENABLE_ADDRESS_SANITIZER:BOOL=yes',
'CAF_LOG_LEVEL:STRING=4',
]
// Our build matrix. The keys are the operating system labels and the values // Our build matrix. The keys are the operating system labels and the values
// are lists of tool labels. // are lists of tool labels.
buildMatrix = [ buildMatrix = [
// Debug builds with ASAN + logging for various OS/compiler combinations. // Debug builds with ASAN + logging for various OS/compiler combinations.
['unix', [ ['Linux', [
builds: ['debug'], builds: ['debug'],
tools: ['gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'clang'], tools: ['gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8'],
cmakeArgs: defaultCmakeArgs cmakeArgs: debugBuildFlags,
+ ' -DCAF_LOG_LEVEL:STRING=4' ]],
+ ' -DCAF_ENABLE_ADDRESS_SANITIZER:BOOL=yes', ['macOS', [
builds: ['debug'],
tools: ['clang'],
cmakeArgs: debugBuildFlags,
]], ]],
// One release build per supported OS. FreeBSD and Windows have the least // One release build per supported OS. FreeBSD and Windows have the least
// testing outside Jenkins, so we also explicitly schedule debug builds. // testing outside Jenkins, so we also explicitly schedule debug builds.
['Linux', [ ['Linux', [
builds: ['release'], builds: ['release'],
tools: ['gcc', 'clang'], tools: ['gcc', 'clang'],
cmakeArgs: defaultCmakeArgs, cmakeArgs: releaseBuildFlags,
]], ]],
['macOS', [ ['macOS', [
builds: ['release'], builds: ['release'],
tools: ['clang'], tools: ['clang'],
cmakeArgs: defaultCmakeArgs, cmakeArgs: releaseBuildFlags,
]], ]],
['FreeBSD', [ ['FreeBSD', [
builds: ['debug'], // no release build for now, because it takes 1h builds: ['debug'], // no release build for now, because it takes 1h
tools: ['clang'], tools: ['clang'],
cmakeArgs: defaultCmakeArgs, cmakeArgs: debugBuildFlags,
]], ]],
['Windows', [ ['Windows', [
builds: ['debug', 'release'], builds: ['debug', 'release'],
tools: ['msvc'], tools: ['msvc'],
cmakeArgs: '-DCAF_BUILD_STATIC_ONLY:BOOL=yes' cmakeArgs: [
+ ' -DCAF_ENABLE_RUNTIME_CHECKS:BOOL=yes' 'CAF_BUILD_STATIC_ONLY:BOOL=yes',
+ ' -DCAF_NO_OPENCL:BOOL=yes', 'CAF_ENABLE_RUNTIME_CHECKS:BOOL=yes',
'CAF_NO_OPENCL:BOOL=yes',
],
]], ]],
// One Additional build for coverage reports. // One Additional build for coverage reports.
['unix', [ ['Linux', [
builds: ['debug'], builds: ['debug'],
tools: ['gcovr'], tools: ['gcc8 && gcovr'],
extraSteps: ['coverageReport'], extraSteps: ['coverageReport'],
cmakeArgs: '-DCAF_ENABLE_GCOV:BOOL=yes ' cmakeArgs: [
+ ' -DCAF_NO_EXCEPTIONS:BOOL=yes ' 'CAF_ENABLE_GCOV:BOOL=yes',
+ ' -DCAF_FORCE_NO_EXCEPTIONS:BOOL=yes', 'CAF_NO_EXCEPTIONS:BOOL=yes',
'CAF_FORCE_NO_EXCEPTIONS:BOOL=yes',
],
]], ]],
] ]
...@@ -80,15 +101,20 @@ def coverageReport() { ...@@ -80,15 +101,20 @@ def coverageReport() {
} }
} }
def cmakeSteps(buildType, cmakeArgs) { def cmakeSteps(buildType, cmakeArgs, installDir) {
def absInstallDir = pwd() + '/' + installDir
dir('caf-sources') {
// Configure and build. // Configure and build.
cmakeBuild([ cmakeBuild([
buildDir: 'build', buildDir: 'build',
buildType: buildType, buildType: buildType,
cmakeArgs: cmakeArgs, cmakeArgs: "-DCMAKE_INSTALL_PREFIX=\"$absInstallDir\" " + cmakeArgs,
installation: 'cmake in search path', installation: 'cmake in search path',
sourceDir: '.', sourceDir: '.',
steps: [[withCmake: true]], steps: [[
args: '--target install',
withCmake: true,
]],
]) ])
// Run unit tests. // Run unit tests.
ctest([ ctest([
...@@ -96,29 +122,42 @@ def cmakeSteps(buildType, cmakeArgs) { ...@@ -96,29 +122,42 @@ def cmakeSteps(buildType, cmakeArgs) {
installation: 'cmake in search path', installation: 'cmake in search path',
workingDir: 'build', workingDir: 'build',
]) ])
}
zip([
archive: true,
dir: installDir,
zipFile: "${installDir}.zip",
])
} }
def buildSteps(buildType, cmakeArgs) { // Builds `name` with CMake and runs the unit tests.
def buildSteps(buildType, cmakeArgs, installDir) {
echo "build stage: $STAGE_NAME" echo "build stage: $STAGE_NAME"
deleteDir() deleteDir()
dir(installDir) {
// Create directory.
}
unstash('caf-sources') unstash('caf-sources')
dir('caf-sources') {
if (STAGE_NAME.contains('Windows')) { if (STAGE_NAME.contains('Windows')) {
echo "Windows build on $NODE_NAME" echo "Windows build on $NODE_NAME"
withEnv(['PATH=C:\\Windows\\System32;C:\\Program Files\\CMake\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\bin']) { withEnv(['PATH=C:\\Windows\\System32;C:\\Program Files\\CMake\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\bin']) {
cmakeSteps(buildType, cmakeArgs) cmakeSteps(buildType, cmakeArgs, installDir)
} }
} else { } else {
echo "Unix build on $NODE_NAME" echo "Unix build on $NODE_NAME"
def leakCheck = STAGE_NAME.contains("Linux") && !STAGE_NAME.contains("clang") def leakCheck = STAGE_NAME.contains("Linux") && !STAGE_NAME.contains("clang")
withEnv(["label_exp=" + STAGE_NAME.toLowerCase(), withEnv(["label_exp=" + STAGE_NAME.toLowerCase(),
"ASAN_OPTIONS=detect_leaks=" + (leakCheck ? 1 : 0)]) { "ASAN_OPTIONS=detect_leaks=" + (leakCheck ? 1 : 0)]) {
cmakeSteps(buildType, cmakeArgs) cmakeSteps(buildType, cmakeArgs, installDir)
}
} }
} }
} }
// Concatenates CMake flags into a single string.
def makeFlags(xs) {
xs.collect { x -> '-D' + x }.join(' ')
}
// Builds a stage for given builds. Results in a parallel stage `if builds.size() > 1`. // Builds a stage for given builds. Results in a parallel stage `if builds.size() > 1`.
def makeBuildStages(matrixIndex, builds, lblExpr, settings) { def makeBuildStages(matrixIndex, builds, lblExpr, settings) {
builds.collectEntries { buildType -> builds.collectEntries { buildType ->
...@@ -129,8 +168,9 @@ def makeBuildStages(matrixIndex, builds, lblExpr, settings) { ...@@ -129,8 +168,9 @@ def makeBuildStages(matrixIndex, builds, lblExpr, settings) {
node(lblExpr) { node(lblExpr) {
stage(id) { stage(id) {
try { try {
def installDir = "$lblExpr && $buildType"
withEnv(buildEnvironments[lblExpr] ?: []) { withEnv(buildEnvironments[lblExpr] ?: []) {
buildSteps(buildType, settings['cmakeArgs'] ?: '') buildSteps(buildType, makeFlags(settings['cmakeArgs']), installDir)
(settings['extraSteps'] ?: []).each { fun -> "$fun"() } (settings['extraSteps'] ?: []).each { fun -> "$fun"() }
} }
} finally { } finally {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment