amiro-blt / ide / QtCreator / QtCreatorSetup.sh @ 316a2b34
History | View | Annotate | Download (31.723 KB)
1 | 4cce70a8 | Thomas Schöpping | ################################################################################ |
---|---|---|---|
2 | 1da30dfc | Thomas Schöpping | # AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini # |
3 | # Robot (AMiRo) platform. # |
||
4 | 4cce70a8 | Thomas Schöpping | # 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 | 69661903 | Thomas Schöpping | #!/bin/bash |
25 | |||
26 | 4cce70a8 | Thomas Schöpping | ################################################################################ |
27 | 1da30dfc | Thomas Schöpping | # GENERIC FUNCTIONS # |
28 | 4cce70a8 | Thomas Schöpping | ################################################################################ |
29 | 69661903 | Thomas Schöpping | |
30 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function printError { |
40 | local string="ERROR: $1" |
||
41 | # if a log file is specified |
||
42 | 0a42f078 | Thomas Schöpping | if [ -n "$LOG_FILE" ]; then |
43 | 1da30dfc | Thomas Schöpping | printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
44 | 69661903 | Thomas Schöpping | fi |
45 | 1da30dfc | Thomas Schöpping | printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2 |
46 | } |
||
47 | 69661903 | Thomas Schöpping | |
48 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function printWarning { |
58 | local string="WARNING: $1" |
||
59 | # if a log file is specified |
||
60 | 0a42f078 | Thomas Schöpping | if [ -n "$LOG_FILE" ]; then |
61 | 1da30dfc | Thomas Schöpping | printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
62 | fi |
||
63 | 0a42f078 | Thomas Schöpping | printf "$(tput setaf 3)>>> $string$(tput sgr 0)" |
64 | 1da30dfc | Thomas Schöpping | } |
65 | |||
66 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function printInfo { |
76 | local string="INFO: $1" |
||
77 | # if a log file is specified |
||
78 | 0a42f078 | Thomas Schöpping | if [ -n "$LOG_FILE" ]; then |
79 | 1da30dfc | Thomas Schöpping | printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
80 | fi |
||
81 | 0a42f078 | Thomas Schöpping | printf "$(tput setaf 2)>>> $string$(tput sgr 0)" |
82 | 1da30dfc | Thomas Schöpping | } |
83 | |||
84 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function printLog { |
93 | local string="LOG: $1" |
||
94 | # if a log file is specified |
||
95 | 0a42f078 | Thomas Schöpping | if [ -n "$LOG_FILE" ]; then |
96 | 1da30dfc | Thomas Schöpping | printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE |
97 | 69661903 | Thomas Schöpping | fi |
98 | 1da30dfc | Thomas Schöpping | } |
99 | |||
100 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function quitScript { |
109 | 3719a40a | Thomas Schöpping | printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n" |
110 | printf "\n" |
||
111 | 1da30dfc | Thomas Schöpping | printf "######################################################################\n" |
112 | exit 0 |
||
113 | 69661903 | Thomas Schöpping | } |
114 | |||
115 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function readUserInput { |
128 | 0a42f078 | Thomas Schöpping | local input="" |
129 | 1da30dfc | Thomas Schöpping | # read user input |
130 | 0a42f078 | Thomas Schöpping | 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 | 69661903 | Thomas Schöpping | fi |
135 | done |
||
136 | 0a42f078 | Thomas Schöpping | printLog "[$input] has been selected\n" |
137 | eval $2="$input" |
||
138 | 1da30dfc | Thomas Schöpping | } |
139 | 69661903 | Thomas Schöpping | |
140 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | return -1 |
160 | 69661903 | Thomas Schöpping | fi |
161 | 0a42f078 | Thomas Schöpping | } |
162 | 1da30dfc | Thomas Schöpping | |
163 | 0a42f078 | Thomas Schöpping | ### 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 | 0dc9f2f9 | Thomas Schöpping | # Possible values are 'a', 'c', 'r' and 'n'. |
173 | # - a: append (starts with a separator) |
||
174 | # - c: continue (does not insert a seperator) |
||
175 | 0a42f078 | Thomas Schöpping | # - 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 | 1da30dfc | Thomas Schöpping | local option="" |
192 | 0a42f078 | Thomas Schöpping | 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 | 1da30dfc | Thomas Schöpping | done |
213 | 0a42f078 | Thomas Schöpping | filepath=$(realpath ${otherargs[0]}) |
214 | 69661903 | Thomas Schöpping | |
215 | 1da30dfc | Thomas Schöpping | # if file already exists |
216 | 0a42f078 | Thomas Schöpping | if [ -e $filepath ]; then |
217 | 1da30dfc | Thomas Schöpping | # if no option was specified, ask what to do |
218 | 0a42f078 | Thomas Schöpping | if [ -z "$option" ]; then |
219 | printWarning "log file $filepath already esists\n" |
||
220 | local userinput="" |
||
221 | printf "Select what to do:\n" |
||
222 | 1da30dfc | Thomas Schöpping | printf " [A] - append log\n" |
223 | printf " [R] - restart log (delete existing file)\n" |
||
224 | printf " [N] - no log\n" |
||
225 | 0a42f078 | Thomas Schöpping | readUserInput "AaRrNn" userinput |
226 | 1da30dfc | Thomas Schöpping | option=${userinput,,} |
227 | fi |
||
228 | # evaluate option |
||
229 | 0a42f078 | Thomas Schöpping | case "$option" in |
230 | 0dc9f2f9 | Thomas Schöpping | a|c) |
231 | 0a42f078 | Thomas Schöpping | if [ $quiet = false ]; then |
232 | printInfo "appending log to $filepath\n" |
||
233 | fi |
||
234 | 0dc9f2f9 | Thomas Schöpping | if [ $option != c ]; then |
235 | printf "\n" >> $filepath |
||
236 | printf "######################################################################\n" >> $filepath |
||
237 | printf "\n" >> $filepath |
||
238 | fi |
||
239 | 1da30dfc | Thomas Schöpping | ;; |
240 | r) |
||
241 | 0a42f078 | Thomas Schöpping | echo -n "" > $filepath |
242 | if [ $quiet = false ]; then |
||
243 | printInfo "content of $filepath wiped\n" |
||
244 | fi |
||
245 | 1da30dfc | Thomas Schöpping | ;; |
246 | n) |
||
247 | 0a42f078 | Thomas Schöpping | if [ $quiet = false ]; then |
248 | printInfo "no log file will be generated\n" |
||
249 | fi |
||
250 | filepath="" |
||
251 | 1da30dfc | Thomas Schöpping | ;; |
252 | *) # sanity check (return error) |
||
253 | 0a42f078 | Thomas Schöpping | printError "unexpected argument: $option\n"; return -1;; |
254 | 1da30dfc | Thomas Schöpping | esac |
255 | 69661903 | Thomas Schöpping | else |
256 | 0a42f078 | Thomas Schöpping | if [ $quiet = false ]; then |
257 | printInfo "log file set to $filepath\n" |
||
258 | fi |
||
259 | 69661903 | Thomas Schöpping | fi |
260 | 0a42f078 | Thomas Schöpping | |
261 | eval ${otherargs[1]}="$filepath" |
||
262 | |||
263 | return 0 |
||
264 | 69661903 | Thomas Schöpping | } |
265 | 4cce70a8 | Thomas Schöpping | |
266 | 1da30dfc | Thomas Schöpping | ################################################################################ |
267 | # SPECIFIC FUNCTIONS # |
||
268 | ################################################################################ |
||
269 | |||
270 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function printWelcomeText { |
278 | 4cce70a8 | Thomas Schöpping | printf "######################################################################\n" |
279 | printf "# #\n" |
||
280 | 1da30dfc | Thomas Schöpping | printf "# Welcome to the QtCreator setup! #\n" |
281 | 4cce70a8 | Thomas Schöpping | printf "# #\n" |
282 | printf "######################################################################\n" |
||
283 | printf "# #\n" |
||
284 | printf "# Copyright (c) 2016..2017 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 | 1da30dfc | Thomas Schöpping | } |
296 | |||
297 | 0a42f078 | Thomas Schöpping | ### print help ################################################################# |
298 | # Prints a help text to standard out. |
||
299 | # |
||
300 | # usage: printHelp |
||
301 | # arguments: n/a |
||
302 | # return: n/a |
||
303 | # |
||
304 | 1da30dfc | Thomas Schöpping | function printHelp { |
305 | printInfo "printing help text\n" |
||
306 | 0a42f078 | Thomas Schöpping | 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 | 1da30dfc | Thomas Schöpping | } |
327 | 69661903 | Thomas Schöpping | |
328 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function getProjectDir { |
337 | 0a42f078 | Thomas Schöpping | printLog "reading path for project files from user...\n" |
338 | local amirobltdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../Target/) |
||
339 | local input="" |
||
340 | read -p "Path where to create/delete project files: " -i $amirobltdir -e input |
||
341 | printLog "user selected path $(realpath $input)\n" |
||
342 | eval $1="$(realpath $input)" |
||
343 | 1da30dfc | Thomas Schöpping | } |
344 | 69661903 | Thomas Schöpping | |
345 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function retrieveGccIncludeDir { |
357 | # retrieve binary path or link |
||
358 | 0a42f078 | Thomas Schöpping | local binpath=$(which arm-none-eabi-gcc) |
359 | 1da30dfc | Thomas Schöpping | if [ -z "$binpath" ]; then |
360 | 0a42f078 | Thomas Schöpping | printError "command 'arm-none-eabi-gcc' not found\n" |
361 | 1da30dfc | Thomas Schöpping | return -1 |
362 | 0a42f078 | Thomas Schöpping | else |
363 | 69661903 | Thomas Schöpping | |
364 | 0a42f078 | Thomas Schöpping | # traverse any links |
365 | while [ -L "$binpath" ]; do |
||
366 | binpath=$(readlink $binpath) |
||
367 | done |
||
368 | printInfo "gcc-arm-none-eabi detected: $binpath\n" |
||
369 | 69661903 | Thomas Schöpping | |
370 | 0a42f078 | Thomas Schöpping | # return include path |
371 | eval $1=$(realpath $(dirname ${binpath})/../arm-none-eabi/include/) |
||
372 | 69661903 | Thomas Schöpping | |
373 | 0a42f078 | Thomas Schöpping | return 0 |
374 | fi |
||
375 | 1da30dfc | Thomas Schöpping | } |
376 | 69661903 | Thomas Schöpping | |
377 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | # 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 | 69661903 | Thomas Schöpping | |
396 | 0a42f078 | Thomas Schöpping | # 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 | 4cce70a8 | Thomas Schöpping | done |
419 | 69661903 | Thomas Schöpping | |
420 | 1da30dfc | Thomas Schöpping | # 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 | 69661903 | Thomas Schöpping | |
427 | 1da30dfc | Thomas Schöpping | # read project directory if required |
428 | if [ -z "$projectdir" ]; then |
||
429 | getProjectDir projectdir |
||
430 | fi |
||
431 | 69661903 | Thomas Schöpping | |
432 | 1da30dfc | Thomas Schöpping | # 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 | 69661903 | Thomas Schöpping | |
437 | 1da30dfc | Thomas Schöpping | 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 | 4cce70a8 | Thomas Schöpping | |
441 | 1da30dfc | Thomas Schöpping | 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 | 4cce70a8 | Thomas Schöpping | |
445 | 1da30dfc | Thomas Schöpping | 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 | 69661903 | Thomas Schöpping | |
449 | 1da30dfc | Thomas Schöpping | if [ $wipe == true ]; then |
450 | rm ${projectdir}/LightRing.user 2>&1 | tee -a $LOG_FILE |
||
451 | rm ${projectdir}/PowerManagement.user 2>&1 | tee -a $LOG_FILE |
||
452 | rm ${projectdir}/DiWheelDrive.user 2>&1 | tee -a $LOG_FILE |
||
453 | fi |
||
454 | 69661903 | Thomas Schöpping | |
455 | 1da30dfc | Thomas Schöpping | # store the path to the output variable, if required |
456 | if [ ! -z "$outvar" ]; then |
||
457 | eval $outvar="$projectdir" |
||
458 | fi |
||
459 | 69661903 | Thomas Schöpping | |
460 | 1da30dfc | Thomas Schöpping | return 0 |
461 | } |
||
462 | 4cce70a8 | Thomas Schöpping | |
463 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function createLightRingProject { |
479 | local projectdir="" |
||
480 | 0a42f078 | Thomas Schöpping | local gccincludedir="" |
481 | 1da30dfc | Thomas Schöpping | local outvar="" |
482 | 0a42f078 | Thomas Schöpping | local gccoutvar="" |
483 | 4cce70a8 | Thomas Schöpping | |
484 | 0a42f078 | Thomas Schöpping | # parse arguments |
485 | local otherargs=() |
||
486 | while [ $# -gt 0 ]; do |
||
487 | if ( parseIsOption $1 ); then |
||
488 | case "$1" in |
||
489 | -p=*|--path=*) |
||
490 | projectdir=$(realpath "${1#*=}"); shift 1;; |
||
491 | -p|--path) |
||
492 | projectdir=$(realpath "$2"); shift 2;; |
||
493 | --gcc=*) |
||
494 | gccincludedir=$(realpath "${1#*=}"); shift 1;; |
||
495 | --gcc) |
||
496 | gccincludedir=$(realpath "$2"); shift 2;; |
||
497 | -o=*|--out=*) |
||
498 | outvar=${1#*=}; shift 1;; |
||
499 | -o|--out) |
||
500 | outvar=$2; shift 2;; |
||
501 | --gccout=*) |
||
502 | gccoutvar=$(realpath "${1#*=}"); shift 1;; |
||
503 | --gccout) |
||
504 | gccoutvar=$(realpath "$2"); shift 2;; |
||
505 | *) |
||
506 | printError "invalid option: $1\n"; shift 1;; |
||
507 | esac |
||
508 | else |
||
509 | otherargs+=("$1") |
||
510 | shift 1 |
||
511 | fi |
||
512 | 1da30dfc | Thomas Schöpping | done |
513 | |||
514 | # print message |
||
515 | 0a42f078 | Thomas Schöpping | printInfo "creating QtCreator project files for the LightRing module...\n" |
516 | 1da30dfc | Thomas Schöpping | |
517 | # read project directory if required |
||
518 | if [ -z "$projectdir" ]; then |
||
519 | getProjectDir projectdir |
||
520 | fi |
||
521 | |||
522 | # retrieve gcc-arm-none-eabi include dir |
||
523 | if [ -z "$gccincludedir" ]; then |
||
524 | 0a42f078 | Thomas Schöpping | retrieveGccIncludeDir gccincludedir |
525 | 1da30dfc | Thomas Schöpping | fi |
526 | |||
527 | # create project files |
||
528 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
529 | find $gccincludedir -type d > ${projectdir}/LightRing.includes |
||
530 | find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Source/) -type d | grep -v "ARMCM4_STM32" >> ${projectdir}/LightRing.includes |
||
531 | find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Demo/ARMCM3_STM32F103_LightRing_GCC/Boot/) -type d | grep -v "uip\|fatfs\|ethernetlib\|cmd\|ide" >> ${projectdir}/LightRing.includes |
||
532 | # generate a file that specifies all files |
||
533 | echo -n "" > ${projectdir}/LightRing.files |
||
534 | for path in `cat ${projectdir}/LightRing.includes`; do |
||
535 | find $path -maxdepth 1 -type f \( ! -iname ".*" \) | grep -v "/arm-none-eabi/" | grep -E ".*(\.h|\.c|\.x)$" >> ${projectdir}/LightRing.files |
||
536 | done |
||
537 | # generate a default project configuration file if none exists so far |
||
538 | if [ ! -f ${projectdir}/LightRing.config ]; then |
||
539 | echo -e "// Add predefined macros for your project here. For example:" > ${projectdir}/LightRing.config |
||
540 | echo -e "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/LightRing.config |
||
541 | echo -e "" >> ${projectdir}/LightRing.config |
||
542 | fi |
||
543 | # generate a default .creator file if none exists so far |
||
544 | if [ ! -f ${projectdir}/LightRing.creator ]; then |
||
545 | echo -e "[general]" > ${projectdir}/LightRing.creator |
||
546 | echo -e "" >> ${projectdir}/LightRing.creator |
||
547 | fi |
||
548 | |||
549 | 0a42f078 | Thomas Schöpping | # fill the output variables |
550 | 1da30dfc | Thomas Schöpping | if [ ! -z "$outvar" ]; then |
551 | eval $outvar="$projectdir" |
||
552 | fi |
||
553 | 0a42f078 | Thomas Schöpping | if [ ! -z "$gccoutvar" ]; then |
554 | eval $gccoutvar="$gccincludedir" |
||
555 | fi |
||
556 | 4cce70a8 | Thomas Schöpping | |
557 | 1da30dfc | Thomas Schöpping | return 0 |
558 | } |
||
559 | 4cce70a8 | Thomas Schöpping | |
560 | 0a42f078 | Thomas Schöpping | ### create PowerManagement project files ####################################### |
561 | # Create project files for the PowerManagement module. |
||
562 | # |
||
563 | # usage: createPowerManagementProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
||
564 | # arguments: -p, --path <path> |
||
565 | # Path where to create the project files. |
||
566 | # --gcc=<path> |
||
567 | # Path to the GCC include directory. |
||
568 | # -o, --out <var> |
||
569 | # Variable to store the path to. |
||
570 | # --gccout=<var> |
||
571 | # Variable to store the path to the GCC include directory to. |
||
572 | # return: 0 |
||
573 | # No error or warning occurred. |
||
574 | # |
||
575 | 1da30dfc | Thomas Schöpping | function createPowerManagementProject { |
576 | local projectdir="" |
||
577 | 0a42f078 | Thomas Schöpping | local gccincludedir="" |
578 | 1da30dfc | Thomas Schöpping | local outvar="" |
579 | 0a42f078 | Thomas Schöpping | local gccoutvar="" |
580 | 4cce70a8 | Thomas Schöpping | |
581 | 0a42f078 | Thomas Schöpping | # parse arguments |
582 | local otherargs=() |
||
583 | while [ $# -gt 0 ]; do |
||
584 | if ( parseIsOption $1 ); then |
||
585 | case "$1" in |
||
586 | -p=*|--path=*) |
||
587 | projectdir=$(realpath "${1#*=}"); shift 1;; |
||
588 | -p|--path) |
||
589 | projectdir=$(realpath "$2"); shift 2;; |
||
590 | --gcc=*) |
||
591 | gccincludedir=$(realpath "${1#*=}"); shift 1;; |
||
592 | --gcc) |
||
593 | gccincludedir=$(realpath "$2"); shift 2;; |
||
594 | -o=*|--out=*) |
||
595 | outvar=${1#*=}; shift 1;; |
||
596 | -o|--out) |
||
597 | outvar=$2; shift 2;; |
||
598 | --gccout=*) |
||
599 | gccoutvar=$(realpath "${1#*=}"); shift 1;; |
||
600 | --gccout) |
||
601 | gccoutvar=$(realpath "$2"); shift 2;; |
||
602 | *) |
||
603 | printError "invalid option: $1\n"; shift 1;; |
||
604 | esac |
||
605 | else |
||
606 | otherargs+=("$1") |
||
607 | shift 1 |
||
608 | fi |
||
609 | 1da30dfc | Thomas Schöpping | done |
610 | |||
611 | # print message |
||
612 | 0a42f078 | Thomas Schöpping | printInfo "creating QtCreator project files for the PowerManagement module...\n" |
613 | 4cce70a8 | Thomas Schöpping | |
614 | 1da30dfc | Thomas Schöpping | # read project directory if required |
615 | if [ -z "$projectdir" ]; then |
||
616 | getProjectDir projectdir |
||
617 | fi |
||
618 | |||
619 | # retrieve gcc-arm-none-eabi include dir |
||
620 | if [ -z "$gccincludedir" ]; then |
||
621 | 0a42f078 | Thomas Schöpping | retrieveGccIncludeDir gccincludedir |
622 | 1da30dfc | Thomas Schöpping | fi |
623 | 4cce70a8 | Thomas Schöpping | |
624 | 1da30dfc | Thomas Schöpping | # create project files |
625 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
626 | find $gccincludedir -type d > ${projectdir}/PowerManagement.includes |
||
627 | 0a42f078 | Thomas Schöpping | find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Source/) -type d | grep -v "ARMCM4_STM32" >> ${projectdir}/PowerManagement.includes |
628 | 1da30dfc | Thomas Schöpping | find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Demo/ARMCM4_STM32F405_Power_Management_GCC/Boot/) -type d | grep -v "uip\|fatfs\|ethernetlib\|cmd\|ide" >> ${projectdir}/PowerManagement.includes |
629 | # generate a file that specifies all files |
||
630 | echo -n "" > ${projectdir}/PowerManagement.files |
||
631 | for path in `cat ${projectdir}/PowerManagement.includes`; do |
||
632 | find $path -maxdepth 1 -type f \( ! -iname ".*" \) | grep -v "/arm-none-eabi/" | grep -E ".*(\.h|\.c|\.x)$" >> ${projectdir}/PowerManagement.files |
||
633 | done |
||
634 | # generate a default project configuration file if none exists so far |
||
635 | if [ ! -f ${projectdir}/PowerManagement.config ]; then |
||
636 | echo -e "// Add predefined macros for your project here. For example:" > ${projectdir}/PowerManagement.config |
||
637 | echo -e "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/PowerManagement.config |
||
638 | echo -e "" >> ${projectdir}/PowerManagement.config |
||
639 | fi |
||
640 | # generate a default .creator file if none exists so far |
||
641 | if [ ! -f ${projectdir}/PowerManagement.creator ]; then |
||
642 | echo -e "[general]" > ${projectdir}/PowerManagement.creator |
||
643 | echo -e "" >> ${projectdir}/PowerManagement.creator |
||
644 | fi |
||
645 | 4cce70a8 | Thomas Schöpping | |
646 | 0a42f078 | Thomas Schöpping | # fill the output variables |
647 | 1da30dfc | Thomas Schöpping | if [ ! -z "$outvar" ]; then |
648 | eval $outvar="$projectdir" |
||
649 | fi |
||
650 | 0a42f078 | Thomas Schöpping | if [ ! -z "$gccoutvar" ]; then |
651 | eval $gccoutvar="$gccincludedir" |
||
652 | fi |
||
653 | 4cce70a8 | Thomas Schöpping | |
654 | 1da30dfc | Thomas Schöpping | return 0 |
655 | } |
||
656 | 4cce70a8 | Thomas Schöpping | |
657 | 0a42f078 | Thomas Schöpping | ### create DiWheelDrive project files ########################################## |
658 | # Create project files for the DiWheelDrive module. |
||
659 | # |
||
660 | # usage: createDiWheelDriveProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
||
661 | # arguments: -p, --path <path> |
||
662 | # Path where to create the project files. |
||
663 | # --gcc=<path> |
||
664 | # Path to the GCC include directory. |
||
665 | # -o, --out <var> |
||
666 | # Variable to store the path to. |
||
667 | # --gccout=<var> |
||
668 | # Variable to store the path to the GCC include directory to. |
||
669 | # return: 0 |
||
670 | # No error or warning occurred. |
||
671 | # |
||
672 | 1da30dfc | Thomas Schöpping | function createDiWheelDriveProject { |
673 | local projectdir="" |
||
674 | 0a42f078 | Thomas Schöpping | local gccincludedir="" |
675 | 1da30dfc | Thomas Schöpping | local outvar="" |
676 | 0a42f078 | Thomas Schöpping | local gccoutvar="" |
677 | 4cce70a8 | Thomas Schöpping | |
678 | 0a42f078 | Thomas Schöpping | # parse arguments |
679 | local otherargs=() |
||
680 | while [ $# -gt 0 ]; do |
||
681 | if ( parseIsOption $1 ); then |
||
682 | case "$1" in |
||
683 | -p=*|--path=*) |
||
684 | projectdir=$(realpath "${1#*=}"); shift 1;; |
||
685 | -p|--path) |
||
686 | projectdir=$(realpath "$2"); shift 2;; |
||
687 | --gcc=*) |
||
688 | gccincludedir=$(realpath "${1#*=}"); shift 1;; |
||
689 | --gcc) |
||
690 | gccincludedir=$(realpath "$2"); shift 2;; |
||
691 | -o=*|--out=*) |
||
692 | outvar=${1#*=}; shift 1;; |
||
693 | -o|--out) |
||
694 | outvar=$2; shift 2;; |
||
695 | --gccout=*) |
||
696 | gccoutvar=$(realpath "${1#*=}"); shift 1;; |
||
697 | --gccout) |
||
698 | gccoutvar=$(realpath "$2"); shift 2;; |
||
699 | *) |
||
700 | printError "invalid option: $1\n"; shift 1;; |
||
701 | esac |
||
702 | else |
||
703 | otherargs+=("$1") |
||
704 | shift 1 |
||
705 | fi |
||
706 | 1da30dfc | Thomas Schöpping | done |
707 | 4cce70a8 | Thomas Schöpping | |
708 | 1da30dfc | Thomas Schöpping | # print message |
709 | 0a42f078 | Thomas Schöpping | printInfo "creating QtCreator project files for the DiWheelDrive module...\n" |
710 | 4cce70a8 | Thomas Schöpping | |
711 | 1da30dfc | Thomas Schöpping | # read project directory if required |
712 | if [ -z "$projectdir" ]; then |
||
713 | getProjectDir projectdir |
||
714 | fi |
||
715 | 4cce70a8 | Thomas Schöpping | |
716 | 1da30dfc | Thomas Schöpping | # retrieve gcc-arm-none-eabi include dir |
717 | if [ -z "$gccincludedir" ]; then |
||
718 | 0a42f078 | Thomas Schöpping | retrieveGccIncludeDir gccincludedir |
719 | 1da30dfc | Thomas Schöpping | fi |
720 | 4cce70a8 | Thomas Schöpping | |
721 | 1da30dfc | Thomas Schöpping | # create project files |
722 | # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
||
723 | find $gccincludedir -type d > ${projectdir}/DiWheelDrive.includes |
||
724 | find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Source/) -type d | grep -v "ARMCM4_STM32" >> ${projectdir}/DiWheelDrive.includes |
||
725 | find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/) -type d | grep -v "uip\|fatfs\|ethernetlib\|cmd\|ide" >> ${projectdir}/DiWheelDrive.includes |
||
726 | # generate a file that specifies all files |
||
727 | echo -n "" > ${projectdir}/DiWheelDrive.files |
||
728 | for path in `cat ${projectdir}/DiWheelDrive.includes`; do |
||
729 | find $path -maxdepth 1 -type f \( ! -iname ".*" \) | grep -v "/arm-none-eabi/" | grep -E ".*(\.h|\.c|\.x)$" >> ${projectdir}/DiWheelDrive.files |
||
730 | done |
||
731 | # generate a default project configuration file if none exists so far |
||
732 | if [ ! -f ${projectdir}/DiWheelDrive.config ]; then |
||
733 | echo -e "// Add predefined macros for your project here. For example:" > ${projectdir}/DiWheelDrive.config |
||
734 | echo -e "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/DiWheelDrive.config |
||
735 | echo -e "" >> ${projectdir}/DiWheelDrive.config |
||
736 | fi |
||
737 | # generate a default .creator file if none exists so far |
||
738 | if [ ! -f ${projectdir}/DiWheelDrive.creator ]; then |
||
739 | echo -e "[general]" > ${projectdir}/DiWheelDrive.creator |
||
740 | echo -e "" >> ${projectdir}/DiWheelDrive.creator |
||
741 | fi |
||
742 | 4cce70a8 | Thomas Schöpping | |
743 | 0a42f078 | Thomas Schöpping | # fill the output variables |
744 | 1da30dfc | Thomas Schöpping | if [ ! -z "$outvar" ]; then |
745 | eval $outvar="$projectdir" |
||
746 | fi |
||
747 | 0a42f078 | Thomas Schöpping | if [ ! -z "$gccoutvar" ]; then |
748 | eval $gccoutvar="$gccincludedir" |
||
749 | fi |
||
750 | 4cce70a8 | Thomas Schöpping | |
751 | 1da30dfc | Thomas Schöpping | return 0 |
752 | } |
||
753 | 4cce70a8 | Thomas Schöpping | |
754 | 0a42f078 | Thomas Schöpping | ### create project files for al modules ######################################## |
755 | # Create project files for all modules. |
||
756 | # |
||
757 | # usage: createAllProjects |
||
758 | # arguments: n/a |
||
759 | # return: 0 |
||
760 | # No error or warning occurred. |
||
761 | # |
||
762 | 1da30dfc | Thomas Schöpping | function createAllProjects { |
763 | 0a42f078 | Thomas Schöpping | # print message |
764 | printInfo "creating QtCreator project files for the DiWheelDrive module...\n" |
||
765 | 1da30dfc | Thomas Schöpping | |
766 | 0a42f078 | Thomas Schöpping | # read project directory |
767 | 1da30dfc | Thomas Schöpping | local projectdir="" |
768 | 0a42f078 | Thomas Schöpping | getProjectDir projectdir |
769 | printInfo "files will be created in $projectdir\n" |
||
770 | 4cce70a8 | Thomas Schöpping | |
771 | 0a42f078 | Thomas Schöpping | # retrieve gcc-arm-none-eabi include dir |
772 | retrieveGccIncludeDir gccincludedir |
||
773 | 4cce70a8 | Thomas Schöpping | |
774 | 1da30dfc | Thomas Schöpping | # create projects |
775 | 0a42f078 | Thomas Schöpping | createLightRingProject --path="$projectdir" --gcc="$gccincludedir" |
776 | createPowerManagementProject --path="$projectdir" --gcc="$gccincludedir" |
||
777 | createDiWheelDriveProject --path="$projectdir" --gcc="$gccincludedir" |
||
778 | 4cce70a8 | Thomas Schöpping | |
779 | 1da30dfc | Thomas Schöpping | return 0 |
780 | } |
||
781 | 4cce70a8 | Thomas Schöpping | |
782 | 0a42f078 | Thomas Schöpping | ### main function of this script ############################################### |
783 | # Creates, deletes and wipes QtCreator project files for the three AMiRo base modules. |
||
784 | # |
||
785 | # usage: see function printHelp |
||
786 | # arguments: see function printHelp |
||
787 | # return: 0 |
||
788 | # No error or warning ocurred. |
||
789 | # |
||
790 | 1da30dfc | Thomas Schöpping | function main { |
791 | 0a42f078 | Thomas Schöpping | # print welcome/info text if not suppressed |
792 | 1da30dfc | Thomas Schöpping | if [[ $@ != *"--noinfo"* ]]; then |
793 | printWelcomeText |
||
794 | else |
||
795 | printf "######################################################################\n" |
||
796 | fi |
||
797 | printf "\n" |
||
798 | |||
799 | 1446566f | Thomas Schöpping | # if --help or -h was specified, print the help text and exit |
800 | if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then |
||
801 | printHelp |
||
802 | printf "\n" |
||
803 | quitScript |
||
804 | fi |
||
805 | |||
806 | 1da30dfc | Thomas Schöpping | # set log file if specified |
807 | 0a42f078 | Thomas Schöpping | if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then |
808 | 1da30dfc | Thomas Schöpping | # get the parameter (file name) |
809 | local cmdidx=1 |
||
810 | 0a42f078 | Thomas Schöpping | while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do |
811 | 1da30dfc | Thomas Schöpping | cmdidx=$[cmdidx + 1] |
812 | done |
||
813 | 0a42f078 | Thomas Schöpping | local cmd="${!cmdidx}" |
814 | local logfile="" |
||
815 | if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then |
||
816 | logfile=${cmd#*=} |
||
817 | else |
||
818 | local filenameidx=$((cmdidx + 1)) |
||
819 | logfile="${!filenameidx}" |
||
820 | fi |
||
821 | 1da30dfc | Thomas Schöpping | # optionally force silent appending |
822 | 0a42f078 | Thomas Schöpping | if [[ "$cmd" = "--LOG"* ]]; then |
823 | 0dc9f2f9 | Thomas Schöpping | setLogFile --option=c --quiet "$logfile" LOG_FILE |
824 | 1da30dfc | Thomas Schöpping | else |
825 | 0a42f078 | Thomas Schöpping | setLogFile "$logfile" LOG_FILE |
826 | 1da30dfc | Thomas Schöpping | printf "\n" |
827 | fi |
||
828 | fi |
||
829 | # log script name |
||
830 | printLog "this is $(realpath ${BASH_SOURCE[0]})\n" |
||
831 | 4cce70a8 | Thomas Schöpping | |
832 | 0a42f078 | Thomas Schöpping | # parse arguments |
833 | local otherargs=() |
||
834 | while [ $# -gt 0 ]; do |
||
835 | if ( parseIsOption $1 ); then |
||
836 | case "$1" in |
||
837 | -h|--help) # already handled; ignore |
||
838 | shift 1;; |
||
839 | -c|--clean) |
||
840 | deleteProjects; printf "\n"; shift 1;; |
||
841 | -w|--wipe) |
||
842 | deleteProjects --wipe; printf "\n"; shift 1;; |
||
843 | --LightRing) |
||
844 | createLightRingProject; printf "\n"; shift 1;; |
||
845 | --PowerManagement) |
||
846 | createPowerManagementProject; printf "\n"; shift 1;; |
||
847 | --DiWheelDrive) |
||
848 | createDiWheelDriveProject; printf "\n"; shift 1;; |
||
849 | -a|--all) |
||
850 | createAllProjects; printf "\n"; shift 1;; |
||
851 | -q|--quit) |
||
852 | quitScript; shift 1;; |
||
853 | --log=*|--LOG=*) # already handled; ignore |
||
854 | shift 1;; |
||
855 | --log|--LOG) # already handled; ignore |
||
856 | shift 2;; |
||
857 | --noinfo) # already handled; ignore |
||
858 | shift 1;; |
||
859 | *) |
||
860 | printError "invalid option: $1\n"; shift 1;; |
||
861 | esac |
||
862 | else |
||
863 | otherargs+=("$1") |
||
864 | shift 1 |
||
865 | fi |
||
866 | 1da30dfc | Thomas Schöpping | done |
867 | 4cce70a8 | Thomas Schöpping | |
868 | 0a42f078 | Thomas Schöpping | # interactive menu |
869 | while ( true ); do |
||
870 | 1da30dfc | Thomas Schöpping | # main menu info prompt and selection |
871 | printInfo "QtCreator setup main menu\n" |
||
872 | printf "Please select one of the following actions:\n" |
||
873 | printf " [C] - clean project files\n" |
||
874 | printf " [W] - wipe project and .user files\n" |
||
875 | printf " [L] - create a project for the LightRing module\n" |
||
876 | printf " [P] - create a project for the PowerManagement module\n" |
||
877 | printf " [D] - create a project for the DiWheelDrive module\n" |
||
878 | printf " [A] - create a project for all modules\n" |
||
879 | printf " [Q] - quit this setup\n" |
||
880 | 0a42f078 | Thomas Schöpping | local userinput="" |
881 | readUserInput "CcWwLlPpDdAaQq" userinput |
||
882 | 1da30dfc | Thomas Schöpping | printf "\n" |
883 | |||
884 | # evaluate user selection |
||
885 | 0a42f078 | Thomas Schöpping | case "$userinput" in |
886 | 1da30dfc | Thomas Schöpping | C|c) |
887 | 0a42f078 | Thomas Schöpping | deleteProjects; printf "\n";; |
888 | 1da30dfc | Thomas Schöpping | W|w) |
889 | 0a42f078 | Thomas Schöpping | deleteProjects --wipe; printf "\n";; |
890 | 1da30dfc | Thomas Schöpping | L|l) |
891 | 0a42f078 | Thomas Schöpping | createLightRingProject; printf "\n";; |
892 | 1da30dfc | Thomas Schöpping | P|p) |
893 | 0a42f078 | Thomas Schöpping | createPowerManagementProject; printf "\n";; |
894 | 1da30dfc | Thomas Schöpping | D|d) |
895 | 0a42f078 | Thomas Schöpping | createDiWheelDriveProject; printf "\n";; |
896 | 1da30dfc | Thomas Schöpping | A|a) |
897 | 0a42f078 | Thomas Schöpping | createAllProjects; printf "\n";; |
898 | 1da30dfc | Thomas Schöpping | Q|q) |
899 | 0a42f078 | Thomas Schöpping | quitScript;; |
900 | 1da30dfc | Thomas Schöpping | *) # sanity check (exit with error) |
901 | 0a42f078 | Thomas Schöpping | printError "unexpected argument: $userinput\n";; |
902 | 4cce70a8 | Thomas Schöpping | esac |
903 | done |
||
904 | 1da30dfc | Thomas Schöpping | |
905 | exit 0 |
||
906 | } |
||
907 | 69661903 | Thomas Schöpping | |
908 | 4cce70a8 | Thomas Schöpping | ################################################################################ |
909 | 1da30dfc | Thomas Schöpping | # SCRIPT ENTRY POINT # |
910 | 4cce70a8 | Thomas Schöpping | ################################################################################ |
911 | 69661903 | Thomas Schöpping | |
912 | 1da30dfc | Thomas Schöpping | main "$@" |