amiro-blt / tools / ide / QtCreator / QtCreatorSetup.sh @ 768babc5
History | View | Annotate | Download (25.866 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 | 94886d84 | Thomas Schöpping | # Copyright (C) 2016..2020 Thomas Schöpping et al. # |
| 5 | 4cce70a8 | Thomas Schöpping | # # |
| 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 | ec50c96e | Thomas Schöpping | # load library |
| 27 | source "$(dirname ${BASH_SOURCE[0]})/../../bash/setuplib.sh"
|
||
| 28 | 1da30dfc | Thomas Schöpping | |
| 29 | 0a42f078 | Thomas Schöpping | ### 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 | 1da30dfc | Thomas Schöpping | function printWelcomeText {
|
| 37 | 4cce70a8 | Thomas Schöpping | printf "######################################################################\n" |
| 38 | printf "# #\n" |
||
| 39 | 1da30dfc | Thomas Schöpping | printf "# Welcome to the QtCreator setup! #\n" |
| 40 | 4cce70a8 | Thomas Schöpping | printf "# #\n" |
| 41 | printf "######################################################################\n" |
||
| 42 | printf "# #\n" |
||
| 43 | 94886d84 | Thomas Schöpping | printf "# Copyright (c) 2016..2020 Thomas Schöpping #\n" |
| 44 | 4cce70a8 | Thomas Schöpping | 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 | 1da30dfc | Thomas Schöpping | } |
| 55 | |||
| 56 | 0a42f078 | Thomas Schöpping | ### print help ################################################################# |
| 57 | # Prints a help text to standard out. |
||
| 58 | # |
||
| 59 | # usage: printHelp |
||
| 60 | # arguments: n/a |
||
| 61 | # return: n/a |
||
| 62 | # |
||
| 63 | 1da30dfc | Thomas Schöpping | function printHelp {
|
| 64 | printInfo "printing help text\n" |
||
| 65 | d5a2a7ce | Thomas Schöpping | printf "usage: $(basename ${BASH_SOURCE[0]}) [-h|--help] [-m|--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
|
| 66 | 0a42f078 | Thomas Schöpping | printf "\n" |
| 67 | printf "options: -h, --help\n" |
||
| 68 | printf " Print this help text.\n" |
||
| 69 | d5a2a7ce | Thomas Schöpping | printf " -m, --module <module>\n" |
| 70 | 6c75ad52 | Thomas Schöpping | printf " Create project for a single module.\n" |
| 71 | printf " -a, --all\n" |
||
| 72 | printf " Create projects for all modules.\n" |
||
| 73 | 0a42f078 | Thomas Schöpping | printf " -c, --clean\n" |
| 74 | printf " Delete project files.\n" |
||
| 75 | printf " -w, --wipe\n" |
||
| 76 | printf " Delete project and .user files.\n" |
||
| 77 | printf " -q, --quit\n" |
||
| 78 | printf " Quit the script.\n" |
||
| 79 | printf " --log=<file>\n" |
||
| 80 | printf " Specify a log file.\n" |
||
| 81 | 1da30dfc | Thomas Schöpping | } |
| 82 | 69661903 | Thomas Schöpping | |
| 83 | 0a42f078 | Thomas Schöpping | ### read directory where to create/delete projects ############################# |
| 84 | # Read the directory where to create/delete project files from user. |
||
| 85 | # |
||
| 86 | # usage: getProjectDir <pathvar> |
||
| 87 | # arguments: <pathvar> |
||
| 88 | # Variable to store the selected path to. |
||
| 89 | # return: n/a |
||
| 90 | # |
||
| 91 | 1da30dfc | Thomas Schöpping | function getProjectDir {
|
| 92 | 0a42f078 | Thomas Schöpping | printLog "reading path for project files from user...\n" |
| 93 | 9085c3a0 | Thomas Schöpping | local amirobltdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../Target/)
|
| 94 | 0a42f078 | Thomas Schöpping | local input="" |
| 95 | read -p "Path where to create/delete project files: " -i $amirobltdir -e input |
||
| 96 | printLog "user selected path $(realpath $input)\n" |
||
| 97 | eval $1="$(realpath $input)" |
||
| 98 | 1da30dfc | Thomas Schöpping | } |
| 99 | 69661903 | Thomas Schöpping | |
| 100 | 0a42f078 | Thomas Schöpping | ### retrieves the ARM-NONE-EABI-GCC include directory ########################## |
| 101 | # Retrieves the include directory of the currently set arm-none-eabi-gcc. |
||
| 102 | # |
||
| 103 | # usage: retrieveGccIncludeDir <path> |
||
| 104 | # arguments: <path> |
||
| 105 | # Variable to store the path to. |
||
| 106 | # return: 0 |
||
| 107 | # No error or warning occurred. |
||
| 108 | # -1 |
||
| 109 | # Error: Command 'arm-none-eabi-gcc' not found. |
||
| 110 | 6c75ad52 | Thomas Schöpping | # -2 |
| 111 | d5a2a7ce | Thomas Schöpping | # Error: include directory could not be resolved. |
| 112 | 0a42f078 | Thomas Schöpping | # |
| 113 | 1da30dfc | Thomas Schöpping | function retrieveGccIncludeDir {
|
| 114 | # retrieve binary path or link |
||
| 115 | 0a42f078 | Thomas Schöpping | local binpath=$(which arm-none-eabi-gcc) |
| 116 | 6c75ad52 | Thomas Schöpping | local gccincpath="" |
| 117 | 1da30dfc | Thomas Schöpping | if [ -z "$binpath" ]; then |
| 118 | 0a42f078 | Thomas Schöpping | printError "command 'arm-none-eabi-gcc' not found\n" |
| 119 | 1da30dfc | Thomas Schöpping | return -1 |
| 120 | 0a42f078 | Thomas Schöpping | else |
| 121 | 69661903 | Thomas Schöpping | |
| 122 | 0a42f078 | Thomas Schöpping | # traverse any links |
| 123 | while [ -L "$binpath" ]; do |
||
| 124 | 7737db33 | Thomas Schöpping | binpath=$(realpath $(dirname $binpath)/$(readlink $binpath)) |
| 125 | 0a42f078 | Thomas Schöpping | done |
| 126 | printInfo "gcc-arm-none-eabi detected: $binpath\n" |
||
| 127 | 69661903 | Thomas Schöpping | |
| 128 | 0a42f078 | Thomas Schöpping | # return include path |
| 129 | 6c75ad52 | Thomas Schöpping | gccincpath=$(realpath $(dirname ${binpath})/../arm-none-eabi/include/)
|
| 130 | if [ ! -d "$gccincpath" ]; then |
||
| 131 | printWarning "$gccincpath does not exist\n" |
||
| 132 | return -2 |
||
| 133 | else |
||
| 134 | eval $1="$gccincpath" |
||
| 135 | return 0 |
||
| 136 | fi |
||
| 137 | 0a42f078 | Thomas Schöpping | fi |
| 138 | 1da30dfc | Thomas Schöpping | } |
| 139 | 69661903 | Thomas Schöpping | |
| 140 | 6c75ad52 | Thomas Schöpping | ### detect available modules ################################################### |
| 141 | # Detect all avalable modules supported by AMiRo-OS. |
||
| 142 | 0a42f078 | Thomas Schöpping | # |
| 143 | 6c75ad52 | Thomas Schöpping | # usage: detectModules <modulearray> |
| 144 | # arguments: <modulearray> |
||
| 145 | # Array variable to store all detected modules to. |
||
| 146 | # return: n/a |
||
| 147 | # |
||
| 148 | function detectModules {
|
||
| 149 | local modulesdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../Target/Modules)
|
||
| 150 | local modules_detected=() |
||
| 151 | 69661903 | Thomas Schöpping | |
| 152 | 6c75ad52 | Thomas Schöpping | # detect all available modules (via directories) |
| 153 | for dir in $(ls -d ${modulesdir}/*/); do
|
||
| 154 | modules_detected[${#modules_detected[@]}]=$(basename $dir)
|
||
| 155 | 4cce70a8 | Thomas Schöpping | done |
| 156 | 69661903 | Thomas Schöpping | |
| 157 | 6c75ad52 | Thomas Schöpping | # set the output variable |
| 158 | eval "$1=(${modules_detected[*]})"
|
||
| 159 | 1da30dfc | Thomas Schöpping | } |
| 160 | 4cce70a8 | Thomas Schöpping | |
| 161 | 6c75ad52 | Thomas Schöpping | ### create project files for a single module ################################### |
| 162 | # Create project files for a single module. |
||
| 163 | 0a42f078 | Thomas Schöpping | # |
| 164 | 6c75ad52 | Thomas Schöpping | # usage: createModuleProject <modules> [-m|--module=<module>] [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
| 165 | # arguments: <modules> |
||
| 166 | # Array containing all modules available. |
||
| 167 | # -m, --module <module> |
||
| 168 | # Name (folder name) of the module for which project files shall be generated. |
||
| 169 | # -p, --path <path> |
||
| 170 | 0a42f078 | Thomas Schöpping | # Path where to create the project files. |
| 171 | # --gcc=<path> |
||
| 172 | # Path to the GCC include directory. |
||
| 173 | # -o, --out <var> |
||
| 174 | # Variable to store the path to. |
||
| 175 | # --gccout=<var> |
||
| 176 | # Variable to store the path to the GCC include directory to. |
||
| 177 | 6c75ad52 | Thomas Schöpping | # If this optional arguments is absent, ths function will ask for user input. |
| 178 | 0a42f078 | Thomas Schöpping | # return: 0 |
| 179 | # No error or warning occurred. |
||
| 180 | 6c75ad52 | Thomas Schöpping | # 1 |
| 181 | # Aborted by user. |
||
| 182 | # -1 |
||
| 183 | # No modules available. |
||
| 184 | # -2 |
||
| 185 | # The specified <module> could not be found. |
||
| 186 | # -3 |
||
| 187 | # Parsing the project for the specified module failed. |
||
| 188 | # -4 |
||
| 189 | # Missing dependencies. |
||
| 190 | 0a42f078 | Thomas Schöpping | # |
| 191 | 6c75ad52 | Thomas Schöpping | function createModuleProject {
|
| 192 | cc06d380 | Thomas Schöpping | local userdir=$(pwd) |
| 193 | 6c75ad52 | Thomas Schöpping | local modulesdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../Target/Modules)
|
| 194 | local modules=("${!1}")
|
||
| 195 | local module="" |
||
| 196 | local moduleidx="" |
||
| 197 | 1da30dfc | Thomas Schöpping | local projectdir="" |
| 198 | 0a42f078 | Thomas Schöpping | local gccincludedir="" |
| 199 | 1da30dfc | Thomas Schöpping | local outvar="" |
| 200 | 0a42f078 | Thomas Schöpping | local gccoutvar="" |
| 201 | 4cce70a8 | Thomas Schöpping | |
| 202 | 6c75ad52 | Thomas Schöpping | # check dependencies |
| 203 | checkCommands make |
||
| 204 | if [ $? -ne 0 ]; then |
||
| 205 | printError "Missing dependencies detected.\n" |
||
| 206 | return -4 |
||
| 207 | fi |
||
| 208 | |||
| 209 | 0a42f078 | Thomas Schöpping | # parse arguments |
| 210 | local otherargs=() |
||
| 211 | while [ $# -gt 0 ]; do |
||
| 212 | if ( parseIsOption $1 ); then |
||
| 213 |