Statistics
| Branch: | Revision:

urtware / setup.sh @ 7d9678db

History | View | Annotate | Download (6.414 KB)

1
################################################################################
2
# AMiRo-Apps is a collection of applications for the Autonomous Mini Robot     #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2018..2019  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
# load library
27
source "$(dirname ${BASH_SOURCE[0]})/tools/bash/setuplib.sh"
28

    
29
### print welcome text #########################################################
30
# Prints a welcome message to standard out.
31
#
32
# usage:      printWelcomeText
33
# arguments:  n/a
34
# return:     n/a
35
#
36
function printWelcomeText {
37
  printf "######################################################################\n"
38
  printf "#                                                                    #\n"
39
  printf "#                  Welcome to the AMiRo-Apps setup!                  #\n"
40
  printf "#                                                                    #\n"
41
  printf "######################################################################\n"
42
  printf "#                                                                    #\n"
43
  printf "# Copyright (c) 2018..2019  Thomas Schöpping                         #\n"
44
  printf "#                                                                    #\n"
45
  printf "# This is free software; see the source for copying conditions.      #\n"
46
  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
47
  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
48
  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
49
  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
50
  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
51
  printf "# Excellence Initiative.                                             #\n"
52
  printf "#                                                                    #\n"
53
  printf "######################################################################\n"
54
}
55

    
56
### print help #################################################################
57
# Prints a help text to standard out.
58
#
59
# usage:      printHelp
60
# arguments:  n/a
61
# return:     n/a
62
#
63
function printHelp {
64
  printInfo "printing help text\n"
65
  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-i|--init] [-k|--kernel] [-b|--bootloader] [-p|--periphery-LLD] [-m|--middleware] [-c|--compiler] [--IDE] [-q|--quit] [--log=<file>]\n"
66
  printf "\n"
67
  printf "options:  -h, --help\n"
68
  printf "              Print this help text.\n"
69
  printf "          --IDE\n"
70
  printf "              Enter IDE setup.\n"
71
  printf "          -q, --quit\n"
72
  printf "              Quit the script.\n"
73
}
74

    
75
### enter IDE setup ############################################################
76
# Enter IDE setup.
77
#
78
# usage:      ideSetup
79
# arguments:  n/a
80
# return:     n/a
81
#
82
function ideSetup {
83
  printInfo "entering IDE setup\n"
84
  $(dirname $(realpath ${BASH_SOURCE[0]}))/tools/ide/idesetup.sh
85
}
86

    
87
### main function of this script ###############################################
88
# Provides functions for project initialization, configuration of IDE and
89
# compiler setup, as well as entry points to the several Git submodules.
90
#
91
# usage:      see function printHelp
92
# arguments:  see function printHelp
93
# return:     0
94
#                 No error or warning occurred.
95
#
96
function main {
97
  # print welcome/info text if not suppressed
98
  if [[ $@ != *"--noinfo"* ]]; then
99
    printWelcomeText
100
  else
101
    printf "######################################################################\n"
102
  fi
103
  printf "\n"
104

    
105
  # if --help or -h was specified, print the help text and exit
106
  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
107
    printHelp
108
    printf "\n"
109
    quitScript
110
  fi
111

    
112
  # parse arguments
113
  local otherargs=()
114
  while [ $# -gt 0 ]; do
115
    if ( parseIsOption $1 ); then
116
      case "$1" in
117
        -h|--help) # already handled; ignore
118
          shift 1;;
119
        --IDE)
120
           ideSetup; printf "\n"; shift 1;;
121
        -q|--quit)
122
          quitScript; shift 1;;
123
        *)
124
          printError "invalid option: $1\n"; shift 1;;
125
      esac
126
    else
127
      otherargs+=("$1")
128
      shift 1
129
    fi
130
  done
131

    
132
  # interactive menu
133
  while ( true ); do
134
    # main menu info prompt and selection
135
    printInfo "AMiRo-Apps main menu\n"
136
    printf "Please select one of the following actions:\n"
137
    printf "  [E] - enter IDE project setup\n"
138
    printf "  [Q] - quit this setup\n"
139
    local userinput=""
140
    readUserInput "IiOoMmCcEeQq" userinput
141
    printf "\n"
142

    
143
    # evaluate user selection
144
    case "$userinput" in
145
      E|e)
146
        ideSetup; printf "\n";;
147
      Q|q)
148
        quitScript;;
149
      *) # sanity check (exit with error)
150
        printError "unexpected argument: $userinput\n";;
151
    esac
152
  done
153

    
154
  exit 0
155
}
156

    
157
################################################################################
158
# SCRIPT ENTRY POINT                                                           #
159
################################################################################
160

    
161
main "$@"