This repository has been archived on 2026-08-30. You can view files and clone it, but cannot push or open issues or pull requests.
Ravenous-LaTeX/build.sh

246 lines
6.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
URL="https://proxy.dandaedre.com/gitea/Ravenous/podman_ravenous"
CONTAINER_IMAGE=${CONTAINER_IMAGE:-localhost/ravenous-podman:latest}
RAW=false # will be set to true when --raw is requested
print_error() {
echo "Error: $1" >&2
echo "Please check the setup at:" >&2
echo "$URL" >&2
}
# ------------------------------------------------------------------
# Argument parsing – first positional arg can be a mode or --help
# ------------------------------------------------------------------
MODE=simple # default mode
MAKE_ARGS=() # everything that ends up in the `make` call
while [[ $# -gt 0 ]]; do
case $1 in
--help)
cat <<'HELP'
Usage: ./build.sh [--help | <mode>] [make-options …]
Modes:
simple (default) – run a minimal build
clean – clean all build artifacts
player – build the player handbook
master – build the master handbook
balance – show all the balancing data
full – rerun a full build
Additional option:
raw – execute commands directly on the host using ravenous-tools instead of a Podman container
Everything that follows the mode is forwarded verbatim to `make` inside
the container (or run directly when --raw is used).
HELP
exit 0
;;
--full|full)
MODE=full
shift
;;
--player|player)
MODE=player
shift
;;
--master|master)
MODE=master
shift
;;
--mlite|mlite)
MODE=mlite
shift
;;
--clean|clean)
MODE=clean
shift
;;
--balance|balance)
MODE=balance
shift
;;
--raw|raw) # raw mode: use ravenous-tools instead of a container
RAW=true
shift
;;
*)
# All remaining arguments are passed straight to `make`
MAKE_ARGS+=("$@")
break
;;
esac
done
# ------------------------------------------------------------------
# Prerequisites Check
# ------------------------------------------------------------------
if [ "$RAW" = true ]; then
if ! command -v ravenous-tools >/dev/null 2>&1; then
echo "Error: ravenous-tools is not installed." >&2
echo "Please install it or run without --raw." >&2
exit 1
fi
else
if ! command -v podman >/dev/null 2>&1; then
print_error "Podman is not installed."
exit 1
fi
if ! podman image inspect "$CONTAINER_IMAGE" > /dev/null 2>&1; then
print_error "Container image '$CONTAINER_IMAGE' is not installed."
exit 1
fi
fi
echo "--- Prerequisites met ---"
# ------------------------------------------------------------------
# Helper: run a command inside the container with podman and exit on error
# ------------------------------------------------------------------
run_podman() {
# Forward all podman flags (e.g., --no-cache) that the caller might want
if [ "$RAW" = true ]; then
# In raw mode simply execute the command as it is.
ravenous-tools "$@"
return $?
fi
# Forward all podman flags (e.g., --no-cache) that the caller might want
local PODMAN_OPTS=()
while [[ $# -gt 0 ]]; do
case $1 in
--* )
PODMAN_OPTS+=("$1")
shift
;;
*)
break
;;
esac
done
podman run \
"${PODMAN_OPTS[@]}" \
--rm \
-i \
--tty \
-v "$(pwd)":/workspace \
"$CONTAINER_IMAGE" \
"$@"
}
# ------------------------------------------------------------------
# Build Logic Selection
# ------------------------------------------------------------------
case "$MODE" in
full)
echo ">>> Executing FULL build sequence (with args: ${MAKE_ARGS[@]})..."
run_podman tablegen -e all
mkdir -p ~/.local/share/fonts/
mkdir -p ./Images/Radar/
mkdir -p ./Bestiaire/
mkdir -p ./Handbooks/
cp ./Ressources/lmroman8-regular.ttf ~/.local/share/fonts/
run_podman monsters export --all
run_podman graphs load
run_podman graphs generate
run_podman tablegen classes -e
run_podman weapons all -e ./Craft/
# Pass user supplied make arguments *before* the target so that options
# or custom targets still work.
run_podman make "${MAKE_ARGS[@]}" -N Player_handbook.tex
run_podman make -t glossaries -N Player_handbook.tex
run_podman make "${MAKE_ARGS[@]}" -N Player_handbook.tex
run_podman make "${MAKE_ARGS[@]}" -N Master_handbook.tex
run_podman make -t glossaries -N Master_handbook.tex
run_podman make "${MAKE_ARGS[@]}" -N Master_handbook.tex
run_podman make "${MAKE_ARGS[@]}" -N Ravenous.tex
run_podman make -t glossaries -N Ravenous.tex
run_podman make "${MAKE_ARGS[@]}" -N Ravenous.tex
;;
player)
echo ">>> Executing PLAYER build (with args: ${MAKE_ARGS[@]})..."
run_podman make "${MAKE_ARGS[@]}" -N Player_handbook.tex || exit $?
echo "--- Build Completed Successfully ---"
;;
master)
echo ">>> Executing MASTER build (with args: ${MAKE_ARGS[@]})..."
mkdir -p ./Bestiaire/
mkdir -p ./Handbooks/
run_podman monsters export --all
run_podman graphs load
run_podman graphs generate
run_podman tablegen classes -e
run_podman weapons all -e ./Craft/
run_podman make "${MAKE_ARGS[@]}" -N Master_handbook.tex || exit $?
echo "--- Build Completed Successfully ---"
;;
mlite)
echo ">>> Executing MASTER (no regen) build (with args: ${MAKE_ARGS[@]})..."
run_podman make "${MAKE_ARGS[@]}" -N Master_handbook.tex || exit $?
echo "--- Build Completed Successfully ---"
;;
clean)
echo ">>> Cleaning up directory..."
run_podman make -t clean Player_handbook.tex || exit $?
run_podman make -t clean Master_handbook.tex || exit $?
run_podman make -t clean Ravenous_build.tex || exit $?
run_podman graphs remove || exit $?
rm -f ./Ravenous_build.* ./Player_handbook_build.* Bestiaire/*
rm -rf ./Handbooks/
echo "--- Cleanup Completed Successfully ---"
;;
simple)
echo ">>> Executing SIMPLE build (with args: ${MAKE_ARGS[@]})..."
run_podman make "${MAKE_ARGS[@]}" -N Ravenous.tex || exit $?
echo "--- Build Completed Successfully ---"
;;
balance)
echo ">>> Showing Balancing values (with args: ${MAKE_ARGS[@]})..."
run_podman monsters balance "${MAKE_ARGS[@]}" || exit $?
;;
*)
print_error "Unknown mode: $MODE"
exit 1
;;
esac
exit 0