diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..6402e53 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:sid-slim + +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get -y install build-essential clang-16 gcc-13 g++-13 scons python3 \ + python3-pip python-is-python3 clang-tidy git ninja-build cmake + +RUN python -m pip install --no-cache-dir --break-system-packages GitPython + +RUN ln -s /usr/bin/clang-16 /usr/local/bin/clang \ + && ln -s /usr/bin/clang++-16 /usr/local/bin/clang++ \ + && ln -s /usr/bin/clang-tidy-16 /usr/local/bin/clang-tidy \ + && ln -s /usr/bin/run-clang-tidy-16 /usr/local/bin/run-clang-tidy diff --git a/build/Jenkinsfile b/build/Jenkinsfile new file mode 100644 index 0000000..058b591 --- /dev/null +++ b/build/Jenkinsfile @@ -0,0 +1,73 @@ +pipeline { + agent { + dockerfile { + filename 'Dockerfile' + dir 'build' + } + } + + parameters { + booleanParam(name: 'CLEAN', defaultValue: false, description: 'Clean build') + booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run tests') + } + + stages { + stage('Clean') { + when { + expression { params.CLEAN } + } + steps { + sh 'rm -rf cache/*' + } + } + stage('Clang-Tidy') { + when { + expression { params.RUN_TESTS } + } + steps { + warnError('clang-tidy found problems.') { + sh 'bash build/scripts/clang-tidy.sh' + } + } + } + stage('Build Linux Clang') { + steps { + sh 'scons -j8 --build_type=debug --variant=linux_clang_debug --compiler=clang' + sh 'scons -j8 --build_type=release_debug --variant=linux_clang_release_debug --compiler=clang' + sh 'scons -j8 --build_type=release --variant=linux_clang_release --compiler=clang' + } + } + stage('Build Linux GCC') { + steps { + script { + def config = 'CC="gcc-13"\nCXX="g++-13"' + writeFile file: 'config.py', text: config + } + sh 'scons -j8 --build_type=debug --variant=linux_gcc_debug' + sh 'scons -j8 --build_type=release_debug --variant=linux_gcc_release_debug' + sh 'scons -j8 --build_type=release --variant=linux_gcc_release' + } + } + stage('Archive') { + steps { + archiveArtifacts artifacts: 'bin_*/*', + fingerprint: true, + onlyIfSuccessful: true + } + } + } + + post { + failure { + mail from: 'Jenkins ', + to: 'buildresult@mewin.de', + cc: '', + bcc: '', + subject: "Jenkins Build Error (${env.JOB_NAME})", + body: "Build Failure
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
Build URL: ${env.BUILD_URL}", + charset: 'UTF-8', + mimeType: 'text/html', + replyTo: ''; + } + } +} diff --git a/build/scripts/clang-tidy.sh b/build/scripts/clang-tidy.sh new file mode 100644 index 0000000..4560c70 --- /dev/null +++ b/build/scripts/clang-tidy.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -xe + +if [ ! -f ".clang-tidy" ] ; then + echo "Must be run from project root folder!" + exit 1 +fi + +# first generate the compile commands for clang-tidy to work with +scons -Q --unity=disable --compiler=clang compile_commands.json + +mkdir -p cache/jenkins +find private -name "*.cpp" > "cache/jenkins/clang-tidy-files" + +# run clang-tidy, but ignore errors for now +# clang-tidy reports some errors in headers, we need to filter those out +run-clang-tidy -j8 -p . -quiet $(<"cache/jenkins/clang-tidy-files") | tee "cache/jenkins/clang-tidy.log" || true + +# check if there were any errors in our sources +if [ $(grep -- "-warnings-as-errors" cache/jenkins/clang-tidy.log | grep -E "private/|public/" -c || true) -ne 0 ] ; then + grep -- "-warnings-as-errors" cache/jenkins/clang-tidy.log | grep -E "private/|public/" >&2 + exit 1 +else + echo "No relevant errors from clang-tidy, hooray!" +fi