mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 18:43:55 -07:00
add github actions (#4164)
This commit is contained in:
parent
45d838a0b3
commit
4aaedf64d2
11 changed files with 425 additions and 334 deletions
128
.ci/compile.sh
Executable file
128
.ci/compile.sh
Executable file
|
|
@ -0,0 +1,128 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
|
||||
|
||||
# Read arguments
|
||||
while [[ "$@" ]]; do
|
||||
case "$1" in
|
||||
'--format')
|
||||
CHECK_FORMAT=1
|
||||
shift
|
||||
;;
|
||||
'--install')
|
||||
MAKE_INSTALL=1
|
||||
shift
|
||||
;;
|
||||
'--package')
|
||||
MAKE_PACKAGE=1
|
||||
shift
|
||||
if [[ $# != 0 && $1 != -* ]]; then
|
||||
PACKAGE_NAME="$1"
|
||||
shift
|
||||
if [[ $# != 0 && $1 != -* ]]; then
|
||||
PACKAGE_TYPE="$1"
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
'--server')
|
||||
MAKE_SERVER=1
|
||||
shift
|
||||
;;
|
||||
'--test')
|
||||
MAKE_TEST=1
|
||||
shift
|
||||
;;
|
||||
'--debug')
|
||||
BUILDTYPE="Debug"
|
||||
shift
|
||||
;;
|
||||
'--release')
|
||||
BUILDTYPE="Release"
|
||||
shift
|
||||
;;
|
||||
'--zip')
|
||||
MAKE_ZIP=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [[ $1 == -* ]]; then
|
||||
echo "unrecognized option: $1"
|
||||
exit 3
|
||||
fi
|
||||
BUILDTYPE="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check formatting using clang-format
|
||||
if [[ $CHECK_FORMAT ]]; then
|
||||
source ./.ci/lint.sh
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Setup
|
||||
./servatrice/check_schema_version.sh
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
if ! [[ $CORE_AMOUNT ]]; then
|
||||
CORE_AMOUNT="2" # default machines have 2 cores
|
||||
fi
|
||||
|
||||
# Add cmake flags
|
||||
if [[ $MAKE_SERVER ]]; then
|
||||
flags+=" -DWITH_SERVER=1"
|
||||
fi
|
||||
if [[ $MAKE_TEST ]]; then
|
||||
flags+=" -DTEST=1"
|
||||
BUILDTYPE="Debug" # test requires buildtype Debug
|
||||
fi
|
||||
if [[ $BUILDTYPE ]]; then
|
||||
flags+=" -DCMAKE_BUILD_TYPE=$BUILDTYPE"
|
||||
fi
|
||||
if [[ $PACKAGE_TYPE ]]; then
|
||||
flags+=" -DCPACK_GENERATOR=$PACKAGE_TYPE"
|
||||
fi
|
||||
|
||||
# Add qt install location when using brew
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
PATH="/usr/local/opt/ccache/bin:$PATH"
|
||||
flags+=" -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/"
|
||||
fi
|
||||
|
||||
# Compile
|
||||
cmake --version
|
||||
cmake .. $flags
|
||||
make -j"$CORE_AMOUNT"
|
||||
|
||||
if [[ $MAKE_TEST ]]; then
|
||||
make test
|
||||
fi
|
||||
|
||||
if [[ $MAKE_INSTALL ]]; then
|
||||
make install
|
||||
fi
|
||||
|
||||
if [[ $MAKE_PACKAGE ]]; then
|
||||
make package
|
||||
if [[ $PACKAGE_NAME ]]; then
|
||||
found="$(find . -maxdepth 1 -type f -name "Cockatrice-*.*" -print -quit)"
|
||||
path="${found%/*}"
|
||||
file="${found##*/}"
|
||||
if [[ ! $file ]]; then
|
||||
echo "could not find package" >&2
|
||||
exit 1
|
||||
fi
|
||||
new_name="$path/${file%.*}-$PACKAGE_NAME."
|
||||
if [[ $MAKE_ZIP ]]; then
|
||||
zip "${new_name}zip" "$path/$file"
|
||||
mv "$path/$file" "$path/_$file"
|
||||
else
|
||||
extension="${file##*.}"
|
||||
mv "$path/$file" "$new_name$extension"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue