amiro-os / tools / ide / QtCreator / QtCreatorSetup.sh @ 23ec8223
History | View | Annotate | Download (25.929 KB)
| 1 | e545e620 | Thomas Schöpping | ################################################################################ |
|---|---|---|---|
| 2 | # AMiRo-OS is an operating system designed for the Autonomous Mini Robot # |
||
| 3 | # (AMiRo) platform. # |
||
| 4 | 96621a83 | Thomas Schöpping | # Copyright (C) 2016..2020 Thomas Schöpping et al. # |
| 5 | e545e620 | 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 | #!/bin/bash |
||
| 25 | |||
| 26 | 8516dad6 | Thomas Schöpping | # load library |
| 27 | source "$(dirname ${BASH_SOURCE[0]})/../../bash/setuplib.sh"
|
||
| 28 | e545e620 | Thomas Schöpping | |
| 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 QtCreator setup! #\n" |
||
| 40 | printf "# #\n" |
||
| 41 | printf "######################################################################\n" |
||
| 42 | printf "# #\n" |
||
| 43 | 96621a83 | Thomas Schöpping | printf "# Copyright (c) 2016..2020 Thomas Schöpping #\n" |
| 44 | e545e620 | 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 | } |
||
| 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 | 959f302e | Thomas Schöpping | printf "usage: $(basename ${BASH_SOURCE[0]}) [-h|--help] [--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
|
| 66 | e545e620 | Thomas Schöpping | printf "\n" |
| 67 | printf "options: -h, --help\n" |
||
| 68 | printf " Print this help text.\n" |
||
| 69 | 959f302e | Thomas Schöpping | printf " --module=<module>\n" |
| 70 | printf " Create project for a single module.\n" |
||
| 71 | printf " -a, --all\n" |
||
| 72 | printf " Create projects for all modules.\n" |
||
| 73 | e545e620 | 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 | } |
||
| 82 | |||
| 83 | ### 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 | function getProjectDir {
|
||
| 92 | printLog "reading path for project files from user...\n" |
||
| 93 | local amiroosdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../)
|
||
| 94 | local input="" |
||
| 95 | read -p "Path where to create/delete project files: " -i $amiroosdir -e input |
||
| 96 | printLog "user selected path $(realpath $input)\n" |
||
| 97 | eval $1="$(realpath $input)" |
||
| 98 | } |
||
| 99 | |||
| 100 | ### 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 | 9cee554d | Thomas Schöpping | # -2 |
| 111 | # Error: include directory could not be resolved |
||
| 112 | e545e620 | Thomas Schöpping | # |
| 113 | function retrieveGccIncludeDir {
|
||
| 114 | # retrieve binary path or link |
||
| 115 | local binpath=$(which arm-none-eabi-gcc) |
||
| 116 | 9cee554d | Thomas Schöpping | local gccincpath="" |
| 117 | e545e620 | Thomas Schöpping | if [ -z "$binpath" ]; then |
| 118 | printError "command 'arm-none-eabi-gcc' not found\n" |
||
| 119 | return -1 |
||
| 120 | else |
||
| 121 | |||
| 122 | # traverse any links |
||
| 123 | while [ -L "$binpath" ]; do |
||
| 124 | 680d05e5 | Thomas Schöpping | binpath=$(realpath $(dirname $binpath)/$(readlink $binpath)) |
| 125 | e545e620 | Thomas Schöpping | done |
| 126 | printInfo "gcc-arm-none-eabi detected: $binpath\n" |
||
| 127 | |||
| 128 | # return include path |
||
| 129 | 9cee554d | 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 | e545e620 | Thomas Schöpping | fi |
| 138 | } |
||
| 139 | |||
| 140 | 959f302e | Thomas Schöpping | ### detect available modules ################################################### |
| 141 | # Detect all avalable modules supported by AMiRo-OS. |
||
| 142 | e545e620 | Thomas Schöpping | # |
| 143 | 959f302e | 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]}))/../../../modules)
|
||
| 150 | local modules_detected=() |
||
| 151 | e545e620 | Thomas Schöpping | |
| 152 | 959f302e | 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 | e545e620 | Thomas Schöpping | done |
| 156 | |||
| 157 | 959f302e | Thomas Schöpping | # set the output variable |
| 158 | eval "$1=(${modules_detected[*]})"
|
||
| 159 | e545e620 | Thomas Schöpping | } |
| 160 | |||
| 161 | 959f302e | Thomas Schöpping | ### create project files for a single module ################################### |
| 162 | # Create project files for a single module. |
||
| 163 | e545e620 | Thomas Schöpping | # |
| 164 | 959f302e | 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 | e545e620 | 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 | 959f302e | Thomas Schöpping | # If this optional arguments is absent, ths function will ask for user input. |
| 178 | e545e620 | Thomas Schöpping | # return: 0 |
| 179 | # No error or warning occurred. |
||
| 180 | 959f302e | 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 | 57cbd1cd | Thomas Schöpping | # -4 |
| 189 | # Missing dependencies. |
||
| 190 | e545e620 | Thomas Schöpping | # |
| 191 | 959f302e | Thomas Schöpping | function createModuleProject {
|
| 192 | e545e620 | Thomas Schöpping | local userdir=$(pwd) |
| 193 | 959f302e | Thomas Schöpping | local modulesdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../modules)
|
| 194 | local modules=("${!1}")
|
||
| 195 | local module="" |
||
| 196 | local moduleidx="" |
||
| 197 | e545e620 | Thomas Schöpping | local projectdir="" |
| 198 | local gccincludedir="" |
||
| 199 | local outvar="" |
||
| 200 | local gccoutvar="" |
||
| 201 | |||
| 202 | 57cbd1cd | 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 | e545e620 | Thomas Schöpping | # parse arguments |
| 210 | local otherargs=() |
||
| 211 | while [ $# -gt 0 ]; do |
||
| 212 | if ( parseIsOption $1 ); then |
||
| 213 | case "$1" in |
||
| 214 | 959f302e | Thomas Schöpping | -m=*|--module=*) |
| 215 | module="${1#*=}"; shift 1;;
|
||
| 216 | -m|--module) |
||
| 217 | module="$2"; shift 2;; |
||
| 218 | e545e620 | Thomas Schöpping | -p=*|--path=*) |
| 219 | projectdir=$(realpath "${1#*=}"); shift 1;;
|
||
| 220 | -p|--path) |
||
| 221 | projectdir=$(realpath "$2"); shift 2;; |
||
| 222 | --gcc=*) |
||
| 223 | gccincludedir=$(realpath "${1#*=}"); shift 1;;
|
||
| 224 | --gcc) |
||
| 225 | gccincludedir=$(realpath "$2"); shift 2;; |
||
| 226 | -o=*|--out=*) |
||
| 227 | outvar=${1#*=}; shift 1;;
|
||
| 228 | -o|--out) |
||
| 229 | outvar=$2; shift 2;; |
||
| 230 | --gccout=*) |
||
| 231 | gccoutvar=$(realpath "${1#*=}"); shift 1;;
|
||
| 232 | --gccout) |
||
| 233 | gccoutvar=$(realpath "$2"); shift 2;; |
||
| 234 | *) |
||
| 235 | printError "invalid option: $1\n"; shift 1;; |
||
| 236 | esac |
||
| 237 | else |
||
| 238 | otherargs+=("$1")
|
||
| 239 |