Statistics
| Branch: | Tag: | Revision:

amiro-blt / setup.sh @ 4cce70a8

History | View | Annotate | Download (6.083 KB)

1
################################################################################
2
# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini    #
3
# Robot (AMiRo) platform.                                                      #
4
# Copyright (C) 2016..2017  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
# initial info text (can be disabled with 'no_info' as last argument)
27
if [[ ! ${!#} = "no_info" ]]; then
28
  printf "######################################################################\n"
29
  printf "#                                                                    #\n"
30
  printf "#                  Welcome to the AMiRo-BLT setup!                   #\n"
31
  printf "#                                                                    #\n"
32
  printf "######################################################################\n"
33
  printf "#                                                                    #\n"
34
  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
35
  printf "#                                                                    #\n"
36
  printf "# This is free software; see the source for copying conditions.      #\n"
37
  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
38
  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
39
  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
40
  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
41
  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
42
  printf "# Excellence Initiative.                                             #\n"
43
  printf "#                                                                    #\n"
44
  printf "######################################################################\n"
45
  printf "\n"
46
fi
47

    
48
# initialization of variables
49
ARG_IDX=1
50
USER_INPUT=${!ARG_IDX}
51

    
52
while [[ ! $USER_INPUT =~ ^[Ee]$ ]]; do
53

    
54
  # main menu info prompt and selection
55
  printf "AMiRo-BLT setup\n"
56
  printf "===============\n"
57
  printf "\n"
58
  if [[ -z $USER_INPUT || $USER_INPUT == "no_info" ]]; then
59
    printf "Please select one of the following actions:\n"
60
    printf "    [S] - SerialBoot flashing tool setup\n"
61
    printf "    [Q] - setup QtCreator projects\n"
62
    printf "    [E] - exit this setup\n"
63

    
64
    while [[ ! $USER_INPUT =~ ^[SsQqEe]$ ]]; do
65
      read -p "your selection: " -n 1 -e USER_INPUT
66
      if [[ ! $USER_INPUT =~ ^[SsQqEe]$ ]]; then
67
        printf "[%s] is no valid action. \n" $USER_INPUT
68
      fi
69
    done
70

    
71
    printf "\n"
72
    printf "######################################################################\n"
73
    printf "\n"
74
  fi
75

    
76
  # action selection
77
  case $USER_INPUT in
78

    
79
    # SerailBoot setup
80
    S|s)
81
      # print setup header
82
      printf "SerialBoot setup\n"
83
      printf "================\n"
84
      printf "\n"
85

    
86
      USER_DIR=${PWD}
87
      cd $(dirname ${BASH_SOURCE[0]})/Host/Source/SerialBoot
88
      BUILD_SERIALBOOT=true
89

    
90
      # test for existing binary
91
      if [ -f build/SerialBoot ]; then
92
        printf "WARNING: SerialBoot binary already exists.\n"
93
        read -p "Would you like to delete and rebuild it? [Y|n] " -n 1 -i "Y" -e USER_INPUT
94
        if [[ $USER_INPUT =~ ^[Yy]$ ]]; then
95
          BUILD_SERIALBOOT=true
96
          rm -rf build/
97
        elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then
98
          BUILD_SERIALBOOT=false
99
          printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT
100
        else
101
          BUILD_SERIALBOOT=false
102
        fi
103
      fi
104

    
105
      # build the tool, if requested
106
      if [ $BUILD_SERIALBOOT = true ]; then
107
        mkdir build
108
        cd build
109
        cmake ..
110
        make
111
      fi
112

    
113
      cd $USER_DIR
114
      ;;
115

    
116
    # QtCreator setup
117
    Q|q)
118
      # calling the script with no arguments prints the help and returns
119
      source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh "no_info"
120
      printf "\n"
121
      # set deafult arguments and call the script again
122
      USER_INPUT="clean all"
123
      read -p "select commands: " -i "$USER_INPUT" -e USER_INPUT
124
      printf "\n"
125
      source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh "no_info" $USER_INPUT
126
      ;;
127

    
128
    # exit
129
    E|e)
130
      break;
131
      ;;
132

    
133
    # sanity check
134
    *)
135
      printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
136
      printf "ERROR (${LINENO}): unexpected state; aborting script\n"
137
      printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
138
      printf "\n"
139
      exit
140
      ;;
141

    
142
  esac
143

    
144
  printf "\n"
145
  printf "######################################################################\n"
146
  printf "\n"
147

    
148
  let ARG_IDX++
149
  USER_INPUT=${!ARG_IDX}
150

    
151
done
152