Statistics
| Branch: | Tag: | Revision:

amiro-os / tools / ide / QtCreator / QtCreatorSetup.sh @ 22be62dc

History | View | Annotate | Download (41.035 KB)

1 e545e620 Thomas Schöpping
################################################################################
2
# AMiRo-OS is an operating system designed for the Autonomous Mini Robot       #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2016..2018  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23
24
#!/bin/bash
25
26
################################################################################
27
# GENERIC FUNCTIONS                                                            #
28
################################################################################
29
30
### print an error message #####################################################
31
# Prints a error <message> to standard output.
32
#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
33
#
34
# usage:      printError <message>
35
# arguments:  <message>
36
#                 Message string to print.
37
# return:     n/a
38
#
39
function printError {
40
  local string="ERROR:   $1"
41
  # if a log file is specified
42
  if [ -n "$LOG_FILE" ]; then
43
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
44
  fi
45
  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
46
}
47
48
### print a warning message ####################################################
49
# Prints a warning <message> to standard output.
50
#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
51
#
52
# usage:      printMessage <message>
53
# arguments:  <message>
54
#                 Message string to print.
55
# return:     n/a
56
#
57
function printWarning {
58
  local string="WARNING: $1"
59
  # if a log file is specified
60
  if [ -n "$LOG_FILE" ]; then
61
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
62
  fi
63
  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
64
}
65
66
### print an information message ###############################################
67
# Prints an information <message> to standard output.
68
#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
69
#
70
# usage:      printInfo <message>
71
# arguments:  <message>
72
#                 Message string to print.
73
# return:     n/a
74
#
75
function printInfo {
76
  local string="INFO:    $1"
77
  # if a log file is specified
78
  if [ -n "$LOG_FILE" ]; then
79
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
80
  fi
81
  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
82
}
83
84
### print a message to file ####################################################
85
# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
86
#
87
# usage       printLog <message>
88
# arguments:  <message>
89
#                 Message string to print.
90
# return:     n/a
91
#
92
function printLog {
93
  local string="LOG:     $1"
94
  # if a log file is specified
95
  if [ -n "$LOG_FILE" ]; then
96
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
97
  fi
98
}
99
100
### exit the script normally ###################################################
101
# Prints a delimiter and exits the script normally (returns 0).
102
#
103
# usage:      quitScript
104
# arguments:  n/a
105
# return:     0
106
#                 No error or warning occurred.
107
#
108
function quitScript {
109
  printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n"
110
  printf "\n"
111
  printf "######################################################################\n"
112
  exit 0
113
}
114
115
### read a user input ##########################################################
116
# Reads a single character user input from a set up <options> and stores it in
117
# a given <return> variable.
118
#
119
# usage:      readUserInput <options> <return>
120
# arguments:  <options>
121
#                 String definiing the set of valid characters.
122
#                 If the string is empty, the user can input any character.
123
#             <return>
124
#                 Variable to store the selected character to.
125
# return:     n/a
126
#
127
function readUserInput {
128
  local input=""
129
  # read user input
130
  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
131
    read -p "your selection: " -n 1 -e input
132
    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
133
      printWarning "[$input] is no valid action\n"
134
    fi
135
  done
136
  printLog "[$input] has been selected\n"
137
  eval $2="$input"
138
}
139
140
### check whether argument is an option ########################################
141
# Checks a <string> whether it is an option.
142
# Options are defined to either start with '--' followed by any string, or
143
# to start with a single '-' followed by a single character, or
144
# to start with a single '-' followed by a single character, a '=' and any string.
145
# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
146
#
147
# usage:      parseIsOption <string>
148
# arguments:  <string>
149
#                 A string to check whether it is an option.
150
# return:     0
151
#                 <string> is an option.
152
#             -1
153
#                 <string> is not an option.
154
#
155
function parseIsOption {
156
  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
157
    return 0
158
  else
159
    return -1
160
  fi
161
}
162
163
### set the log file ###########################################################
164
# Sets a specified <infile> as log file and checks whether it already exists.
165
# If so, the log may either be appended to the file, its content can be cleared,
166
# or no log is generated at all.
167
# The resulting path is stored in <outvar>.
168
#
169
# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
170
# arguments:  --option=<option>
171
#                 Select what to do if <file> already exists.
172
#                 Possible values are 'a', 'c', 'r' and 'n'.
173
#                 - a: append (starts with a separator)
174
#                 - c: continue (does not insert a seperator)
175
#                 - r: delete and restart
176
#                 - n: no log
177
#                 If no option is secified but <file> exists, an interactive selection is provided.
178
#             --quiet
179
#                 Suppress all messages.
180
#             <infile>
181
#                 Path of the wanted log file.
182
#             <outvar>
183
#                 Variable to store the path of the log file to.
184
# return:     0
185
#                 No error or warning occurred.
186
#             -1
187
#                 Error: invalid input
188
#
189
function setLogFile {
190
  local filepath=""
191
  local option=""
192
  local quiet=false
193
194
  # parse arguments
195
  local otherargs=()
196
  while [ $# -gt 0 ]; do
197
    if ( parseIsOption $1 ); then
198
      case "$1" in
199
        -o=*|--option=*)
200
          option=${1#*=}; shift 1;;
201
        -o*|--option*)
202
          option="$2"; shift 2;;
203
        -q|--quiet)
204
          quiet=true; shift 1;;
205
        *)
206
          printError "invalid option: $1\n"; shift 1;;
207
      esac
208
    else
209
      otherargs+=("$1")
210
      shift 1
211
    fi
212
  done
213
  filepath=$(realpath ${otherargs[0]})
214
215
  # if file already exists
216
  if [ -e $filepath ]; then
217
    # if no option was specified, ask what to do
218
    if [ -z "$option" ]; then
219
      printWarning "log file $filepath already esists\n"
220
      local userinput=""
221
      printf "Select what to do:\n"
222
      printf "  [A] - append log\n"
223
      printf "  [R] - restart log (delete existing file)\n"
224
      printf "  [N] - no log\n"
225
      readUserInput "AaRrNn" userinput
226
      option=${userinput,,}
227
    fi
228
    # evaluate option
229
    case "$option" in
230
      a|c)
231
        if [ $quiet = false ]; then
232
          printInfo "appending log to $filepath\n"
233
        fi
234
        if [ $option != c ]; then
235
          printf "\n" >> $filepath
236
          printf "######################################################################\n" >> $filepath
237
          printf "\n" >> $filepath
238
        fi
239
        ;;
240
      r)
241
        echo -n "" > $filepath
242
        if [ $quiet = false ]; then
243
          printInfo "content of $filepath wiped\n"
244
        fi
245
        ;;
246
      n)
247
        if [ $quiet = false ]; then
248
          printInfo "no log file will be generated\n"
249
        fi
250
        filepath=""
251
        ;;
252
      *) # sanity check (return error)
253
        printError "unexpected argument: $option\n"; return -1;;
254
    esac
255
  else
256
    if [ $quiet = false ]; then
257
      printInfo "log file set to $filepath\n"
258
    fi
259
  fi
260
261
  eval ${otherargs[1]}="$filepath"
262
263
  return 0
264
}
265
266
################################################################################
267
# SPECIFIC FUNCTIONS                                                           #
268
################################################################################
269
270
### print welcome text #########################################################
271
# Prints a welcome message to standard out.
272
#
273
# usage:      printWelcomeText
274
# arguments:  n/a
275
# return:     n/a
276
#
277
function printWelcomeText {
278
  printf "######################################################################\n"
279
  printf "#                                                                    #\n"
280
  printf "#                  Welcome to the QtCreator setup!                   #\n"
281
  printf "#                                                                    #\n"
282
  printf "######################################################################\n"
283
  printf "#                                                                    #\n"
284
  printf "# Copyright (c) 2016..2018  Thomas Schöpping                         #\n"
285
  printf "#                                                                    #\n"
286
  printf "# This is free software; see the source for copying conditions.      #\n"
287
  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
288
  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
289
  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
290
  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
291
  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
292
  printf "# Excellence Initiative.                                             #\n"
293
  printf "#                                                                    #\n"
294
  printf "######################################################################\n"
295
}
296
297
### print help #################################################################
298
# Prints a help text to standard out.
299
#
300
# usage:      printHelp
301
# arguments:  n/a
302
# return:     n/a
303
#
304
function printHelp {
305
  printInfo "printing help text\n"
306
  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-c|--clean] [-w|--wipe] [--LightRing] [--PowerManagement] [--DiWheelDrive] [-a|--all] [-q|--quit] [--log=<file>]\n"
307
  printf "\n"
308
  printf "options:  -h, --help\n"
309
  printf "              Print this help text.\n"
310
  printf "          -c, --clean\n"
311
  printf "              Delete project files.\n"
312
  printf "          -w, --wipe\n"
313
  printf "              Delete project and .user files.\n"
314
  printf "          --LightRing\n"
315
  printf "              Create project for the LightRing module.\n"
316
  printf "          --PowerManagement\n"
317
  printf "              Create project for the PowerManagement module.\n"
318
  printf "          --DiWheelDrive\n"
319
  printf "              Create project for the DiWheelDrive module.\n"
320
  printf "          -a, --all\n"
321
  printf "              Create projects for all modules.\n"
322
  printf "          -q, --quit\n"
323
  printf "              Quit the script.\n"
324
  printf "          --log=<file>\n"
325
  printf "              Specify a log file.\n"
326
}
327
328
### read directory where to create/delete projects #############################
329
# Read the directory where to create/delete project files from user.
330
#
331
# usage:      getProjectDir <pathvar>
332
# arguments:  <pathvar>
333
#                 Variable to store the selected path to.
334
# return:     n/a
335
#
336
function getProjectDir {
337
  printLog "reading path for project files from user...\n"
338
  local amiroosdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../)
339
  local input=""
340
  read -p "Path where to create/delete project files: " -i $amiroosdir -e input
341
  printLog "user selected path $(realpath $input)\n"
342
  eval $1="$(realpath $input)"
343
}
344
345
### retrieves the ARM-NONE-EABI-GCC include directory ##########################
346
# Retrieves the include directory of the currently set arm-none-eabi-gcc.
347
#
348
# usage:      retrieveGccIncludeDir <path>
349
# arguments:  <path>
350
#                 Variable to store the path to.
351
# return:    0
352
#                 No error or warning occurred.
353
#            -1
354
#                 Error: Command 'arm-none-eabi-gcc' not found.
355
#
356
function retrieveGccIncludeDir {
357
  # retrieve binary path or link
358
  local binpath=$(which arm-none-eabi-gcc)
359
  if [ -z "$binpath" ]; then
360
    printError "command 'arm-none-eabi-gcc' not found\n"
361
    return -1
362
  else 
363
364
    # traverse any links
365
    while [ -L "$binpath" ]; do
366 680d05e5 Thomas Schöpping
      binpath=$(realpath $(dirname $binpath)/$(readlink $binpath))
367 e545e620 Thomas Schöpping
    done
368
    printInfo "gcc-arm-none-eabi detected: $binpath\n"
369
370
    # return include path
371
    eval $1=$(realpath $(dirname ${binpath})/../arm-none-eabi/include/)
372
373
    return 0
374
  fi
375
}
376
377
### delete project files #######################################################
378
# Deletes all project files and optionally .user files, too.
379
#
380
# usage:      deleteProjects [-p|--path=<path>] [-o|--out=<var>] [-w|-wipe]
381
# arguments:  -p, --path <path>
382
#                 Path where to delete the project files.
383
#             -o, --out <var>
384
#                 Variable to store the path to.
385
#             -w, --wipe
386
#                 Delete .user files as well.
387
# return:
388
#  -  0: no error
389
#  -  1: warning: function aborted by user
390
#  - -1: error: unexpected user input
391
function deleteProjects {
392
  local projectdir=""
393
  local outvar=""
394
  local wipe=false
395
396
  # parse arguments
397
  local otherargs=()
398
  while [ $# -gt 0 ]; do
399
    if ( parseIsOption $1 ); then
400
      case "$1" in
401
        -p=*|--path=*)
402
          projectdir=$(realpath "${1#*=}"); shift 1;;
403
        -p|--path)
404
          projectdir=$(realpath "$2"); shift 2;;
405
        -o=*|--out=*)
406
          outvar=${1#*=}; shift 1;;
407
        -o|--out)
408
          outvar=$2; shift 2;;
409
        -w|--wipe)
410
          wipe=true; shift 1;;
411
        *)
412
          printError "invalid option: $1\n"; shift 1;;
413
      esac
414
    else
415
      otherargs+=("$1")
416
      shift 1
417
    fi
418
  done
419
420
  # print message
421
  if [ $wipe != true ]; then
422
    printInfo "deleting all QtCreator project files (*.includes, *.files, *.config, and *.creator)\n"
423
  else
424
    printInfo "deleting all QtCreator project files (*.includes, *.files, *.config, *.creator, and *.user)\n"
425
  fi
426
427
  # read project directory if required
428
  if [ -z "$projectdir" ]; then
429
    getProjectDir projectdir
430
  fi
431
432
  # remove all project files
433
  rm ${projectdir}/LightRing.includes 2>&1 | tee -a $LOG_FILE
434
  rm ${projectdir}/PowerManagement.includes 2>&1 | tee -a $LOG_FILE
435
  rm ${projectdir}/DiWheelDrive.includes 2>&1 | tee -a $LOG_FILE
436
437
  rm ${projectdir}/LightRing.files 2>&1 | tee -a $LOG_FILE
438
  rm ${projectdir}/PowerManagement.files 2>&1 | tee -a $LOG_FILE
439
  rm ${projectdir}/DiWheelDrive.files 2>&1 | tee -a $LOG_FILE
440
441
  rm ${projectdir}/LightRing.config 2>&1 | tee -a $LOG_FILE
442
  rm ${projectdir}/PowerManagement.config 2>&1 | tee -a $LOG_FILE
443
  rm ${projectdir}/DiWheelDrive.config 2>&1 | tee -a $LOG_FILE
444
445
  rm ${projectdir}/LightRing.creator 2>&1 | tee -a $LOG_FILE
446
  rm ${projectdir}/PowerManagement.creator 2>&1 | tee -a $LOG_FILE
447
  rm ${projectdir}/DiWheelDrive.creator 2>&1 | tee -a $LOG_FILE
448
449
  if [ $wipe == true ]; then
450
    rm ${projectdir}/LightRing.creator.user 2>&1 | tee -a $LOG_FILE
451
    rm ${projectdir}/PowerManagement.creator.user 2>&1 | tee -a $LOG_FILE
452
    rm ${projectdir}/DiWheelDrive.creator.user 2>&1 | tee -a $LOG_FILE
453
  fi
454
455
  # store the path to the output variable, if required
456
  if [ ! -z "$outvar" ]; then
457
    eval $outvar="$projectdir"
458
  fi
459
460
  return 0
461
}
462
463
### create LightRing project files #############################################
464
# Create project files for the LightRing module.
465
#
466
# usage:      createLightRingProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
467
# arguments:  -p, --path <path>
468
#                 Path where to create the project files.
469
#             --gcc=<path>
470
#                 Path to the GCC include directory.
471
#             -o, --out <var>
472
#                 Variable to store the path to.
473
#             --gccout=<var>
474
#                 Variable to store the path to the GCC include directory to.
475
# return:     0
476
#                 No error or warning occurred.
477
#
478
function createLightRingProject {
479
  local userdir=$(pwd)
480
  local projectdir=""
481
  local gccincludedir=""
482
  local outvar=""
483
  local gccoutvar=""
484
485
  # parse arguments
486
  local otherargs=()
487
  while [ $# -gt 0 ]; do
488
    if ( parseIsOption $1 ); then
489
      case "$1" in
490
        -p=*|--path=*)
491
          projectdir=$(realpath "${1#*=}"); shift 1;;
492
        -p|--path)
493
          projectdir=$(realpath "$2"); shift 2;;
494
        --gcc=*)
495
          gccincludedir=$(realpath "${1#*=}"); shift 1;;
496
        --gcc)
497
          gccincludedir=$(realpath "$2"); shift 2;;
498
        -o=*|--out=*)
499
          outvar=${1#*=}; shift 1;;
500
        -o|--out)
501
          outvar=$2; shift 2;;
502
        --gccout=*)
503
          gccoutvar=$(realpath "${1#*=}"); shift 1;;
504
        --gccout)
505
          gccoutvar=$(realpath "$2"); shift 2;;
506
        *)
507
          printError "invalid option: $1\n"; shift 1;;
508
      esac
509
    else
510
      otherargs+=("$1")
511
      shift 1
512
    fi
513
  done
514
515
  # print message
516
  printInfo "creating QtCreator project files for the LightRing module...\n"
517
518
  # read absolute project directory if required
519
  if [ -z "$projectdir" ]; then
520
    getProjectDir projectdir
521
  fi
522
523
  # retrieve absolute GCC include dir
524
  if [ -z "$gccincludedir" ]; then
525
    retrieveGccIncludeDir gccincludedir
526
  fi
527
528
  # move to project directory
529
  cd $projectdir
530
531
  # AMiRo-OS, ChibiOS, AMiRo-BLT and AMiRo-LLD relative root directories
532 63592e51 Thomas Schöpping
  local amiroosrootdir=$(realpath --relative-base=$projectdir $(dirname ${BASH_SOURCE[0]})/../../..)
533
  local chibiosrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/kernel/ChibiOS)
534
  local amirobltrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/bootloader/AMiRo-BLT)
535
  local amirolldrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/periphery-lld/AMiRo-LLD)
536 e545e620 Thomas Schöpping
537
  # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories)
538
  find $gccincludedir -type d > ${projectdir}/LightRing.includes
539 63592e51 Thomas Schöpping
  find $amiroosrootdir/modules -type d | grep -v "/doc\|/build\|/.dep\|/PowerManagement\|/DiWheelDrive" >> ${projectdir}/LightRing.includes
540
  find $amiroosrootdir/os -type d | grep -v "/doc\|/build\|/.dep\|/PowerManagement\|/DiWheelDrive" >> ${projectdir}/LightRing.includes
541 e545e620 Thomas Schöpping
  find $chibiosrootdir -type d | grep -E "/os/common/abstractions/cmsis_os$" >> ${projectdir}/LightRing.includes
542
  find $chibiosrootdir -type d | grep -E "/os/common/ext/CMSIS/(include|ST/STM32F1xx)$" >> ${projectdir}/LightRing.includes
543
  find $chibiosrootdir -type d | grep -E "/os/common/oslib/(include|src)$" >> ${projectdir}/LightRing.includes
544
  find $chibiosrootdir -type d | grep -E "/os/common/ports/ARMCMx(/compilers/GCC)?$" >> ${projectdir}/LightRing.includes
545
  find $chibiosrootdir -type d | grep -E "/os/common/startup/ARMCMx/(compilers/GCC|devices/STM32F1xx)$" >> ${projectdir}/LightRing.includes
546
  find $chibiosrootdir -type d | grep -E "/os/hal/(include|src)$" >> ${projectdir}/LightRing.includes
547
  find $chibiosrootdir -type d | grep -E "/os/hal/lib/streams" >> ${projectdir}/LightRing.includes
548
  find $chibiosrootdir -type d | grep -E "/os/hal/osal/(lib|rt)$" >> ${projectdir}/LightRing.includes
549
  find $chibiosrootdir -type d | grep -E "/os/hal/ports/(common/ARMCMx|STM32/(LLD/(CANv1|DACv1|DMAv1|EXTIv1|GPIOv1|I2Cv1|RTCv1|SDIOv1|SPIv1|TIMv1|USARTv1|USBv1|xWDGv1)|STM32F1xx))$" >> ${projectdir}/LightRing.includes
550
  find $chibiosrootdir -type d | grep -E "/os/license$" >> ${projectdir}/LightRing.includes
551
  find $chibiosrootdir -type d | grep -E "/os/rt/(include|src)$" >> ${projectdir}/LightRing.includes
552
  find $chibiosrootdir -type d | grep -E "/os/various/(shell|cpp_wrappers)" >> ${projectdir}/LightRing.includes
553
  find $chibiosrootdir -type d | grep -E "/test/(lib|rt/source/test)$" >> ${projectdir}/LightRing.includes
554
  find $amirobltrootdir -type d | grep -E "/Target/Source/AMiRo$" >> ${projectdir}/LightRing.includes
555
  echo "$(realpath --relative-base=$projectdir ${amirolldrootdir}/..)" >> ${projectdir}/LightRing.includes
556
  find $amirolldrootdir -type d | grep -v "/doc" >> ${projectdir}/LightRing.includes
557
  # generate a file that specifies all files
558
  echo -n "" > ${projectdir}/LightRing.files
559
  for path in `cat ${projectdir}/LightRing.includes`; do
560
    find $path -maxdepth 1 -type f \( ! -iname ".*" \) |
561
      grep -Ev "^.*((/arm-none-eabi/)|(PowerManagement)|(DiWheelDrive)).*$" |
562
      grep -E  "^.*(\.s|\.S|\.h|\.c|\.hpp|\.cpp|\.tpp|\.ld)$" |
563 63592e51 Thomas Schöpping
      grep -Ev "^${amiroosrootdir}/os/hal/ports/((STM32F[^1])|(STM32F1[^0])|(STM32F10[^3])|(STM32F103[^x])|(STM32F103x[^E])).*$" |
564 e545e620 Thomas Schöpping
      grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/ST/STM32F1xx/((stm32f1[^0x])|(stm32f10[^3])|(stm32f103[^x])|(stm32f103x[^e])).*$" |
565
      grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/include/((core_[^c])|(core_c[^m])|(core_cm[^3A-Za-z])|(cmsis_[^g])|(cmsis_g[^c]|(cmsis_gc[^c])))" |
566
      grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/chcore_v[^7]m.*$" |
567
      grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/compilers/GCC/.*_v[^7]m.*$" |
568
      grep -Ev "^${chibiosrootdir}/os/common/startup/ARMCMx/compilers/GCC/.*_v[^7]m.*$" |
569
      grep -Ev "^${chibiosrootdir}/os/hal/ports/STM32/STM32F1xx/.*f10[^3].*$" |
570
      grep -Ev "^${amirobltrootdir}/Target/Source/AMiRo/helper.*$" >> ${projectdir}/LightRing.files;
571
  done
572
  # generate a default project configuration file if none exists so far
573
  if [ ! -f ${projectdir}/LightRing.config ]; then
574
    echo "// Add predefined macros for your project here. For example:" > ${projectdir}/LightRing.config
575
    echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/LightRing.config
576
  fi
577
  # generate a default .creator file if none exists so far
578
  if [ ! -f ${projectdir}/LightRing}.creator ]; then
579
    echo "[general]" > ${projectdir}/LightRing.creator
580
  fi
581
582
  # go back to user directory
583
  cd $userdir
584
585
  # fill the output variables
586
  if [ ! -z "$outvar" ]; then
587
    eval $outvar="$projectdir"
588
  fi
589
  if [ ! -z "$gccoutvar" ]; then
590
    eval $gccoutvar="$gccincludedir"
591
  fi
592
593
  return 0
594
}
595
596
### create PowerManagement project files #######################################
597
# Create project files for the PowerManagement module.
598
#
599
# usage:      createPowerManagementProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
600
# arguments:  -p, --path <path>
601
#                 Path where to create the project files.
602
#             --gcc=<path>
603
#                 Path to the GCC include directory.
604
#             -o, --out <var>
605
#                 Variable to store the path to.
606
#             --gccout=<var>
607
#                 Variable to store the path to the GCC include directory to.
608
# return:     0
609
#                 No error or warning occurred.
610
#
611
function createPowerManagementProject {
612
  local userdir=$(pwd)
613
  local projectdir=""
614
  local gccincludedir=""
615
  local outvar=""
616
  local gccoutvar=""
617
618
  # parse arguments
619
  local otherargs=()
620
  while [ $# -gt 0 ]; do
621
    if ( parseIsOption $1 ); then
622
      case "$1" in
623
        -p=*|--path=*)
624
          projectdir=$(realpath "${1#*=}"); shift 1;;
625
        -p|--path)
626
          projectdir=$(realpath "$2"); shift 2;;
627
        --gcc=*)
628
          gccincludedir=$(realpath "${1#*=}"); shift 1;;
629
        --gcc)
630
          gccincludedir=$(realpath "$2"); shift 2;;
631
        -o=*|--out=*)
632
          outvar=${1#*=}; shift 1;;
633
        -o|--out)
634
          outvar=$2; shift 2;;
635
        --gccout=*)
636
          gccoutvar=$(realpath "${1#*=}"); shift 1;;
637
        --gccout)
638
          gccoutvar=$(realpath "$2"); shift 2;;
639
        *)
640
          printError "invalid option: $1\n"; shift 1;;
641
      esac
642
    else
643
      otherargs+=("$1")
644
      shift 1
645
    fi
646
  done
647
648
  # print message
649
  printInfo "creating QtCreator project files for the PowerManagement module...\n"
650
651
  # read absolute project directory if required
652
  if [ -z "$projectdir" ]; then
653
    getProjectDir projectdir
654
  fi
655
656
  # retrieve absolute GCC include dir
657
  if [ -z "$gccincludedir" ]; then
658
    retrieveGccIncludeDir gccincludedir
659
  fi
660
661
  # move to project directory
662
  cd $projectdir
663
664
  # AMiRo-OS, ChibiOS, AMiRo-BLT and AMiRo-LLD relative root directories
665 63592e51 Thomas Schöpping
  local amiroosrootdir=$(realpath --relative-base=$projectdir $(dirname ${BASH_SOURCE[0]})/../../..)
666
  local chibiosrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/kernel/ChibiOS)
667
  local amirobltrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/bootloader/AMiRo-BLT)
668
  local amirolldrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/periphery-lld/AMiRo-LLD)
669 e545e620 Thomas Schöpping
670
  # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories)
671
  find $gccincludedir -type d > ${projectdir}/PowerManagement.includes
672 63592e51 Thomas Schöpping
  find $amiroosrootdir/modules -type d | grep -v "/doc\|/build\|/.dep\|/LightRing\|/DiWheelDrive" >> ${projectdir}/PowerManagement.includes
673
  find $amiroosrootdir/os -type d | grep -v "/doc\|/build\|/.dep\|/LightRing\|/DiWheelDrive" >> ${projectdir}/PowerManagement.includes
674 e545e620 Thomas Schöpping
  find $chibiosrootdir -type d | grep -E "/os/common/abstractions/cmsis_os$" >> ${projectdir}/PowerManagement.includes
675
  find $chibiosrootdir -type d | grep -E "/os/common/ext/CMSIS/(include|ST/STM32F4xx)$" >> ${projectdir}/PowerManagement.includes
676
  find $chibiosrootdir -type d | grep -E "/os/common/oslib/(include|src)$" >> ${projectdir}/PowerManagement.includes
677
  find $chibiosrootdir -type d | grep -E "/os/common/ports/ARMCMx(/compilers/GCC)?$" >> ${projectdir}/PowerManagement.includes
678
  find $chibiosrootdir -type d | grep -E "/os/common/startup/ARMCMx/(compilers/GCC|devices/STM32F4xx)$" >> ${projectdir}/PowerManagement.includes
679
  find $chibiosrootdir -type d | grep -E "/os/hal/(include|src)$" >> ${projectdir}/PowerManagement.includes
680
  find $chibiosrootdir -type d | grep -E "/os/hal/lib/streams" >> ${projectdir}/PowerManagement.includes
681
  find $chibiosrootdir -type d | grep -E "/os/hal/osal/(lib|rt)$" >> ${projectdir}/PowerManagement.includes
682
  find $chibiosrootdir -type d | grep -E "/os/hal/ports/(common/ARMCMx|STM32/(LLD/(ADCv2|CANv1|DACv1|DMAv2|EXTIv1|GPIOv2|I2Cv1|MACv1|OTGv1|RTCv2|SDIOv1|SPIv1|TIMv1|USARTv1|USBv1|xWDGv1)|STM32F4xx))$" >> ${projectdir}/PowerManagement.includes
683
  find $chibiosrootdir -type d | grep -E "/os/license$" >> ${projectdir}/PowerManagement.includes
684
  find $chibiosrootdir -type d | grep -E "/os/rt/(include|src)$" >> ${projectdir}/PowerManagement.includes
685
  find $chibiosrootdir -type d | grep -E "/os/various/(shell|cpp_wrappers)" >> ${projectdir}/PowerManagement.includes
686
  find $chibiosrootdir -type d | grep -E "/test/(lib|rt/source/test)$" >> ${projectdir}/PowerManagement.includes
687
  find $amirobltrootdir -type d | grep -E "/Target/Source/AMiRo$" >> ${projectdir}/PowerManagement.includes
688
  echo "$(realpath --relative-base=$projectdir ${amirolldrootdir}/..)" >> ${projectdir}/PowerManagement.includes
689
  find $amirolldrootdir -type d | grep -v "/doc" >> ${projectdir}/PowerManagement.includes
690
  # generate a file that specifies all files
691
  echo -n "" > ${projectdir}/PowerManagement.files
692
  for path in `cat ${projectdir}/PowerManagement.includes`; do
693
    find $path -maxdepth 1 -type f \( ! -iname ".*" \) |
694
      grep -Ev "^.*((/arm-none-eabi/)|(LightRing)|(DiWheelDrive)).*$" |
695
      grep -E  "^.*(\.s|\.S|\.h|\.c|\.hpp|\.cpp|\.tpp|\.ld)$" |
696 63592e51 Thomas Schöpping
      grep -Ev "^${amiroosrootdir}/os/hal/ports/((STM32F[^4])|(STM32F4[^0])|(STM32F40[^5])|(STM32F405[^x])|(STM32F405x[^G])).*$" |
697 e545e620 Thomas Schöpping
      grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/ST/STM32F4xx/((stm32f4[^0x])|(stm32f40[^5])).*$" |
698
      grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/include/((core_[^c])|(core_c[^m])|(core_cm[^4A-Za-z])|(cmsis_[^g])|(cmsis_g[^c]|(cmsis_gc[^c])))" |
699
      grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/chcore_v[^7]m.*$" |
700
      grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/compilers/GCC/.*_v[^7]m.*$" |
701
      grep -Ev "^${chibiosrootdir}/os/common/startup/ARMCMx/compilers/GCC/.*_v[^7]m.*$" |
702
      grep -Ev "^${amirobltrootdir}/Target/Source/AMiRo/helper.*$" >> ${projectdir}/PowerManagement.files;
703
  done
704
  # generate a default project configuration file if none exists so far
705
  if [ ! -f ${projectdir}/PowerManagement.config ]; then
706
    echo "// Add predefined macros for your project here. For example:" > ${projectdir}/PowerManagement.config
707
    echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/PowerManagement.config
708
  fi
709
  # generate a default .creator file if none exists so far
710
  if [ ! -f ${projectdir}/PowerManagement.creator ]; then
711
    echo "[general]" > ${projectdir}/PowerManagement.creator
712
  fi
713
714
  # go back to user directory
715
  cd $userdir
716
717
  # fill the output variables
718
  if [ ! -z "$outvar" ]; then
719
    eval $outvar="$projectdir"
720
  fi
721
  if [ ! -z "$gccoutvar" ]; then
722
    eval $gccoutvar="$gccincludedir"
723
  fi
724
725
  return 0
726
}
727
728
### create DiWheelDrive project files ##########################################
729
# Create project files for the DiWheelDrive module.
730
#
731
# usage:      createDiWheelDriveProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
732
# arguments:  -p, --path <path>
733
#                 Path where to create the project files.
734
#             --gcc=<path>
735
#                 Path to the GCC include directory.
736
#             -o, --out <var>
737
#                 Variable to store the path to.
738
#             --gccout=<var>
739
#                 Variable to store the path to the GCC include directory to.
740
# return:     0
741
#                 No error or warning occurred.
742
#
743
function createDiWheelDriveProject {
744
  local userdir=$(pwd)
745
  local projectdir=""
746
  local gccincludedir=""
747
  local outvar=""
748
  local gccoutvar=""
749
750
  # parse arguments
751
  local otherargs=()
752
  while [ $# -gt 0 ]; do
753
    if ( parseIsOption $1 ); then
754
      case "$1" in
755
        -p=*|--path=*)
756
          projectdir=$(realpath "${1#*=}"); shift 1;;
757
        -p|--path)
758
          projectdir=$(realpath "$2"); shift 2;;
759
        --gcc=*)
760
          gccincludedir=$(realpath "${1#*=}"); shift 1;;
761
        --gcc)
762
          gccincludedir=$(realpath "$2"); shift 2;;
763
        -o=*|--out=*)
764
          outvar=${1#*=}; shift 1;;
765
        -o|--out)
766
          outvar=$2; shift 2;;
767
        --gccout=*)
768
          gccoutvar=$(realpath "${1#*=}"); shift 1;;
769
        --gccout)
770
          gccoutvar=$(realpath "$2"); shift 2;;
771
        *)
772
          printError "invalid option: $1\n"; shift 1;;
773
      esac
774
    else
775
      otherargs+=("$1")
776
      shift 1
777
    fi
778
  done
779
780
  # print message
781
  printInfo "creating QtCreator project files for the DiWheelDrive module...\n"
782
783
  # read absolute project directory if required
784
  if [ -z "$projectdir" ]; then
785
    getProjectDir projectdir
786
  fi
787
788
  # retrieve absolute GCC include dir
789
  if [ -z "$gccincludedir" ]; then
790
    retrieveGccIncludeDir gccincludedir
791
  fi
792
793
  # move to project directory
794
  cd $projectdir
795
796
  # AMiRo-OS, ChibiOS, AMiRo-BLT and AMiRo-LLD relative root directories
797 63592e51 Thomas Schöpping
  local amiroosrootdir=$(realpath --relative-base=$projectdir $(dirname ${BASH_SOURCE[0]})/../../..)
798
  local chibiosrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/kernel/ChibiOS)
799
  local amirobltrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/bootloader/AMiRo-BLT)
800
  local amirolldrootdir=$(realpath --relative-base=$projectdir ${amiroosrootdir}/periphery-lld/AMiRo-LLD)
801 e545e620 Thomas Schöpping
802
  # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories)
803
  find $gccincludedir -type d > ${projectdir}/DiWheelDrive.includes
804 63592e51 Thomas Schöpping
  find $amiroosrootdir/modules -type d | grep -v "/doc\|/build\|/.dep\|/LightRing\|/PowerManagement" >> ${projectdir}/DiWheelDrive.includes
805
  find $amiroosrootdir/os -type d | grep -v "/doc\|/build\|/.dep\|/LightRing\|/PowerManagement" >> ${projectdir}/DiWheelDrive.includes
806 e545e620 Thomas Schöpping
  find $chibiosrootdir -type d | grep -E "/os/common/abstractions/cmsis_os$" >> ${projectdir}/DiWheelDrive.includes
807
  find $chibiosrootdir -type d | grep -E "/os/common/ext/CMSIS/(include|ST/STM32F1xx)$" >> ${projectdir}/DiWheelDrive.includes
808
  find $chibiosrootdir -type d | grep -E "/os/common/oslib/(include|src)$" >> ${projectdir}/DiWheelDrive.includes
809
  find $chibiosrootdir -type d | grep -E "/os/common/ports/ARMCMx(/compilers/GCC)?$" >> ${projectdir}/DiWheelDrive.includes
810
  find $chibiosrootdir -type d | grep -E "/os/common/startup/ARMCMx/(compilers/GCC|devices/STM32F1xx)$" >> ${projectdir}/DiWheelDrive.includes
811
  find $chibiosrootdir -type d | grep -E "/os/hal/(include|src)$" >> ${projectdir}/DiWheelDrive.includes
812
  find $chibiosrootdir -type d | grep -E "/os/hal/lib/streams" >> ${projectdir}/DiWheelDrive.includes
813
  find $chibiosrootdir -type d | grep -E "/os/hal/osal/(lib|rt)$" >> ${projectdir}/DiWheelDrive.includes
814
  find $chibiosrootdir -type d | grep -E "/os/hal/ports/(common/ARMCMx|STM32/(LLD/(CANv1|DACv1|DMAv1|EXTIv1|GPIOv1|I2Cv1|RTCv1|SDIOv1|SPIv1|TIMv1|USARTv1|USBv1|xWDGv1)|STM32F1xx))$" >> ${projectdir}/DiWheelDrive.includes
815
  find $chibiosrootdir -type d | grep -E "/os/license$" >> ${projectdir}/DiWheelDrive.includes
816
  find $chibiosrootdir -type d | grep -E "/os/rt/(include|src)$" >> ${projectdir}/DiWheelDrive.includes
817
  find $chibiosrootdir -type d | grep -E "/os/various/(shell|cpp_wrappers)" >> ${projectdir}/DiWheelDrive.includes
818
  find $chibiosrootdir -type d | grep -E "/test/(lib|rt/source/test)$" >> ${projectdir}/DiWheelDrive.includes
819
  find $amirobltrootdir -type d | grep -E "/Target/Source/AMiRo$" >> ${projectdir}/DiWheelDrive.includes
820
  echo "$(realpath --relative-base=$projectdir ${amirolldrootdir}/..)" >> ${projectdir}/DiWheelDrive.includes
821
  find $amirolldrootdir -type d | grep -v "/doc" >> ${projectdir}/DiWheelDrive.includes
822
  # generate a file that specifies all files
823
  echo -n "" > ${projectdir}/DiWheelDrive.files
824
  for path in `cat ${projectdir}/DiWheelDrive.includes`; do
825
    find $path -maxdepth 1 -type f \( ! -iname ".*" \) |
826
      grep -Ev "^.*((/arm-none-eabi/)|(LightRing)|(PowerManagement)).*$" |
827
      grep -E  "^.*(\.s|\.S|\.h|\.c|\.hpp|\.cpp|\.tpp|\.ld)$" |
828 63592e51 Thomas Schöpping
      grep -Ev "^${amiroosrootdir}/os/hal/ports/((STM32F[^1])|(STM32F1[^0])|(STM32F10[^3])|(STM32F103[^x])|(STM32F103x[^E])).*$" |
829 e545e620 Thomas Schöpping
      grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/ST/STM32F1xx/((stm32f1[^0x])|(stm32f10[^3])|(stm32f103[^x])|(stm32f103x[^e])).*$" |
830
      grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/include/((core_[^c])|(core_c[^m])|(core_cm[^3A-Za-z])|(cmsis_[^g])|(cmsis_g[^c]|(cmsis_gc[^c])))" |
831
      grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/chcore_v[^7]m.*$" |
832
      grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/compilers/GCC/.*_v[^7]m.*$" |
833
      grep -Ev "^${chibiosrootdir}/os/common/startup/ARMCMx/compilers/GCC/.*_v[^7]m.*$" |
834
      grep -Ev "^${chibiosrootdir}/os/hal/ports/STM32/STM32F1xx/.*f10[^3].*$" |
835
      grep -Ev "^${amirobltrootdir}/Target/Source/AMiRo/helper.*$" >> ${projectdir}/DiWheelDrive.files;
836
  done
837
  # generate a default project configuration file if none exists so far
838
  if [ ! -f ${projectdir}/DiWheelDrive.config ]; then
839
    echo "// Add predefined macros for your project here. For example:" > ${projectdir}/DiWheelDrive.config
840
    echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/DiWheelDrive.config
841
  fi
842
  # generate a default .creator file if none exists so far
843
  if [ ! -f ${projectdir}/DiWheelDrive.creator ]; then
844
    echo "[general]" > ${projectdir}/DiWheelDrive.creator
845
  fi
846
847
  # go back to user directory
848
  cd $userdir
849
850
  # fill the output variables
851
  if [ ! -z "$outvar" ]; then
852
    eval $outvar="$projectdir"
853
  fi
854
  if [ ! -z "$gccoutvar" ]; then
855
    eval $gccoutvar="$gccincludedir"
856
  fi
857
858
  return 0
859
}
860
861
### create project files for all modules #######################################
862
# Create project files for all modules.
863
#
864
# usage:      createAllProjects
865
# arguments:  n/a
866
# return:     0
867
#                 No error or warning occurred.
868
#
869
function createAllProjects {
870
  # print message
871
  printInfo "creating QtCreator project files for the DiWheelDrive module...\n"
872
873
  # read project directory
874
  local projectdir=""
875
  getProjectDir projectdir
876
  printInfo "files will be created in $projectdir\n"
877
878
  # retrieve gcc-arm-none-eabi include dir
879
  retrieveGccIncludeDir gccincludedir
880
881
  # create projects
882
  createLightRingProject --path="$projectdir" --gcc="$gccincludedir"
883
  createPowerManagementProject --path="$projectdir" --gcc="$gccincludedir"
884
  createDiWheelDriveProject --path="$projectdir" --gcc="$gccincludedir"
885
886
  return 0
887
}
888
889
### main function of this script ###############################################
890
# Creates, deletes and wipes QtCreator project files for the three AMiRo base modules.
891
#
892
# usage:      see function printHelp
893
# arguments:  see function printHelp
894
# return:     0
895
#                 No error or warning ocurred.
896
#
897
function main {
898
# print welcome/info text if not suppressed
899
  if [[ $@ != *"--noinfo"* ]]; then
900
    printWelcomeText
901
  else
902
    printf "######################################################################\n"
903
  fi
904
  printf "\n"
905
906
  # if --help or -h was specified, print the help text and exit
907
  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
908
    printHelp
909
    printf "\n"
910
    quitScript
911
  fi
912
913
  # set log file if specified
914
  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
915
    # get the parameter (file name)
916
    local cmdidx=1
917
    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
918
      cmdidx=$[cmdidx + 1]
919
    done
920
    local cmd="${!cmdidx}"
921
    local logfile=""
922
    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
923
      logfile=${cmd#*=}
924
    else
925
      local filenameidx=$((cmdidx + 1))
926
      logfile="${!filenameidx}"
927
    fi
928
    # optionally force silent appending
929
    if [[ "$cmd" = "--LOG"* ]]; then
930
      setLogFile --option=c --quiet "$logfile" LOG_FILE
931
    else
932
      setLogFile "$logfile" LOG_FILE
933
      printf "\n"
934
    fi
935
  fi
936
  # log script name
937
  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
938
939
  # parse arguments
940
  local otherargs=()
941
  while [ $# -gt 0 ]; do
942
    if ( parseIsOption $1 ); then
943
      case "$1" in
944
        -h|--help) # already handled; ignore
945
          shift 1;;
946
        -c|--clean)
947
          deleteProjects; printf "\n"; shift 1;;
948
        -w|--wipe)
949
          deleteProjects --wipe; printf "\n"; shift 1;;
950
        --LightRing)
951
          createLightRingProject; printf "\n"; shift 1;;
952
        --PowerManagement)
953
          createPowerManagementProject; printf "\n"; shift 1;;
954
        --DiWheelDrive)
955
          createDiWheelDriveProject; printf "\n"; shift 1;;
956
        -a|--all)
957
          createAllProjects; printf "\n"; shift 1;;
958
        -q|--quit)
959
          quitScript; shift 1;;
960
        --log=*|--LOG=*) # already handled; ignore
961
          shift 1;;
962
        --log|--LOG) # already handled; ignore
963
          shift 2;;
964
        --noinfo) # already handled; ignore
965
          shift 1;;
966
        *)
967
          printError "invalid option: $1\n"; shift 1;;
968
      esac
969
    else
970
      otherargs+=("$1")
971
      shift 1
972
    fi
973
  done
974
975
  # interactive menu
976
  while ( true ); do
977
    # main menu info prompt and selection
978
    printInfo "QtCreator setup main menu\n"
979
    printf "Please select one of the following actions:\n"
980
    printf "  [C] - clean project files\n"
981
    printf "  [W] - wipe project and .user files\n"
982
    printf "  [L] - create a project for the LightRing module\n"
983
    printf "  [P] - create a project for the PowerManagement module\n"
984
    printf "  [D] - create a project for the DiWheelDrive module\n"
985
    printf "  [A] - create a project for all modules\n"
986
    printf "  [Q] - quit this setup\n"
987
    local userinput=""
988
    readUserInput "CcWwLlPpDdAaQq" userinput
989
    printf "\n"
990
991
    # evaluate user selection
992
    case "$userinput" in
993
      C|c)
994
        deleteProjects; printf "\n";;
995
      W|w)
996
        deleteProjects --wipe; printf "\n";;
997
      L|l)
998
        createLightRingProject; printf "\n";;
999
      P|p)
1000
        createPowerManagementProject; printf "\n";;
1001
      D|d)
1002
        createDiWheelDriveProject; printf "\n";;
1003
      A|a)
1004
        createAllProjects; printf "\n";;
1005
      Q|q)
1006
        quitScript;;
1007
      *) # sanity check (exit with error)
1008
        printError "unexpected argument: $userinput\n";;
1009
    esac
1010
  done
1011
1012
  exit 0
1013
}
1014
1015
################################################################################
1016
# SCRIPT ENTRY POINT                                                           #
1017
################################################################################
1018
1019
main "$@"