2022-04-10 12:51:06 +02:00
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' }
2021-09-12 13:59:07 +02:00
def buildTarget(String path, String rpmArch = 'noarch', String debArch = 'noarch', boolean isPackageArchDeb = true, String suffix = '') {
2021-11-07 23:44:42 +01:00
final String packageArch = isPackageArchDeb ? debArch : rpmArch;
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"
2021-08-18 13:48:29 +02:00
// Note: CMake 3.20 or higher is needed
2021-09-12 13:59:07 +02:00
cmakeBuild buildDir: "cmake-build-${packageArch}${suffix}", buildType: 'release', cleanBuild: true, installation: 'Latest',
2022-06-10 22:41:14 +02:00
cmakeArgs: "--no-warn-unused-cli -DCMAKE_SYSTEM_NAME=\"${system_name}\" -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 -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCXX_TARGET=${packageArch} -DCMAKE_EXE_LINKER_FLAGS=-static -DIGNORE_MINIMAL_COMPILER_VERSION=ON ${no_compilation_cache_flags()}",
2022-04-10 12:51:06 +02:00
generator: cmake_generator()
2021-09-12 13:59:07 +02:00
cmake arguments: "--build ./cmake-build-${packageArch}${suffix} --target ybcon", installation: 'Latest'
2021-10-20 21:44:54 +02:00
sh "/usr/bin/${path}-strip -s ./cmake-build-${packageArch}${suffix}/ybcon*"
2021-09-12 13:59:07 +02:00
cpack installation: 'Latest', workingDir: "cmake-build-${packageArch}${suffix}"
2021-08-15 16:17:10 +02:00
}
2021-11-07 23:44:42 +01:00
final String windowsSuffix = '-windows'
2021-09-12 14:14:46 +02:00
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 22:51:38 +02: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
2022-06-10 22:15:51 +02:00
- Emscripten Clang (https://github.com/emscripten-core/emsdk) in /usr/share/
2022-06-10 22:51:38 +02:00
- MinGW32 G++/Clang (https://github.com/mstorsjo/llvm-mingw) for x86_64, i686, armhf and aarch64, unzipped into /usr/, along with soft links from /usr/bin/ to the binaries
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'))
timeout(time: 8, 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') {
steps {
2021-03-24 16:39:43 +01:00
echo "Building the ${env.BRANCH_NAME} branch.."
2022-06-10 22:15:51 +02:00
buildTarget('x86_64-linux-musl', 'x86_64', 'amd64')
buildTarget('i686-linux-musl', 'i386', 'i386')
2022-04-10 12:51:06 +02:00
cmakeBuild buildDir: "cmake-build-release-emscripten", buildType: 'release', cleanBuild: true, installation: 'Latest',
2022-04-12 18:51:26 +02:00
cmakeArgs: "-DCMAKE_TOOLCHAIN_FILE=\"/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake\" ${no_compilation_cache_flags()}",
2022-04-10 12:51:06 +02:00
generator: cmake_generator()
cmake arguments: "--build ./cmake-build-release-emscripten", installation: 'Latest'
2022-03-13 10:23:06 +01:00
}
}
stage('Build for other architectures') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
2022-06-10 22:15:51 +02:00
buildTarget('armel-linux-musleabi', 'armv4l', 'armel')
buildTarget('armv7l-linux-musleabihf', 'armv7hl', 'armhf')
buildTarget('aarch64-linux-musl', 'aarch64', 'arm64', false)
buildTarget('riscv64-linux-musl', 'riscv64', 'riscv64')
2022-03-13 10:23:06 +01:00
}
2021-08-09 18:02:05 +02:00
}
}
2021-08-09 20:55:43 +02:00
stage('Build for other platforms') {
2021-08-09 18:02:05 +02:00
steps {
2022-03-13 21:49:28 +01:00
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
2021-09-12 14:14:46 +02:00
buildTarget('armv7-w64-mingw32', 'armv7hl', 'armhf', true, windowsSuffix)
buildTarget('aarch64-w64-mingw32', 'aarch64', 'arm64', false, windowsSuffix)
2021-08-09 18:02:05 +02:00
}
2022-03-13 21:55:07 +01:00
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
buildTarget('x86_64-w64-mingw32', 'x86_64', 'amd64', true, windowsSuffix)
buildTarget('i686-w64-mingw32', 'i386', 'i386', true, windowsSuffix)
}
2020-12-11 22:36:10 +01:00
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
2022-04-10 12:51:06 +02:00
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-release-emscripten/*.js', fingerprint: false
2021-09-12 14:14:46 +02:00
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
archiveArtifacts artifacts: 'cmake-build-*/*wpkg.*.exe, cmake-build-*/*.zip'
}
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
}