mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -07:00
ninja
This commit is contained in:
parent
29c3f1fa7a
commit
2786226e99
1 changed files with 37 additions and 14 deletions
|
|
@ -1,21 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
|
# This script is to be used by the CI environment from the project root directory, do not use it from somewhere else.
|
||||||
|
|
||||||
# Compiles cockatrice inside of a ci environment
|
# Compiles cockatrice inside of a CI environment
|
||||||
# --install runs make install
|
# --install runs make install
|
||||||
# --package [<package type>] runs make package, optionally force the type
|
# --package [<package type>] runs make package, optionally force the type
|
||||||
# --suffix <suffix> renames package with this suffix, requires arg
|
# --suffix <suffix> renames package with this suffix, requires arg
|
||||||
# --server compiles servatrice
|
# --server compiles servatrice
|
||||||
# --test runs tests
|
# --test runs tests
|
||||||
# --debug or --release sets the build type ie CMAKE_BUILD_TYPE
|
# --debug or --release sets the build type (CMAKE_BUILD_TYPE)
|
||||||
# --ccache [<size>] uses ccache and shows stats, optionally provide size
|
# --ccache [<size>] uses ccache and shows stats, optionally provide size
|
||||||
# --dir <dir> sets the name of the build dir, default is "build"
|
# --dir <dir> sets the name of the build dir, default is "build"
|
||||||
# --parallel <core count> sets how many cores cmake should build with in parallel
|
# --parallel <core count> sets how many cores cmake should build with in parallel
|
||||||
|
# --ninja use Ninja for building (default if Ninja is available)
|
||||||
|
# --make use Make for building (fallback if Ninja is unavailable)
|
||||||
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_TEST USE_CCACHE CCACHE_SIZE BUILD_DIR PARALLEL_COUNT
|
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_TEST USE_CCACHE CCACHE_SIZE BUILD_DIR PARALLEL_COUNT
|
||||||
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir> --parallel <core_count>)
|
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir> --parallel <core_count>)
|
||||||
# exitcode: 1 for failure, 3 for invalid arguments
|
# exitcode: 1 for failure, 3 for invalid arguments
|
||||||
|
|
||||||
|
USE_NINJA=
|
||||||
|
|
||||||
# Read arguments
|
# Read arguments
|
||||||
while [[ $# != 0 ]]; do
|
while [[ $# != 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
@ -85,6 +89,14 @@ while [[ $# != 0 ]]; do
|
||||||
PARALLEL_COUNT="$1"
|
PARALLEL_COUNT="$1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
'--ninja')
|
||||||
|
USE_NINJA=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
'--make')
|
||||||
|
USE_NINJA=
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "::error file=$0::unrecognized option: $1"
|
echo "::error file=$0::unrecognized option: $1"
|
||||||
exit 3
|
exit 3
|
||||||
|
|
@ -124,17 +136,23 @@ if [[ $PACKAGE_TYPE ]]; then
|
||||||
flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE")
|
flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Auto-detect Ninja if not explicitly set
|
||||||
|
if [[ -z "$USE_NINJA" ]]; then
|
||||||
|
if command -v ninja &>/dev/null; then
|
||||||
|
USE_NINJA=1
|
||||||
|
echo "::notice::Using Ninja generator by default"
|
||||||
|
else
|
||||||
|
echo "::notice::Ninja not found, falling back to Make"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Add cmake --build flags
|
# Add cmake --build flags
|
||||||
buildflags=(--config "$BUILDTYPE")
|
buildflags=(--config "$BUILDTYPE")
|
||||||
if [[ $PARALLEL_COUNT ]]; then
|
|
||||||
if [[ $(cmake --build /not_a_dir --parallel 2>&1 | head -1) =~ parallel ]]; then
|
# Remove parallelism flag for Ninja (it handles this automatically)
|
||||||
# workaround for bionic having an old cmake
|
if [[ ! $USE_NINJA && $PARALLEL_COUNT ]]; then
|
||||||
echo "this version of cmake does not support --parallel, using native build tool -j instead"
|
# Only use parallelism flag if using Make (not Ninja)
|
||||||
buildflags+=(-- -j "$PARALLEL_COUNT")
|
buildflags+=(--parallel "$PARALLEL_COUNT")
|
||||||
# note, no normal build flags should be added after this
|
|
||||||
else
|
|
||||||
buildflags+=(--parallel "$PARALLEL_COUNT")
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function ccachestatsverbose() {
|
function ccachestatsverbose() {
|
||||||
|
|
@ -156,13 +174,18 @@ fi
|
||||||
|
|
||||||
echo "::group::Configure cmake"
|
echo "::group::Configure cmake"
|
||||||
cmake --version
|
cmake --version
|
||||||
cmake .. "${flags[@]}"
|
if [[ $USE_NINJA ]]; then
|
||||||
|
cmake -G Ninja .. "${flags[@]}"
|
||||||
|
else
|
||||||
|
cmake .. "${flags[@]}"
|
||||||
|
fi
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "::group::Build project"
|
echo "::group::Build project"
|
||||||
if [[ $RUNNER_OS == Windows ]]; then
|
if [[ $RUNNER_OS == Windows ]]; then
|
||||||
# Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/
|
# Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/
|
||||||
# and https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#multitooltask-mtt
|
# and https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#multitooltask-mtt
|
||||||
|
# and https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#multitooltask-mtt
|
||||||
cmake --build . "${buildflags[@]}" -- -p:UseMultiToolTask=true -p:EnableClServerMode=true
|
cmake --build . "${buildflags[@]}" -- -p:UseMultiToolTask=true -p:EnableClServerMode=true
|
||||||
else
|
else
|
||||||
cmake --build . "${buildflags[@]}"
|
cmake --build . "${buildflags[@]}"
|
||||||
|
|
@ -200,7 +223,7 @@ if [[ $MAKE_PACKAGE ]]; then
|
||||||
|
|
||||||
if [[ $PACKAGE_SUFFIX ]]; then
|
if [[ $PACKAGE_SUFFIX ]]; then
|
||||||
echo "::group::Update package name"
|
echo "::group::Update package name"
|
||||||
cd ..
|
cd ..
|
||||||
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"
|
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue