#!/usr/bin/env bash

LAUNCHER=dotnet

if ! [ -x "$(command -v $LAUNCHER)" ]
then
    echo "$LAUNCHER not found. Renode requires dotnet runtime. Please refer to documentation for installation instructions. Exiting!"
    exit 1
fi

if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
    ON_WINDOWS=true
else
    ON_WINDOWS=false
fi

BIN_DIR=$(dirname "${BASH_SOURCE[0]}")/bin

if $ON_WINDOWS && [[ -f "$BIN_DIR/RenodeWPF.dll" ]]; then
    DLL="RenodeWPF.dll"
else
    DLL="Renode.dll"
fi

$LAUNCHER "$BIN_DIR/$DLL" "$@"
