* update workflow to use windows 2022 image * return the version of the run vcpkg action the action has been changed to now use a vcpkg.json file instead of the txt file we use now, we should try to find a way to update it to the new workflow in case the current one becomes obsolete * clean up a bit for consistency * run ctest directly instead of relying on the makefile * set -C flag for ctest * set config option for cmake --build this option is ignored for other platforms
155 lines
3 KiB
Bash
Executable file
155 lines
3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
|
|
LINT_SCRIPT=".ci/lint_cpp.sh"
|
|
|
|
# Read arguments
|
|
while [[ $# != 0 ]]; do
|
|
case "$1" in
|
|
'--')
|
|
shift
|
|
;;
|
|
'--format')
|
|
CHECK_FORMAT=1
|
|
shift
|
|
;;
|
|
'--install')
|
|
MAKE_INSTALL=1
|
|
shift
|
|
;;
|
|
'--package')
|
|
MAKE_PACKAGE=1
|
|
shift
|
|
if [[ $# != 0 && $1 != -* ]]; then
|
|
PACKAGE_TYPE="$1"
|
|
shift
|
|
fi
|
|
;;
|
|
'--suffix')
|
|
shift
|
|
if [[ $# == 0 ]]; then
|
|
echo "::error file=$0::--suffix expects an argument"
|
|
exit 1
|
|
fi
|
|
PACKAGE_SUFFIX="$1"
|
|
shift
|
|
;;
|
|
'--server')
|
|
MAKE_SERVER=1
|
|
shift
|
|
;;
|
|
'--test')
|
|
MAKE_TEST=1
|
|
shift
|
|
;;
|
|
'--debug')
|
|
BUILDTYPE="Debug"
|
|
shift
|
|
;;
|
|
'--release')
|
|
BUILDTYPE="Release"
|
|
shift
|
|
;;
|
|
'--ccache')
|
|
USE_CCACHE=1
|
|
shift
|
|
;;
|
|
*)
|
|
if [[ $1 == -* ]]; then
|
|
echo "::error file=$0::unrecognized option: $1"
|
|
exit 3
|
|
fi
|
|
BUILDTYPE="$1"
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Check formatting using clang-format
|
|
if [[ $CHECK_FORMAT ]]; then
|
|
echo "::group::Run linter"
|
|
source "$LINT_SCRIPT"
|
|
echo "::endgroup::"
|
|
fi
|
|
|
|
set -e
|
|
|
|
# Setup
|
|
./servatrice/check_schema_version.sh
|
|
mkdir -p build
|
|
cd build
|
|
|
|
if [[ ! $CMAKE_BUILD_PARALLEL_LEVEL ]]; then
|
|
CMAKE_BUILD_PARALLEL_LEVEL=2 # default machines have 2 cores
|
|
fi
|
|
|
|
# Add cmake flags
|
|
flags=()
|
|
if [[ $MAKE_SERVER ]]; then
|
|
flags+=("-DWITH_SERVER=1")
|
|
fi
|
|
if [[ $MAKE_TEST ]]; then
|
|
flags+=("-DTEST=1")
|
|
fi
|
|
if [[ ! $BUILDTYPE ]]; then
|
|
BUILDTYPE=Release
|
|
fi
|
|
flags+=("-DCMAKE_BUILD_TYPE=$BUILDTYPE")
|
|
if [[ $PACKAGE_TYPE ]]; then
|
|
flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE")
|
|
fi
|
|
|
|
if [[ $(uname) == "Darwin" ]]; then
|
|
if [[ $USE_CCACHE ]]; then
|
|
# prepend ccache compiler binaries to path
|
|
PATH="/usr/local/opt/ccache/libexec:$PATH"
|
|
fi
|
|
# Add qt install location when using homebrew
|
|
flags+=("-DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/")
|
|
fi
|
|
|
|
# Compile
|
|
if [[ $USE_CCACHE ]]; then
|
|
echo "::group::Show ccache stats"
|
|
ccache --show-stats
|
|
echo "::endgroup::"
|
|
fi
|
|
|
|
echo "::group::Configure cmake"
|
|
cmake --version
|
|
cmake .. "${flags[@]}"
|
|
echo "::endgroup::"
|
|
|
|
echo "::group::Build project"
|
|
cmake --build . --config "$BUILDTYPE"
|
|
echo "::endgroup::"
|
|
|
|
if [[ $USE_CCACHE ]]; then
|
|
echo "::group::Show ccache stats again"
|
|
ccache --show-stats
|
|
echo "::endgroup::"
|
|
fi
|
|
|
|
if [[ $MAKE_TEST ]]; then
|
|
echo "::group::Run tests"
|
|
ctest -C "$BUILDTYPE"
|
|
echo "::endgroup::"
|
|
fi
|
|
|
|
if [[ $MAKE_INSTALL ]]; then
|
|
echo "::group::Install"
|
|
cmake --build . --target install --config "$BUILDTYPE"
|
|
echo "::endgroup::"
|
|
fi
|
|
|
|
if [[ $MAKE_PACKAGE ]]; then
|
|
echo "::group::Create package"
|
|
cmake --build . --target package --config "$BUILDTYPE"
|
|
echo "::endgroup::"
|
|
|
|
if [[ $PACKAGE_SUFFIX ]]; then
|
|
echo "::group::Update package name"
|
|
../.ci/name_build.sh "$PACKAGE_SUFFIX"
|
|
echo "::endgroup::"
|
|
fi
|
|
fi
|