2022-04-10 12:51:06 +02:00
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
2022-08-24 11:14:04 +02:00
def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: false, notFailBuild: true, skipWhenFailed: false) }
2022-10-07 22:59:00 +02:00
boolean use_yarn_or_npm() { return fileExists('/usr/bin/yarn') || fileExists('/usr/bin/npm') }
2022-08-24 03:16:06 +02:00
2021-10-05 22:13:40 +02:00
/* Required Plugins:
2023-08-17 12:00:32 +02:00
- CMake 3.21 or higher
2021-10-05 22:13:40 +02:00
- Sidebar Link
- Workspace Cleanup
2022-04-10 12:41:04 +02:00
Required Compilers:
2022-11-25 19:44:34 +01:00
- Musl cross-compiling toolchains (archives ending in "-cross" from https://musl.cc/#binaries) for x86_64, i686, armel, armhf, aarch64 and riscv64, unzipped into /usr/, along with soft links from /usr/bin/ to the binaries
2023-07-27 03:53:34 +02:00
- Emscripten Clang (https://github.com/emscripten-core/emsdk; the 3.1.30 version is known to work) 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
2023-08-17 12:00:32 +02:00
- Android NDK Clang (https://ci.android.com/builds/submitted/10493228/linux/latest/android-ndk-10493228-linux-x86_64.zip) unzipped as /usr/android-ndk
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)
2022-10-07 22:59:00 +02:00
- Vercel PKG (https://github.com/vercel/pkg)
- LDID (https://github.com/sbingner/ldid)
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(
2022-08-24 17:58:12 +02:00
'x86_64-linux-musl (RPM=x86_64, DEB=amd64)',
2023-08-16 22:06:37 +02:00
'i686-linux-musl (RPM=i686, DEB=i386)',
2022-08-24 17:58:12 +02:00
'armel-linux-musleabi (RPM=armv4l, DEB=armel)',
'armv7l-linux-musleabihf (RPM=armv7hl, DEB=armhf)',
'aarch64-linux-musl (RPM=aarch64, DEB=arm64)',
2022-11-25 19:44:34 +01:00
'riscv64-linux-musl (RPM=riscv64, DEB=riscv64)',
2022-08-24 17:58:12 +02:00
'x86_64-w64-mingw32 (RPM=x86_64, DEB=amd64)',
'i686-w64-mingw32 (RPM=i386, DEB=i386)',
'armv7-w64-mingw32 (RPM=armv7hl, DEB=armhf)',
'aarch64-w64-mingw32 (RPM=aarch64, DEB=arm64)',
2023-08-17 12:00:32 +02:00
'x86_64-linux-android21 (RPM=x86_64, DEB=amd64) -> x86_64',
'i686-linux-android21 (RPM=i686, DEB=i386) -> x86',
'armv7a-linux-android21 (RPM=armv7, DEB=armhf) -> armeabi-v7a',
'aarch64-linux-android21 (RPM=aarch64, DEB=arm64) -> arm64-v8a',
2022-08-24 11:14:04 +02:00
'/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake'
2022-08-24 03:16:06 +02:00
)
}
}
stages {
2022-08-24 11:14:04 +02:00
stage('Compile') {
steps {
script {
2022-08-24 17:58:12 +02:00
final boolean use_toolchain = "${TARGET}".endsWith('.cmake')
final String path = use_toolchain ? "${TARGET}" : "${TARGET}".substring(0, "${TARGET}".indexOf(' ('))
final String rpmArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('(RPM=') + 5, "${TARGET}".indexOf(','))
final String debArch = use_toolchain ? 'noarch' : "${TARGET}".substring("${TARGET}".indexOf('DEB=') + 4, "${TARGET}".indexOf(')'))
2023-08-17 12:00:32 +02:00
final String system_name = path.contains('mingw') ? 'Windows' : (path.contains('android') ? 'Android' : sh(returnStdout: true, script: 'uname -s').trim())
2022-08-24 11:14:04 +02:00
final String linker = "/usr/bin/${path}-ld"
2022-08-27 22:44:33 +02:00
final boolean not_packer_compatible = path.contains('riscv') || ((path.contains('aarch64') || path.contains('arm')) && path.contains('mingw'))
2022-08-24 11:14:04 +02:00
final String build_directory = "cmake-build-${use_toolchain ? path.substring(path.lastIndexOf('/') + 1, path.length() - 6) : path}".toLowerCase()
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
2023-08-17 12:00:32 +02:00
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${path}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCXX_TARGET=\"${use_toolchain ? 'noarch' : debArch}\" -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ ${system_name == 'Android' ? "-DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_CXX_FLAGS=-static-openmp -DCMAKE_ANDROID_NDK=/usr/android-ndk -DCMAKE_ANDROID_ARCH_ABI=${"${TARGET}".substring("${TARGET}".indexOf(' -> ') + 4)}" : "-DCMAKE_SYSTEM_PROCESSOR=${path.substring(0, path.indexOf('-'))}"} -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${path.endsWith('armv7-w64-mingw32') ? ' -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=NO' : ''}",
2022-08-24 11:14:04 +02:00
generator: cmake_generator()
2022-10-07 22:59:00 +02:00
cmake arguments: "--build ./$build_directory --target ${!("${TARGET}".endsWith('Emscripten.cmake') && use_yarn_or_npm()) ? 'ybcon' : 'vercel_pkg'}", installation: 'Latest'
2022-08-24 11:14:04 +02:00
}
}
}
}
stage('Package') {
when { equals expected: true, actual: !"${TARGET}".endsWith('.cmake') }
2022-08-24 03:16:06 +02:00
steps {
2022-08-24 11:14:04 +02:00
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
2022-08-24 17:58:12 +02:00
script {
cpack installation: 'Latest', workingDir: "cmake-build-${"${TARGET}".substring(0, "${TARGET}".indexOf(' ('))}"
}
2022-08-24 11:14:04 +02:00
}
2022-08-24 03:16:06 +02:00
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
2022-08-24 11:14:04 +02:00
catchError(buildResult: "${TARGET}".endsWith('.cmake') ? 'FAILURE' : 'UNSTABLE', stageResult: 'FAILURE') {
2022-10-07 22:59:00 +02:00
archiveArtifacts artifacts: "cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-*/*.js,${use_yarn_or_npm() ? 'cmake-build-*/*-mac-*,' : ''} cmake-build-*/*.*.exe, cmake-build-*/*.zip", fingerprint: false
2022-08-24 11:14:04 +02:00
}
2022-08-24 03:16:06 +02:00
}
}
2022-03-13 10:23:06 +01:00
}
2022-08-24 11:14:04 +02:00
post { always { clean_workspace() } }
2021-08-09 18:02:05 +02:00
}
}
2021-10-05 22:03:42 +02:00
}
2022-08-24 11:14:04 +02:00
post { always { clean_workspace() } }
2020-12-11 22:36:10 +01:00
}