blob: afe353d3d53c47b70a55079bd537e8bad0d8210e [file] [log] [blame]
#!/usr/bin/env bash
set -e
set -u
# this is to support running Renode from an external directory and via a symlink
ROOT_PATH="$(cd $(dirname $(readlink -f $0 2>/dev/null || echo $0)); echo $PWD)"
. "$ROOT_PATH/tools/common.sh"
OUTPUT_PATH="$ROOT_PATH/output/bin"
TARGET="Release"
QUIET=false
TRACE=false
NET=false
PARAMS=()
while [[ "$#" -gt 0 ]]
do
case $1 in
-d|--debug)
TARGET="Debug"
if $ON_LINUX
then
LAUNCHER="$LAUNCHER --debug"
fi
;;
-q|--quiet)
QUIET=true
;;
--net)
NET=true
;;
--trace)
TRACE=true
TRACE_FORMAT=${2:-}
case $TRACE_FORMAT in
Chromium|chromium)
TRACE_FORMAT="Chromium"
shift
;;
Speedscope|speedscope)
TRACE_FORMAT="Speedscope"
shift
;;
Nettrace|nettrace)
TRACE_FORMAT="Nettrace"
shift
;;
*)
# No format specified - use default, don't shift argument list
TRACE_FORMAT="Nettrace"
;;
esac
;;
*)
PARAMS+=("$1")
;;
esac
shift
done
if ! $NET && $TRACE
then
echo "Tracing is available only on the dotnet target"
exit 1
fi
if ! $ON_WINDOWS && ! $NET
then
verify_mono_version
fi
if ${REMOTE:-false} && ! $NET
then
LAUNCHER="$LAUNCHER --debugger-agent=transport=dt_socket,address=0.0.0.0:${REMOTE_PORT:=9876},server=y"
echo "Waiting for a debugger at port $REMOTE_PORT..."
fi
if ${QUIET:-false}
then
exec 2>/dev/null
fi
if $NET
then
if $ON_WINDOWS
then
TFM="net6.0-windows10.0.17763.0"
else
TFM="net6.0"
fi
if ! $TRACE
then
TRACE_COMMAND=""
else
TRACE_COMMAND="dotnet-trace collect --format ${TRACE_FORMAT} --"
fi
${TRACE_COMMAND} dotnet "${OUTPUT_PATH}/${TARGET}/${TFM}/Renode.dll" "${PARAMS[@]:-}"
else
if $ON_WINDOWS
then
"${OUTPUT_PATH}/${TARGET}/Renode.exe" "${PARAMS[@]:-}"
else
$LAUNCHER "${OUTPUT_PATH}/${TARGET}/Renode.exe" "${PARAMS[@]:-}"
fi
fi