Bots: env reporting, TFIL movement, gun selector and docs refresh
DevControlBot DevControlBot.sh env-file handling and defines, tfil.nim
survival-movement rework, README
ModularBot .env.example, ModularBot.nim, env_report.nim, vbullet_draw.nim
PPO_Bot enemy_tracker.nim
common_libs gun_harness/selector.nim
tests env_report, lead_gain_legacy, rack_membership,
rack_stat_width, tm_pattern_registration adjustments
docs env_reference.md, goto-controller-algorithm.md
This commit is contained in:
@@ -7,11 +7,15 @@
|
||||
# propagates the real exit code. Signals are forwarded to Nimble so the task's
|
||||
# own EXIT/INT/TERM cleanup always runs.
|
||||
#
|
||||
# Usage: DevControlBot.sh [--debug] [<metadata.json>] [extra args for the bot]
|
||||
# Usage: DevControlBot.sh [--debug] [-d:<define>[=<value>]]... [<metadata.json>] [extra args]
|
||||
#
|
||||
# (no args) RELEASE build + run with the bundled DevControlBot.json
|
||||
# (no flag) RELEASE build (nim c -d:release), quiet output
|
||||
# --debug classic DEBUG build (plain nim c): compiler hints + diagnostics
|
||||
# -d:foo compile-time Nim define. ANY number, in any position, in EITHER
|
||||
# build mode: --debug only changes optimisation/hints, defines are
|
||||
# independent of it, so `-d:tfilDebug` debug graphics work in a
|
||||
# release build too. Accepted forms: -d:foo and -d:foo=bar.
|
||||
#
|
||||
# --debug is a build-mode flag for this wrapper only: it is stripped here and
|
||||
# never reaches the bot binary or nimble's task arguments. It travels to the
|
||||
@@ -19,6 +23,14 @@
|
||||
# confused with a bot argument, cannot collide with the status file mechanism
|
||||
# and keeps the task's argument parsing untouched. Repeated --debug is harmless.
|
||||
#
|
||||
# -d: args travel the same way, as $DEVCONTROLBOT_DEFINES. They MUST be stripped
|
||||
# here: the runBot task forwards its own argv to the BOT BINARY, so a -d: arg
|
||||
# would otherwise become the bot's argv and never reach the compiler. Matching is
|
||||
# the anchored glob `-d:*` (whole-argument, starts with -d:), so a value that
|
||||
# merely contains "-d:" inside another word ("x-d:y", "--debug-d:x") is NOT a
|
||||
# define and is forwarded verbatim. Anything that is neither --debug, -h/--help
|
||||
# nor a -d: arg still reaches the bot binary exactly as before.
|
||||
#
|
||||
# Configuration (SERVER_URL, SERVER_SECRET, ...) is NOT handled here at all: the
|
||||
# API's start() reads those from the environment, and the optional .env file is
|
||||
# loaded by the runBot task, so it also works with a direct `nimble runBot`.
|
||||
@@ -30,11 +42,16 @@ cd "$SCRIPT_DIR"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [--debug] [<metadata.json>] [extra args for the bot]
|
||||
Usage: $(basename "$0") [--debug] [-d:<define>[=<value>]]... [<metadata.json>] [extra args for the bot]
|
||||
|
||||
--debug classic debug build: shows compiler hints and diagnostics
|
||||
(default is a quiet RELEASE build, nim c -d:release)
|
||||
-h,--help show this help
|
||||
--debug classic debug build: shows compiler hints and diagnostics
|
||||
(default is a quiet RELEASE build, nim c -d:release)
|
||||
-d:foo, -d:foo=bar Nim compile-time define, passed to `nim c`. Repeatable.
|
||||
Independent of --debug: defines apply in BOTH build modes,
|
||||
so `-d:tfilDebug` debug graphics also work in a release
|
||||
build. Only whole args starting with -d: are treated as
|
||||
defines; everything else is forwarded to the bot binary.
|
||||
-h,--help show this help
|
||||
|
||||
Examples:
|
||||
$(basename "$0") # release build + run, bundled DevControlBot.json
|
||||
@@ -42,15 +59,33 @@ Examples:
|
||||
$(basename "$0") -h # this help
|
||||
$(basename "$0") --debug # debug build
|
||||
$(basename "$0") --debug my.json # debug build with custom metadata
|
||||
$(basename "$0") -d:tfilDebug # release build with TFIL debug graphics
|
||||
$(basename "$0") --debug -d:tfilDebug # debug build, also with debug graphics
|
||||
$(basename "$0") -d:danger -d:logLevel=2 my.json
|
||||
EOF
|
||||
}
|
||||
|
||||
# Split caller args: everything except --debug is forwarded verbatim.
|
||||
# Split caller args: --debug and -d: defines are consumed here, everything else
|
||||
# is forwarded verbatim. The defines end up in a single space-separated string
|
||||
# because the compiler line is `eval`ed (like $DEPS) to survive paths with spaces.
|
||||
BUILD_MODE=release
|
||||
DEFINES=""
|
||||
FORWARDED=()
|
||||
for a in "$@"; do
|
||||
case "$a" in
|
||||
--debug) BUILD_MODE=debug ;;
|
||||
-d:*)
|
||||
# TRUST BOUNDARY: the string is eval'ed by the runBot task, so a define
|
||||
# carrying whitespace, quotes, $, ` or ; could inject shell. Reject it
|
||||
# loudly instead of passing it on. Legal Nim defines (-d:foo, -d:foo=bar)
|
||||
# contain none of these.
|
||||
case "$a" in
|
||||
*[[:space:]\"\'\$\;\`\\]*)
|
||||
echo "$(basename "$0"): invalid define '$a'" >&2
|
||||
echo " expected -d:name or -d:name=value with no spaces or shell characters" >&2
|
||||
exit 1 ;;
|
||||
esac
|
||||
DEFINES="$DEFINES $a" ;;
|
||||
*) FORWARDED+=("$a") ;;
|
||||
esac
|
||||
done
|
||||
@@ -63,6 +98,9 @@ case "${1:-}" in
|
||||
esac
|
||||
|
||||
export DEVCONTROLBOT_DEBUG="$BUILD_MODE"
|
||||
# Leading space trimmed: empty when the caller passed no -d: arg, and the runBot
|
||||
# task's compile lines are then byte-identical to a run without this feature.
|
||||
export DEVCONTROLBOT_DEFINES="${DEFINES# }"
|
||||
|
||||
# The runBot task's shell always exits 0 (otherwise Nimble raises a NimScript
|
||||
# exception with a stack trace and a dump of the whole script) and writes the
|
||||
|
||||
Reference in New Issue
Block a user