2022-04-10 12:51:06 +02:00
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
2022-08-24 00:50:16 +02:00
def buildTarget(String path, String cmake_toolchain = '', boolean should_package = true) {
2021-12-03 16:14:23 +01:00
final String system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
2022-06-10 22:41:14 +02:00
final String linker = "/usr/bin/${path}-ld"
2022-08-24 00:25:14 +02:00
final String build_directory = "cmake-build-${path}"
2022-08-24 02:45:31 +02:00
final boolean not_packer_compatible = path.contains('riscv') || (path.contains('aarch64') && path.contains('mingw'))
2022-08-24 00:50:16 +02:00
final boolean use_toolchain = cmake_toolchain != ''
2022-08-24 03:16:06 +02:00
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
}
2022-08-24 00:50:16 +02:00
}
2021-08-15 16:17:10 +02:00
}
2022-08-24 03:16:06 +02:00
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
}
2021-10-05 22:13:40 +02:00
/* Required Plugins:
- CMake
- Sidebar Link
- Workspace Cleanup
2022-04-10 12:41:04 +02:00
Required Compilers:
2022-06-10 23:43:30 +02:00
- G++ cross-compiler for riscv64
- Musl cross-compiling toolchains (archives ending in "-cross" from https://musl.cc/#binaries) for x86_64, i686, armel, armhf and aarch64, unzipped into /usr/, along with soft links from /usr/bin/ to the binaries
2022-06-10 22:15:51 +02:00
- Emscripten Clang (https://github.com/emscripten-core/emsdk) in /usr/share/
2022-06-10 22:58:22 +02:00
- MinGW32 G++/Clang (https://github.com/mstorsjo/llvm-mingw) for x86_64, i686, armhf and aarch64, (unzip the content of the folder in the tar.xz file) in /usr/, along with soft links from /usr/bin/ to the binaries
2022-06-11 17:21:48 +02:00
Optional Tools:
2022-06-11 17:12:38 +02:00
- Ninja
2022-08-02 20:04:46 +02:00
- UPX (d61edc9 or higher)
2021-10-05 22:13:40 +02:00
*/
2022-04-10 11:39:42 +02:00
pipeline {
2020-12-11 22:36:10 +01:00
agent any
options {
2021-03-24 16:58:48 +01:00
buildDiscarder(logRotator(numToKeepStr: '48', artifactNumToKeepStr: '96'))
2022-06-11 17:20:39 +02:00
timeout(time: 25, unit: 'MINUTES')
2021-02-21 16:45:14 +01:00
sidebarLinks([
2021-02-21 17:07:38 +01:00
[displayName: 'Gitea Repository', iconFileName: '/userContent/Yerbacon.png', urlName: 'https://gits.username404.fr/Username404-59/Yerbacon/src/branch/' + env.BRANCH_NAME]
2021-02-21 16:45:14 +01:00
])
2020-12-11 22:36:10 +01:00
}
triggers {
pollSCM('*/10 * * * *')
}
stages {
stage('Build') {
2022-08-24 03:16:06 +02:00
matrix {
agent any
axes {
axis {
name 'TARGET'
values(
'x86_64-linux-musl',
'i686-linux-musl',
'armel-linux-musleabi',
'armv7l-linux-musleabihf',
'aarch64-linux-musl',
'riscv64-linux-gnu',
'x86_64-w64-mingw32',
'i686-w64-mingw32',
'armv7-w64-mingw32',
'aarch64-w64-mingw32'
)
}
}
stages {
stage('Compile and package') {
steps {
buildTarget("${TARGET}")
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
upload_archives()
}
}
2022-03-13 10:23:06 +01:00
}
2021-08-09 18:02:05 +02:00
}
}
2022-08-24 03:16:06 +02:00
stage('Build using Emscripten') {
2021-08-09 18:02:05 +02:00
steps {
2022-08-24 03:16:06 +02:00
buildTarget('emscripten', '/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake', false)
2020-12-11 22:36:10 +01:00
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
2022-08-24 03:16:06 +02:00
upload_archives()
2020-12-11 22:36:10 +01:00
}
}
}
2021-10-05 22:03:42 +02:00
post {
always {
cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: false, notFailBuild: true, skipWhenFailed: false)
}
}
2020-12-11 22:36:10 +01:00
}