sots-engine/tests/game_effects/build_and_run.sh

27 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build and run the game/effects unit tests with plain g++ (no CMake needed).
# tests/game_effects/build_and_run.sh
# BUILD_DIR=/some/dir tests/game_effects/build_and_run.sh
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root="$(cd "$here/../.." && pwd)"
build="${BUILD_DIR:-$(mktemp -d "${TMPDIR:-/tmp}/sots-game-effects.XXXXXX")}"
mkdir -p "$build"
CXX="${CXX:-g++}"
CXXFLAGS="${CXXFLAGS:--std=c++17 -O1 -g -Wall -Wextra -Werror -pedantic}"
srcs=("$root"/src/game/sim/economy.cpp "$root"/src/game/sim/research.cpp \
"$root"/src/game/sim/colony.cpp "$root"/src/game/sim/movement.cpp \
"$root"/src/game/effects/tech_id.cpp "$root"/src/game/effects/tech_effects.cpp)
objs=()
for s in "${srcs[@]}"; do
o="$build/$(basename "${s%.cpp}").o"
$CXX $CXXFLAGS -I"$root/src" -c "$s" -o "$o"
objs+=("$o")
done
exe="$build/test_effects"
$CXX $CXXFLAGS -I"$root/src" -I"$here" -I"$root/tests/game_sim" "$here/test_effects.cpp" "${objs[@]}" -o "$exe"
if "$exe"; then echo "game_effects: all tests passed (build dir $build)"; else echo "game_effects: FAILURES (build dir $build)"; exit 1; fi