townengine/bin/twn
2025-02-17 10:01:48 +03:00

54 lines
1.5 KiB
Bash
Executable File

#!/bin/env sh
# townengine tooling interface
set +e
exe="$(basename $PWD)"
toolpath="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
export TWNROOT=$(realpath "$toolpath"/../)
case "$1" in
build ) "$toolpath"/twnbuild "${@:2}"
;;
run ) $0 build "${@:2}" && ./$exe
;;
gdb ) unset DEBUGINFOD_URLS
$0 build && gdb --se=libgame.so -ex run --args "$(basename $PWD)" --no-sanity-timer "${@:2}"
;;
init ) cp -r "$TWNROOT/apps/templates/$2" "$3"
ln -s "$TWNROOT/bin/twn" "$3/twn"
;;
apitrace ) case "$2" in
take ) export ASAN_OPTIONS=verify_asan_link_order=0
export LD_PRELOAD="/usr/lib/libubsan.so /usr/lib/apitrace/wrappers/glxtrace.so $LD_PRELOAD"
./$exe "${@:3}"
;;
show ) traces=( $exe.*.trace )
trace=${traces[-1]}
if [ "$trace" = "$exe.*.trace" ]; then
trace="$exe.trace"
fi
qapitrace ${trace}
;;
esac
;;
api-gen ) "$toolpath"/gen_api_header.sh
;;
wiki ) if [ "$OS" = "Windows_NT" ]; then
explorer "file://""$(cygpath -w "$(command realpath $TWNROOT/docs/wiki/index.html)")"
else
xdg-open "file://$TWNROOT/docs/wiki/index.html"
fi
;;
* ) echo "Unknown command."
;;
esac