Statistics
| Branch: | Tag: | Revision:

amiro-os / tools / ide / idesetup.sh @ 8516dad6

History | View | Annotate | Download (7.54 KB)

1
################################################################################
2
# AMiRo-OS is an operating system designed for the Autonomous Mini Robot       #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2016..2020  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]})/../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-OS IDE setup!                 #\n"
40
  printf "#                                                                    #\n"
41
  printf "######################################################################\n"
42
  printf "#                                                                    #\n"
43
  printf "# Copyright (c) 2016..2020  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] [--QtCreator] [-q|--quit] [--log=<file>]\n"
66
  printf "\n"
67
  printf "options:  -h, --help\n"
68
  printf "              Print this help text.\n"
69
  printf "          --QtCreator\n"
70
  printf "              Enter QtCreator setup.\n"
71
  printf "          -q, --quit\n"
72
  printf "              Quit the script.\n"
73
  printf "          --log=<file>\n"
74
  printf "              Specify a log file.\n"
75
}
76

    
77
### enter QtCreator setup ######################################################
78
# Enter the QtCreator IDE setup.
79
#
80
# usage:      qtCreatorSetup
81
# arguments:  n/a
82
# return:     n/a
83
function qtCreatorSetup {
84
  printInfo "entering QtCreator setup...\n"
85
  printf "\n"
86
  if [ -z "$LOG_FILE" ]; then
87
    $(realpath $(dirname ${BASH_SOURCE[0]}))/QtCreator/QtCreatorSetup.sh --noinfo
88
  else
89
    $(realpath $(dirname ${BASH_SOURCE[0]}))/QtCreator/QtCreatorSetup.sh --LOG="$LOG_FILE" --noinfo
90
  fi
91
}
92

    
93
### main function of this script ###############################################
94
# The IDE setup lets the user select an IDE of choice.
95
# As of now, only QtCreator is supported.
96
#
97
# usage:      see function printHelp
98
# arguments:  see function printHelp
99
# return:     0
100
#                 No error or warning occurred.
101
#
102
function main {
103
  # print welcome/info text if not suppressed
104
  if [[ $@ != *"--noinfo"* ]]; then
105
    printWelcomeText
106
  else
107
    printf "######################################################################\n"
108
  fi
109
  printf "\n"
110

    
111
  # if --help or -h was specified, print the help text and exit
112
  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
113
    printHelp
114
    printf "\n"
115
    quitScript
116
  fi
117

    
118
  # set log file if specified
119
  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
120
    # get the parameter (file name)
121
    local cmdidx=1
122
    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
123
      cmdidx=$[cmdidx + 1]
124
    done
125
    local cmd="${!cmdidx}"
126
    local logfile=""
127
    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
128
      logfile=${cmd#*=}
129
    else
130
      local filenameidx=$((cmdidx + 1))
131
      logfile="${!filenameidx}"
132
    fi
133
    # optionally force silent appending
134
    if [[ "$cmd" = "--LOG"* ]]; then
135
      setLogFile --option=c --quiet "$logfile" LOG_FILE
136
    else
137
      setLogFile "$logfile" LOG_FILE
138
      printf "\n"
139
    fi
140
  fi
141
  # log script name
142
  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
143

    
144
  # parse arguments
145
  local otherargs=()
146
  while [ $# -gt 0 ]; do
147
    if ( parseIsOption $1 ); then
148
      case "$1" in
149
        -h|--help) # already handled; ignore
150
          shift 1;;
151
        --QtCreator)
152
          qtCreatorSetup; printf "\n"; shift 1;;
153
        -q|--quit)
154
          quitScript; printf "\n"; shift 1;;
155
        --log=*|--LOG=*) # already handled; ignore
156
          shift 1;;
157
        --log|--LOG) # already handled; ignore
158
          shift 2;;
159
        --noinfo) # already handled; ignore
160
          shift 1;;
161
        *)
162
          printError "invalid option: $1\n"; shift 1;;
163
      esac
164
    else
165
      otherargs+=("$1")
166
      shift 1
167
    fi
168
  done
169

    
170
  # interactive menu
171
  while ( true ); do
172
    # main menu info prompt and selection
173
    printInfo "AMiRo-OS IDE setup main menu\n"
174
    printf "Please select one of the following actions:\n"
175
    printf "  [C] - enter QtCreator setup\n"
176
    printf "  [Q] - quit this setup\n"
177
    local userinput=""
178
    readUserInput "CcQq" userinput
179
    printf "\n"
180

    
181
    # evaluate user selection
182
    case "$userinput" in
183
      C|c)
184
        qtCreatorSetup; printf "\n";;
185
      Q|q)
186
        quitScript;;
187
      *) # sanity check (exit with error)
188
        printError "unexpected argument: $userinput\n";;
189
    esac
190
  done
191

    
192
  exit 0
193
}
194

    
195
################################################################################
196
# SCRIPT ENTRY POINT                                                           #
197
################################################################################
198

    
199
main "$@"