Jenkinsfile: Separate compilation and packaging, move the buildTarget function's content into the "Compile" stage, and clean the workspace of the matrix too
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
bf1cea3e77
commit
8004d3a283
|
@ -1,26 +1,5 @@
|
|||
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
|
||||
|
||||
def buildTarget(String path, String cmake_toolchain = '', boolean should_package = true) {
|
||||
final String system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
|
||||
final String linker = "/usr/bin/${path}-ld"
|
||||
final String build_directory = "cmake-build-${path}"
|
||||
final boolean not_packer_compatible = path.contains('riscv') || (path.contains('aarch64') && path.contains('mingw'))
|
||||
final boolean use_toolchain = cmake_toolchain != ''
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
// Note: CMake 3.20 or higher is needed
|
||||
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
||||
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${cmake_toolchain}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCMAKE_SYSTEM_PROCESSOR=\"${path.substring(0, path.indexOf('-'))}\" -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ -DCMAKE_LINKER=${fileExists("${linker}.gold") ? "${linker}.gold" : linker} -DCMAKE_AR=/usr/bin/${path}-ar -DCMAKE_RC_COMPILER=/usr/bin/${path}-windres -DCMAKE_EXE_LINKER_FLAGS=-static"} -DNO_SELF_PACKER=${!(not_packer_compatible || use_toolchain) ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON -DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON",
|
||||
generator: cmake_generator()
|
||||
cmake arguments: "--build ./$build_directory --target ybcon", installation: 'Latest'
|
||||
if (should_package) {
|
||||
cpack installation: 'Latest', workingDir: build_directory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def upload_archives() {
|
||||
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-*/*.js, cmake-build-*/*Windows.*.exe, cmake-build-*/*.zip', fingerprint: false
|
||||
}
|
||||
def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: false, notFailBuild: true, skipWhenFailed: false) }
|
||||
|
||||
/* Required Plugins:
|
||||
- CMake
|
||||
|
@ -66,40 +45,51 @@ pipeline {
|
|||
'x86_64-w64-mingw32',
|
||||
'i686-w64-mingw32',
|
||||
'armv7-w64-mingw32',
|
||||
'aarch64-w64-mingw32'
|
||||
'aarch64-w64-mingw32',
|
||||
'/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake'
|
||||
)
|
||||
}
|
||||
}
|
||||
stages {
|
||||
stage('Compile and package') {
|
||||
stage('Compile') {
|
||||
steps {
|
||||
buildTarget("${TARGET}")
|
||||
script {
|
||||
final String path = "${TARGET}"
|
||||
final String system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
|
||||
final String linker = "/usr/bin/${path}-ld"
|
||||
final boolean not_packer_compatible = path.contains('riscv') || (path.contains('aarch64') && path.contains('mingw'))
|
||||
final boolean use_toolchain = path.endsWith('.cmake')
|
||||
final String build_directory = "cmake-build-${use_toolchain ? path.substring(path.lastIndexOf('/') + 1, path.length() - 6) : path}".toLowerCase()
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
// Note: CMake 3.20 or higher is needed
|
||||
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
||||
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${path}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCMAKE_SYSTEM_PROCESSOR=\"${path.substring(0, path.indexOf('-'))}\" -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ -DCMAKE_LINKER=${fileExists("${linker}.gold") ? "${linker}.gold" : linker} -DCMAKE_AR=/usr/bin/${path}-ar -DCMAKE_RC_COMPILER=/usr/bin/${path}-windres -DCMAKE_EXE_LINKER_FLAGS=-static"} -DNO_SELF_PACKER=${!(not_packer_compatible || use_toolchain) ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON -DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON",
|
||||
generator: cmake_generator()
|
||||
cmake arguments: "--build ./$build_directory --target ybcon", installation: 'Latest'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Package') {
|
||||
when { equals expected: true, actual: !"${TARGET}".endsWith('.cmake') }
|
||||
steps {
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
cpack installation: 'Latest', workingDir: "cmake-build-${TARGET}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
echo 'Deploying....'
|
||||
upload_archives()
|
||||
catchError(buildResult: "${TARGET}".endsWith('.cmake') ? 'FAILURE' : 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-*/*.js, cmake-build-*/*Windows.*.exe, cmake-build-*/*.zip', fingerprint: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build using Emscripten') {
|
||||
steps {
|
||||
buildTarget('emscripten', '/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake', false)
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
echo 'Deploying....'
|
||||
upload_archives()
|
||||
post { always { clean_workspace() } }
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: false, notFailBuild: true, skipWhenFailed: false)
|
||||
}
|
||||
}
|
||||
post { always { clean_workspace() } }
|
||||
}
|
Loading…
Reference in New Issue