Jenkinsfile: Add two parameters to buildTarget to simplify the script
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
7846634165
commit
5fc16d7d41
|
@ -1,17 +1,19 @@
|
||||||
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
|
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 system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
|
||||||
final String linker = "/usr/bin/${path}-ld"
|
final String linker = "/usr/bin/${path}-ld"
|
||||||
final String build_directory = "cmake-build-${path}"
|
final String build_directory = "cmake-build-${path}"
|
||||||
final boolean is_riscv = path.contains('riscv')
|
final boolean is_riscv = path.contains('riscv')
|
||||||
|
final boolean use_toolchain = cmake_toolchain != ''
|
||||||
// Note: CMake 3.20 or higher is needed
|
// Note: CMake 3.20 or higher is needed
|
||||||
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
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()
|
generator: cmake_generator()
|
||||||
cmake arguments: "--build ./$build_directory --target ybcon", installation: 'Latest'
|
cmake arguments: "--build ./$build_directory --target ybcon", installation: 'Latest'
|
||||||
|
if (should_package) {
|
||||||
cpack installation: 'Latest', workingDir: build_directory
|
cpack installation: 'Latest', workingDir: build_directory
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Required Plugins:
|
/* Required Plugins:
|
||||||
|
@ -47,12 +49,7 @@ pipeline {
|
||||||
echo "Building the ${env.BRANCH_NAME} branch.."
|
echo "Building the ${env.BRANCH_NAME} branch.."
|
||||||
buildTarget('x86_64-linux-musl')
|
buildTarget('x86_64-linux-musl')
|
||||||
buildTarget('i686-linux-musl')
|
buildTarget('i686-linux-musl')
|
||||||
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
|
buildTarget('emscripten', '/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake', false)
|
||||||
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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Build for other architectures') {
|
stage('Build for other architectures') {
|
||||||
|
@ -80,7 +77,7 @@ pipeline {
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Deploying....'
|
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') {
|
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
|
||||||
archiveArtifacts artifacts: 'cmake-build-*/*Windows.*.exe, cmake-build-*/*.zip'
|
archiveArtifacts artifacts: 'cmake-build-*/*Windows.*.exe, cmake-build-*/*.zip'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue