From 2790179f10bd10a76678959fb82802d764d4147a Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Fri, 17 Sep 2021 22:23:22 +0200
Subject: [PATCH] [#107] Tweaked script to run projects with hud, build options
 and argument forwarding

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 scripts/run.sh | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/scripts/run.sh b/scripts/run.sh
index 8e2ead55..2f5a3213 100755
--- a/scripts/run.sh
+++ b/scripts/run.sh
@@ -8,8 +8,24 @@ if [ $# -lt 1 ]; then
 	exit
 fi
 
-PROJECT=$1
+RUN_WITH_HUD="no"
+BUILD_FLAGS=""
+while [ $# -gt 1 ]; do
+  case "$1" in
+    "--"*)
+      if [ "$1" = "--hud" ]; then
+        RUN_WITH_HUD="yes"
+      else
+        BUILD_FLAGS="$BUILD_FLAGS$1 "
+      fi
+      shift 1;;
+    *) break;;
+  esac
+done
+
+PROJECT="$1"
 PROJECT_DIR="../projects/$PROJECT"
+shift 1
 
 # Check if the project name is valid
 if [ ! -d "$PROJECT_DIR" ]; then
@@ -17,7 +33,7 @@ if [ ! -d "$PROJECT_DIR" ]; then
 	exit
 fi
 
-./build.sh $PROJECT
+./build.sh $FLAGS "$PROJECT"
 cd "$PROJECT_DIR" || exit
 
 if [ ! -f "$PROJECT" ]; then
@@ -25,4 +41,8 @@ if [ ! -f "$PROJECT" ]; then
 	exit
 fi
 
-./$PROJECT
\ No newline at end of file
+if [ "$RUN_WITH_HUD" = "yes" ]; then
+  MANGOHUD=1 ./"$PROJECT" "$@"
+else
+  ./"$PROJECT" "$@"
+fi
\ No newline at end of file
-- 
GitLab