Added build scripts.

This commit is contained in:
Patrick 2023-11-12 13:20:38 +01:00
parent a6bb94ca24
commit 51db785fca
3 changed files with 111 additions and 0 deletions

13
build/Dockerfile Normal file
View File

@ -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

73
build/Jenkinsfile vendored Normal file
View File

@ -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 <noreply@mewin.de>',
to: 'buildresult@mewin.de',
cc: '',
bcc: '',
subject: "Jenkins Build Error (${env.JOB_NAME})",
body: "<b>Build Failure</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> Build URL: ${env.BUILD_URL}",
charset: 'UTF-8',
mimeType: 'text/html',
replyTo: '';
}
}
}

View File

@ -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