commit cacd990cefab7167a7cac1ea1f5a8ec8e87687d7
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Mon May 25 20:57:39 2020 +0200

    QtCreator setup script slightly enhanced

diff --git a/bootloader/AMiRo-BLT b/bootloader/AMiRo-BLT
index 5c8c470..d5a2a7c 160000
--- a/bootloader/AMiRo-BLT
+++ b/bootloader/AMiRo-BLT
@@ -1 +1 @@
-Subproject commit 5c8c470ff389fb8e049be416b1e7382e5f62dfc7
+Subproject commit d5a2a7ce252878928ae693d2de59b95eac51af77
diff --git a/tools/ide/QtCreator/QtCreatorSetup.sh b/tools/ide/QtCreator/QtCreatorSetup.sh
index 1b5895c..7d09161 100755
--- a/tools/ide/QtCreator/QtCreatorSetup.sh
+++ b/tools/ide/QtCreator/QtCreatorSetup.sh
@@ -62,11 +62,11 @@ function printWelcomeText {
 #
 function printHelp {
   printInfo "printing help text\n"
-  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
+  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-m|--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
   printf "\n"
   printf "options:  -h, --help\n"
   printf "              Print this help text.\n"
-  printf "          --module=<module>\n"
+  printf "          -m, --module <module>\n"
   printf "              Create project for a single module.\n"
   printf "          -a, --all\n"
   printf "              Create projects for all modules.\n"
@@ -108,7 +108,7 @@ function getProjectDir {
 #            -1
 #                 Error: Command 'arm-none-eabi-gcc' not found.
 #            -2
-#                 Error: include directory could not be resolved
+#                 Error: include directory could not be resolved.
 #
 function retrieveGccIncludeDir {
   # retrieve binary path or link
@@ -325,16 +325,16 @@ function createModuleProject {
   fi
 
   # change to project directory
-  local amiroosrootdir=$(realpath $(dirname ${BASH_SOURCE[0]})/../../..)
   cd "$projectdir"
 
   # run make, but only run the GCC preprocessor and produce no binaries
   local sourcefiles=()
   local sourcefile=""
-  local parse_state="WAIT_FOR_INCLUDE_OR_COMPILE"
+  local parse_state="WAIT_FOR_INCLUDE_COMPILE_MAKE"
+  local makedirs=()
   # capture all output from make and GCC and append the return value of make as last line
   printInfo "processing project (this may take a while)...\n"
-  local rawout=$(make --directory ${amiroosrootdir}/modules/${module} --always-make USE_OPT="-v -E -H" USE_VERBOSE_COMPILE="no" OUTFILES="" 2>&1 && echo $?)
+  local rawout=$(make --directory ${modulesdir}/${module} --always-make USE_OPT="-v -E -H" USE_VERBOSE_COMPILE="no" OUTFILES="" 2>&1 && echo $?)
   # check whether the make call was successfull
   if [[ $(echo "${rawout}" | tail -n 1) != "0" ]]; then
     printError "executing 'make' in module directory failed\n"
@@ -342,35 +342,50 @@ function createModuleProject {
     return -3
   else
     # cleanup
-    make --directory ${amiroosrootdir}/modules/${module} clean &>/dev/null
+    make --directory ${modulesdir}/${module} clean &>/dev/null
   fi
   # extract file names from raw output
   IFS=$'\n'; rawout=($rawout); unset IFS
   for line in "${rawout[@]}"; do
     case $parse_state in
-      WAIT_FOR_INCLUDE_OR_COMPILE)
-        # lines stating included files look like:
+      WAIT_FOR_INCLUDE_COMPILE_MAKE)
+        # lines stating include files look like:
         # ... <../relative/path/to/file>
         if [[ "$line" =~ ^\.+[[:blank:]].+\..+$ ]]; then
           sourcefile=${line##* }
           if [[ ! "$sourcefile" =~ ^/ ]]; then
-            sourcefile=$(realpath ${amiroosrootdir}/modules/${module}/${sourcefile})
+            sourcefile=$(realpath ${makedirs[-1]}/${sourcefile})
           fi
           sourcefiles[${#sourcefiles[@]}]="$sourcefile"
         # whenever the next source file is processed, a message appears like:
-        # Compining <filnemame>
+        # Compiling <filename>
         elif [[ "$line" =~ ^Compiling[[:blank:]](.+\..+)$ ]]; then
           printf "."
           sourcefile=${BASH_REMATCH[1]}
           parse_state="WAIT_FOR_COMPILERCALL"
+        # if make is called again in another directory, a message appears like:
+        # make[1]: Entering directory 'directory'
+        elif [[ "$line" =~ ^make(\[[0-9]+\])?:\ Entering\ directory\ \'.+\'$ ]]; then
+          makedirs+=($(echo "$line" | (cut -d "'" -f 2)))
+        # if make is leaving a directory, a message appears like:
+        # make[1]: Leaving directory 'directory'
+        elif [[ "$line" =~ ^make(\[[0-9]+\])?:\ Leaving\ directory\ \'.+\'$ ]]; then
+          unset makedirs[-1]
         fi;;
       WAIT_FOR_COMPILERCALL)
         # wait for the actual call of the compiler to retrieve the full path to the source file
         if [[ "$line" == *${sourcefile}* ]]; then
           line="${line%%${sourcefile}*}${sourcefile}"
-          sourcefile=$(realpath ${amiroosrootdir}/modules/${module}/${line##* })
+          line="${line##* }"
+          if [[ "$line" =~ ^/ ]]; then
+            # aboslute path
+            sourcefile=$line
+          else
+            # relative path
+            sourcefile=$(realpath ${makedirs[-1]}/${line##* })
+          fi
           sourcefiles[${#sourcefiles[@]}]="$sourcefile"
-          parse_state="WAIT_FOR_INCLUDE_OR_COMPILE"
+          parse_state="WAIT_FOR_INCLUDE_COMPILE_MAKE"
         fi;;
     esac
   done
@@ -387,12 +402,12 @@ function createModuleProject {
   # sort and remove duplicates
   IFS=$'\n'; includes=($(sort --unique <<< "${includes[*]}")); unset IFS
 
-  # generate the .files file, containing all source files
+  # generate the .incldues file, containing all include paths
   echo "" > ${projectdir}/${module}.includes
   for inc in ${includes[*]}; do
     echo "$inc" >> ${projectdir}/${module}.includes
   done
-  # generate the .incldues file, containing all include paths
+  # generate the .files file, containing all source files
   echo "" > ${projectdir}/${module}.files
   for source in ${sourcefiles[*]}; do
     # skip GCC files
@@ -448,7 +463,7 @@ function createModuleProject {
 #
 function createAllProjects {
   local modules=("${!1}")
-  local projectdir=""
+  local projectsdir=""
   local gccincludedir=""
   local outvar=""
   local gccoutvar=""
@@ -459,9 +474,9 @@ function createAllProjects {
     if ( parseIsOption $1 ); then
       case "$1" in
         -p=*|--path=*)
-          projectdir=$(realpath "${1#*=}"); shift 1;;
+          projectsdir=$(realpath "${1#*=}"); shift 1;;
         -p|--path)
-          projectdir=$(realpath "$2"); shift 2;;
+          projectsdir=$(realpath "$2"); shift 2;;
         --gcc=*)
           gccincludedir=$(realpath "${1#*=}"); shift 1;;
         --gcc)
@@ -490,17 +505,16 @@ function createAllProjects {
   fi
 
   # read absolute project directory if required
-  if [ -z "$projectdir" ]; then
-    getProjectDir projectdir
+  if [ -z "$projectsdir" ]; then
+    getProjectDir projectsdir
   fi
 
   # check for existing project files
-  local projectfiles=()
+  local projectfiles=""
   for module in ${modules[@]}; do
-    local pfiles="$(find ${projectdir} -maxdepth 1 -type f | grep -E "${module}\.(includes|files|config|creator)$")"
-    IFS=$'\n'; pfiles=($pfiles); unset IFS
-    projectfiles=( ${projectfiles[*]} ${pfiles[*]} )
+    projectfiles+="$(find ${projectsdir} -maxdepth 1 -type f | grep -E "${module}\.(includes|files|config|creator)$")"
   done
+  IFS=$'\n'; projectfiles=($projectfiles); unset IFS
   if [ ! -z "${projectfiles[*]}" ]; then
     printWarning "The following files will be removed:\n"
     for pfile in ${projectfiles[@]}; do
@@ -541,7 +555,7 @@ function createAllProjects {
     if [ $retval != 0 ]; then
       printf "\n"
     fi
-    createModuleProject modules[@] --module="$module" --path="$projectdir" --gcc="$gccincludedir"
+    createModuleProject modules[@] --module="$module" --path="$projectsdir" --gcc="$gccincludedir"
     retval=$?
   done
 
@@ -636,7 +650,7 @@ function deleteProjects {
 }
 
 ### main function of this script ###############################################
-# Creates, deletes and wipes QtCreator project files for the three AMiRo base modules.
+# Creates, deletes and wipes QtCreator project files for any module supported by AMiRo-OS.
 #
 # usage:      see function printHelp
 # arguments:  see function printHelp
