Jenkinsfile: Add two parameters to buildTarget to simplify the script

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-08-24 00:50:16 +02:00
parent 7846634165
commit 5fc16d7d41
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 8 additions and 11 deletions

19
Jenkinsfile vendored
View File

@ -1,17 +1,19 @@
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
String no_compilation_cache_flags() { return '-DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON' }
def buildTarget(String path) {
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 is_riscv = path.contains('riscv')
final boolean use_toolchain = cmake_toolchain != ''
// Note: CMake 3.20 or higher is needed
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
cmakeArgs: "--no-warn-unused-cli -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=${!is_riscv ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON ${no_compilation_cache_flags()}",
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=${!(is_riscv || 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'
cpack installation: 'Latest', workingDir: build_directory
if (should_package) {
cpack installation: 'Latest', workingDir: build_directory
}
}
/* Required Plugins:
@ -47,12 +49,7 @@ pipeline {
echo "Building the ${env.BRANCH_NAME} branch.."
buildTarget('x86_64-linux-musl')
buildTarget('i686-linux-musl')
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
cmakeBuild buildDir: "cmake-build-release-emscripten", buildType: 'release', cleanBuild: true, installation: 'Latest',
cmakeArgs: "-DCMAKE_TOOLCHAIN_FILE=\"/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake\" ${no_compilation_cache_flags()} -DNO_SELF_PACKER=ON",
generator: cmake_generator()
cmake arguments: "--build ./cmake-build-release-emscripten", installation: 'Latest'
}
buildTarget('emscripten', '/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake', false)
}
}
stage('Build for other architectures') {
@ -80,7 +77,7 @@ pipeline {
stage('Deploy') {
steps {
echo 'Deploying....'
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-release-emscripten/*.js', fingerprint: false
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-*/*.js', fingerprint: false
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
archiveArtifacts artifacts: 'cmake-build-*/*Windows.*.exe, cmake-build-*/*.zip'
}