From cfedb03a09fe9a43bf0daf2c24b94ca98ab66f31 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 24 Feb 2020 11:28:24 +0000 Subject: Create build script for Jenkins (and use it) (#4473) * Add Jenkins build script, so it can actually be used. * Build tools * Reduce build threads to 2 so as not to overload server * Rename CIBuild.sh to travisbuild.sh, better reflect actual use * Echo commands as they are executed * Add toolchain file configuration --- .travis.yml | 2 +- CIbuild.sh | 47 -------------------------------- jenkinsbuild.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ travisbuild.sh | 47 ++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 48 deletions(-) delete mode 100755 CIbuild.sh create mode 100755 jenkinsbuild.sh create mode 100755 travisbuild.sh diff --git a/.travis.yml b/.travis.yml index 742064177..17e941429 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ matrix: before_script: - export PATH=$(echo "$PATH" | sed -e 's/:\/usr\/lib\/ccache//') -script: ./CIbuild.sh +script: ./travisbuild.sh cache: ccache diff --git a/CIbuild.sh b/CIbuild.sh deleted file mode 100755 index b4163f0a8..000000000 --- a/CIbuild.sh +++ /dev/null @@ -1,47 +0,0 @@ - #!/usr/bin/env bash - -set -e - -export CUBERITE_BUILD_SERIES_NAME="Travis $CC $TRAVIS_CUBERITE_BUILD_TYPE" -export CUBERITE_BUILD_ID=$TRAVIS_JOB_NUMBER -export CUBERITE_BUILD_DATETIME=`date` - -# Use ccache if available -if [ `which ccache` ]; then - export CCACHE_CPP2=true - CACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" - echo "Using ccache installed at $(which ccache)" -fi - -cmake . -DBUILD_TOOLS=1 -DSELF_TEST=1 ${CACHE_ARGS}; - -echo "Building..." -cmake --build . -- -j 2; -ctest -j 2 -V; - -echo "Testing..." - -cd Server/; -touch apiCheckFailed.flag -if [ "$TRAVIS_CUBERITE_BUILD_TYPE" != "COVERAGE" ]; then - ./Cuberite <<- EOF - load APIDump - apicheck - restart - stop - EOF - if [ -f ./NewlyUndocumented.lua ]; then - echo "ERROR: Newly undocumented API symbols found:" - cat ./NewlyUndocumented.lua - exit 1 - fi - if [ -f ./DuplicateDocs.txt ]; then - echo "ERROR: API documentation has duplicate symbol warnings:" - cat ./DuplicateDocs.txt - exit 1 - fi - if [ -f ./apiCheckFailed.flag ]; then - echo "ERROR: API check has failed with an unknown error" - exit 1 - fi -fi diff --git a/jenkinsbuild.sh b/jenkinsbuild.sh new file mode 100755 index 000000000..731ccfa03 --- /dev/null +++ b/jenkinsbuild.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +set -ex + +# Parse arguments. +while [[ $# -gt 1 ]] +do +key="$1" +case $key in + -s|--server-name) + SERVERNAME="$2" + shift + ;; + -t|--target) + TARGET="$2" + shift + ;; + -c|--compiler) + CCOMP="$2" + shift + ;; + -cxx|--cxx-compiler) + CXXCOMP="$2" + shift + ;; + -m|--compile-mode) + COMPILEMODE="-DCMAKE_BUILD_TYPE=$2" + shift + ;; + -n|--build-number) + BUILDID="$2" + shift + ;; + -p|--toolchain-file) + TOOLCHAINFILE="-DCMAKE_TOOLCHAIN_FILE=$2" + shift + ;; + -b|--branch) + BRANCH="$2" + shift + ;; + -32|--force-32) + FORCE32="-DFORCE_32=$2" + shift + ;; + *) + ;; +esac +shift +done + +git submodule update --init + +# Set up build information. +export CUBERITE_BUILD_SERIES_NAME="$SERVERNAME $TARGET $COMPILEMODE ($BRANCH)" +export CUBERITE_BUILD_ID="$BUILDID" +export CUBERITE_BUILD_DATETIME="`date`" + +export CCACHE_CPP2=true +CACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" + +# Build +CXX=$CXXCOMP CC=$CCOMP cmake . -DNO_NATIVE_OPTIMIZATION=1 -DBUILD_TOOLS=1 ${TOOLCHAINFILE} ${COMPILEMODE^^} ${FORCE32^^} +make -j 2 + + +# Package Server +echo Cuberite "$CUBERITE_BUILD_SERIES_NAME-$CUBERITE_BUILD_ID\n$BUILD_URL" > Server/buildinfo.txt + +# h: dereference (archive file/folder instead of symlink) +# z: gzip (compress) +# c: create +# v: verbose +# T: files-from (list of server files accepted for release archives) +# f: file (output file location) +pushd Server +tar -hzcv -T Install/UnixExecutables.list -f ../Cuberite.tar.gz +popd +sha1sum Cuberite.tar.gz > Cuberite.tar.gz.sha1 + +# Package ProtoProxy +pushd Tools/ProtoProxy +sha1sum ProtoProxy > ProtoProxy.sha1 +popd diff --git a/travisbuild.sh b/travisbuild.sh new file mode 100755 index 000000000..b4163f0a8 --- /dev/null +++ b/travisbuild.sh @@ -0,0 +1,47 @@ + #!/usr/bin/env bash + +set -e + +export CUBERITE_BUILD_SERIES_NAME="Travis $CC $TRAVIS_CUBERITE_BUILD_TYPE" +export CUBERITE_BUILD_ID=$TRAVIS_JOB_NUMBER +export CUBERITE_BUILD_DATETIME=`date` + +# Use ccache if available +if [ `which ccache` ]; then + export CCACHE_CPP2=true + CACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" + echo "Using ccache installed at $(which ccache)" +fi + +cmake . -DBUILD_TOOLS=1 -DSELF_TEST=1 ${CACHE_ARGS}; + +echo "Building..." +cmake --build . -- -j 2; +ctest -j 2 -V; + +echo "Testing..." + +cd Server/; +touch apiCheckFailed.flag +if [ "$TRAVIS_CUBERITE_BUILD_TYPE" != "COVERAGE" ]; then + ./Cuberite <<- EOF + load APIDump + apicheck + restart + stop + EOF + if [ -f ./NewlyUndocumented.lua ]; then + echo "ERROR: Newly undocumented API symbols found:" + cat ./NewlyUndocumented.lua + exit 1 + fi + if [ -f ./DuplicateDocs.txt ]; then + echo "ERROR: API documentation has duplicate symbol warnings:" + cat ./DuplicateDocs.txt + exit 1 + fi + if [ -f ./apiCheckFailed.flag ]; then + echo "ERROR: API check has failed with an unknown error" + exit 1 + fi +fi -- cgit v1.2.3