Revision 959f302e
tools/ide/QtCreator/QtCreatorSetup.sh | ||
---|---|---|
303 | 303 |
# |
304 | 304 |
function printHelp { |
305 | 305 |
printInfo "printing help text\n" |
306 |
printf "usage: $(basename ${BASH_SOURCE[0]}) [-h|--help] [-c|--clean] [-w|--wipe] [--LightRing] [--PowerManagement] [--DiWheelDrive] [-a|--all] [-q|--quit] [--log=<file>]\n"
|
|
306 |
printf "usage: $(basename ${BASH_SOURCE[0]}) [-h|--help] [--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
|
|
307 | 307 |
printf "\n" |
308 | 308 |
printf "options: -h, --help\n" |
309 | 309 |
printf " Print this help text.\n" |
310 |
printf " --module=<module>\n" |
|
311 |
printf " Create project for a single module.\n" |
|
312 |
printf " -a, --all\n" |
|
313 |
printf " Create projects for all modules.\n" |
|
310 | 314 |
printf " -c, --clean\n" |
311 | 315 |
printf " Delete project files.\n" |
312 | 316 |
printf " -w, --wipe\n" |
313 | 317 |
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 | 318 |
printf " -q, --quit\n" |
323 | 319 |
printf " Quit the script.\n" |
324 | 320 |
printf " --log=<file>\n" |
... | ... | |
374 | 370 |
fi |
375 | 371 |
} |
376 | 372 |
|
377 |
### delete project files #######################################################
|
|
378 |
# Deletes all project files and optionally .user files, too.
|
|
373 |
### detect available modules ###################################################
|
|
374 |
# Detect all avalable modules supported by AMiRo-OS.
|
|
379 | 375 |
# |
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 |
# 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 |
|
376 |
# usage: detectModules <modulearray> |
|
377 |
# arguments: <modulearray> |
|
378 |
# Array variable to store all detected modules to. |
|
379 |
# return: n/a |
|
380 |
# |
|
381 |
function detectModules { |
|
382 |
local modulesdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../modules) |
|
383 |
local modules_detected=() |
|
395 | 384 |
|
396 |
# 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 |
|
385 |
# detect all available modules (via directories) |
|
386 |
for dir in $(ls -d ${modulesdir}/*/); do |
|
387 |
modules_detected[${#modules_detected[@]}]=$(basename $dir) |
|
418 | 388 |
done |
419 | 389 |
|
420 |
# 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 |
|
|
427 |
# read project directory if required |
|
428 |
if [ -z "$projectdir" ]; then |
|
429 |
getProjectDir projectdir |
|
430 |
fi |
|
431 |
|
|
432 |
# 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 |
|
|
437 |
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 |
|
|
441 |
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 |
|
|
445 |
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 |
|
|
449 |
if [ $wipe == true ]; then |
|
450 |
rm ${projectdir}/LightRing.creator.user 2>&1 | tee -a $LOG_FILE |
|
451 |
rm ${projectdir}/PowerManagement.creator.user 2>&1 | tee -a $LOG_FILE |
|
452 |
rm ${projectdir}/DiWheelDrive.creator.user 2>&1 | tee -a $LOG_FILE |
|
453 |
fi |
|
454 |
|
|
455 |
# store the path to the output variable, if required |
|
456 |
if [ ! -z "$outvar" ]; then |
|
457 |
eval $outvar="$projectdir" |
|
458 |
fi |
|
459 |
|
|
460 |
return 0 |
|
390 |
# set the output variable |
|
391 |
eval "$1=(${modules_detected[*]})" |
|
461 | 392 |
} |
462 | 393 |
|
463 |
### create LightRing project files #############################################
|
|
464 |
# Create project files for the LightRing module.
|
|
394 |
### create project files for a single module ###################################
|
|
395 |
# Create project files for a single module.
|
|
465 | 396 |
# |
466 |
# usage: createLightRingProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
|
467 |
# arguments: -p, --path <path> |
|
397 |
# usage: createModuleProject <modules> [-m|--module=<module>] [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
|
398 |
# arguments: <modules> |
|
399 |
# Array containing all modules available. |
|
400 |
# -m, --module <module> |
|
401 |
# Name (folder name) of the module for which project files shall be generated. |
|
402 |
# -p, --path <path> |
|
468 | 403 |
# Path where to create the project files. |
469 | 404 |
# --gcc=<path> |
470 | 405 |
# Path to the GCC include directory. |
... | ... | |
472 | 407 |
# Variable to store the path to. |
473 | 408 |
# --gccout=<var> |
474 | 409 |
# Variable to store the path to the GCC include directory to. |
410 |
# If this optional arguments is absent, ths function will ask for user input. |
|
475 | 411 |
# return: 0 |
476 | 412 |
# No error or warning occurred. |
413 |
# 1 |
|
414 |
# Aborted by user. |
|
415 |
# -1 |
|
416 |
# No modules available. |
|
417 |
# -2 |
|
418 |
# The specified <module> could not be found. |
|
419 |
# -3 |
|
420 |
# Parsing the project for the specified module failed. |
|
477 | 421 |
# |
478 |
function createLightRingProject {
|
|
422 |
function createModuleProject {
|
|
479 | 423 |
local userdir=$(pwd) |
424 |
local modulesdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../../modules) |
|
425 |
local modules=("${!1}") |
|
426 |
local module="" |
|
427 |
local moduleidx="" |
|
480 | 428 |
local projectdir="" |
481 | 429 |
local gccincludedir="" |
482 | 430 |
local outvar="" |
... | ... | |
487 | 435 |
while [ $# -gt 0 ]; do |
488 | 436 |
if ( parseIsOption $1 ); then |
489 | 437 |
case "$1" in |
438 |
-m=*|--module=*) |
|
439 |
module="${1#*=}"; shift 1;; |
|
440 |
-m|--module) |
|
441 |
module="$2"; shift 2;; |
|
490 | 442 |
-p=*|--path=*) |
491 | 443 |
projectdir=$(realpath "${1#*=}"); shift 1;; |
492 | 444 |
-p|--path) |
... | ... | |
512 | 464 |
fi |
513 | 465 |
done |
514 | 466 |
|
515 |
# print message |
|
516 |
printInfo "creating QtCreator project files for the LightRing module...\n" |
|
467 |
# sanity check for the modules variable |
|
468 |
if [ -z "${modules[*]}" ]; then |
|
469 |
printError "no modules available\n" |
|
470 |
return -1 |
|
471 |
fi |
|
472 |
|
|
473 |
# select module |
|
474 |
if [ -z $module ]; then |
|
475 |
# list all available modules |
|
476 |
printInfo "choose a module or type 'A' to abort:\n" |
|
477 |
for (( idx=0; idx<${#modules[@]}; ++idx )); do |
|
478 |
printf "%4u: %s\n" $(($idx + 1)) "${modules[$idx]}" |
|
479 |
done |
|
480 |
# read user input |
|
481 |
printLog "read user selection\n" |
|
482 |
local userinput="" |
|
483 |
while [[ ! "$userinput" =~ ^[0-9]+$ ]] || [ ! "$userinput" -gt 0 ] || [ ! "$userinput" -le ${#modules[@]} ] && [[ ! "$userinput" =~ ^[Aa]$ ]]; do |
|
484 |
read -p "your selection: " -e userinput |
|
485 |
printLog "user selection: $userinput\n" |
|
486 |
if [[ ! "$userinput" =~ ^[0-9]+$ ]] || [ ! "$userinput" -gt 0 ] || [ ! "$userinput" -le ${#modules[@]} ] && [[ ! "$userinput" =~ ^[Aa]$ ]]; then |
|
487 |
printWarning "Please enter an integer between 1 and ${#modules[@]} or 'A' to abort.\n" |
|
488 |
fi |
|
489 |
done |
|
490 |
if [[ "$userinput" =~ ^[Aa]$ ]]; then |
|
491 |
printWarning "aborted by user\n" |
|
492 |
return 1 |
|
493 |
fi |
|
494 |
# store selection |
|
495 |
moduleidx=$(($userinput - 1)) |
|
496 |
module="${modules[$moduleidx]}" |
|
497 |
printf "\n" |
|
498 |
else |
|
499 |
# search all modules for the selected one |
|
500 |
for (( idx=0; idx<${#modules[@]}; ++idx )); do |
|
501 |
if [ "${modules[$idx]}" = "$module" ]; then |
|
502 |
moduleidx=$idx |
|
503 |
break |
|
504 |
fi |
|
505 |
done |
|
506 |
# error if the module could not be found |
|
507 |
if [ -z $moduleidx ]; then |
|
508 |
printError "module ($module) not available\n" |
|
509 |
return -2 |
|
510 |
fi |
|
511 |
fi |
|
517 | 512 |
|
518 | 513 |
# read absolute project directory if required |
519 | 514 |
if [ -z "$projectdir" ]; then |
520 | 515 |
getProjectDir projectdir |
516 |
printf "\n" |
|
517 |
fi |
|
518 |
|
|
519 |
# check for existing project files |
|
520 |
if [ -f ${projectdir}/${module}.includes ] || [ -f ${projectdir}/${module}.files ] || [ -f ${projectdir}/${module}.config ] || [ -f ${projectdir}/${module}.creator ]; then |
|
521 |
printWarning "The following files will be overwritten:\n" |
|
522 |
if [ -f ${projectdir}/${module}.includes ]; then |
|
523 |
printWarning "\t${module}.includes\n" |
|
524 |
fi |
|
525 |
if [ -f ${projectdir}/${module}.files ]; then |
|
526 |
printWarning "\t${module}.files\n" |
|
527 |
fi |
|
528 |
if [ -f ${projectdir}/${module}.config ]; then |
|
529 |
printWarning "\t${module}.config\n" |
|
530 |
fi |
|
531 |
if [ -f ${projectdir}/${module}.creator ]; then |
|
532 |
printWarning "\t${module}.creator\n" |
|
533 |
fi |
|
534 |
local userinput="" |
|
535 |
printInfo "Continue and overwrite? [y/n]\n" |
|
536 |
readUserInput "YyNn" userinput |
|
537 |
case "$userinput" in |
|
538 |
Y|y) |
|
539 |
;; |
|
540 |
N|n) |
|
541 |
printWarning "Project generation for ${module} module aborted by user\n" |
|
542 |
return 1 |
|
543 |
;; |
|
544 |
*) |
|
545 |
printError "unexpected input: ${userinput}\n"; return -999;; |
|
546 |
esac |
|
547 |
printf "\n" |
|
521 | 548 |
fi |
522 | 549 |
|
523 |
# retrieve absolute GCC include dir |
|
550 |
# print message |
|
551 |
printInfo "generating QtCreator project files for the $module module...\n" |
|
552 |
|
|
553 |
# retrieve absolute GCC include path |
|
524 | 554 |
if [ -z "$gccincludedir" ]; then |
525 | 555 |
retrieveGccIncludeDir gccincludedir |
526 | 556 |
fi |
527 | 557 |
|
528 |
# move to project directory
|
|
529 |
cd $projectdir
|
|
558 |
# change to project directory
|
|
559 |
cd "$projectdir"
|
|
530 | 560 |
|
531 |
# AMiRo-OS, ChibiOS, AMiRo-BLT and AMiRo-LLD relative root directories
|
|
561 |
# run make, but only run the GCC preprocessor and produce no binaries
|
|
532 | 562 |
local amiroosrootdir=$(realpath $(dirname ${BASH_SOURCE[0]})/../../..) |
533 |
local chibiosrootdir=$(realpath ${amiroosrootdir}/kernel/ChibiOS) |
|
534 |
local amirobltrootdir=$(realpath ${amiroosrootdir}/bootloader/AMiRo-BLT) |
|
535 |
local amirolldrootdir=$(realpath ${amiroosrootdir}/periphery-lld/AMiRo-LLD) |
|
536 |
|
|
537 |
# generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
|
538 |
find $gccincludedir -type d > ${projectdir}/LightRing.includes |
|
539 |
echo $amiroosrootdir >> ${projectdir}/LightRing.includes |
|
540 |
find $amiroosrootdir/modules -type d | grep -v "/doc\|/build\|/.dep\|/PowerManagement\|/DiWheelDrive" >> ${projectdir}/LightRing.includes |
|
541 |
find $amiroosrootdir/core -type d >> ${projectdir}/LightRing.includes |
|
542 |
find $amiroosrootdir/unittests -type d >> ${projectdir}/LightRing.includes |
|
543 |
find $chibiosrootdir -type d | grep -E "/os/common/abstractions/cmsis_os$" >> ${projectdir}/LightRing.includes |
|
544 |
find $chibiosrootdir -type d | grep -E "/os/common/ext/CMSIS/(include|ST/STM32F1xx)$" >> ${projectdir}/LightRing.includes |
|
545 |
find $chibiosrootdir -type d | grep -E "/os/common/oslib/(include|src)$" >> ${projectdir}/LightRing.includes |
|
546 |
find $chibiosrootdir -type d | grep -E "/os/common/ports/ARMCMx(/compilers/GCC)?$" >> ${projectdir}/LightRing.includes |
|
547 |
find $chibiosrootdir -type d | grep -E "/os/common/startup/ARMCMx/(compilers/GCC|devices/STM32F1xx)$" >> ${projectdir}/LightRing.includes |
|
548 |
find $chibiosrootdir -type d | grep -E "/os/hal/(include|src)$" >> ${projectdir}/LightRing.includes |
|
549 |
find $chibiosrootdir -type d | grep -E "/os/hal/lib/streams" >> ${projectdir}/LightRing.includes |
|
550 |
find $chibiosrootdir -type d | grep -E "/os/hal/osal/(lib|rt)$" >> ${projectdir}/LightRing.includes |
|
551 |
find $chibiosrootdir -type d | grep -E "/os/hal/ports/(common/ARMCMx|STM32/(LLD/(CANv1|DACv1|DMAv1|EXTIv1|GPIOv1|I2Cv1|RTCv1|SDIOv1|SPIv1|TIMv1|USARTv1|USBv1|xWDGv1)|STM32F1xx))$" >> ${projectdir}/LightRing.includes |
|
552 |
find $chibiosrootdir -type d | grep -E "/os/license$" >> ${projectdir}/LightRing.includes |
|
553 |
find $chibiosrootdir -type d | grep -E "/os/rt/(include|src)$" >> ${projectdir}/LightRing.includes |
|
554 |
find $chibiosrootdir -type d | grep -E "/test/(lib|rt/source/test)$" >> ${projectdir}/LightRing.includes |
|
555 |
find $amirobltrootdir -type d | grep -E "/Target/Source/AMiRo$" >> ${projectdir}/LightRing.includes |
|
556 |
echo "$(realpath ${amirolldrootdir}/..)" >> ${projectdir}/LightRing.includes |
|
557 |
find $amirolldrootdir -type d | grep -v "/doc" >> ${projectdir}/LightRing.includes |
|
558 |
# generate a file that specifies all files |
|
559 |
echo -n "" > ${projectdir}/LightRing.files |
|
560 |
for path in `cat ${projectdir}/LightRing.includes`; do |
|
561 |
find $path -maxdepth 1 -type f \( ! -iname ".*" \) | |
|
562 |
grep -Ev "^.*((/arm-none-eabi/)|(PowerManagement)|(DiWheelDrive)).*$" | |
|
563 |
grep -E "^.*(\.s|\.S|\.h|\.c|\.hpp|\.cpp|\.tpp|\.ld)$" | |
|
564 |
grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/ST/STM32F1xx/((stm32f1[^0x])|(stm32f10[^3])|(stm32f103[^x])|(stm32f103x[^e])).*$" | |
|
565 |
grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/include/((core_[^c])|(core_c[^m])|(core_cm[^3A-Za-z])|(cmsis_[^g])|(cmsis_g[^c]|(cmsis_gc[^c])))" | |
|
566 |
grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/chcore_v[^7]m.*$" | |
|
567 |
grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/compilers/GCC/.*_v[^7]m.*$" | |
|
568 |
grep -Ev "^${chibiosrootdir}/os/common/startup/ARMCMx/compilers/GCC/.*_v[^7]m.*$" | |
|
569 |
grep -Ev "^${chibiosrootdir}/os/hal/ports/STM32/STM32F1xx/.*f10[^3].*$" | |
|
570 |
grep -Ev "^${amirobltrootdir}/Target/Source/AMiRo/helper.*$" >> ${projectdir}/LightRing.files; |
|
563 |
local sourcefiles=() |
|
564 |
local sourcefile="" |
|
565 |
local capture_state="WAIT_FOR_INCLUDE_OR_COMPILING" |
|
566 |
# capture all output from make and GCC and append the return value of make as last line |
|
567 |
printInfo "processing project (this may take a while)...\n" |
|
568 |
local rawout=$(make --directory ${amiroosrootdir}/modules/${module} --always-make USE_OPT="-v -E -H" OUTFILES="" 2>&1 && echo $?) |
|
569 |
# check whether the make call was successfull |
|
570 |
if [[ $(echo "${rawout}" | tail -n 1) != "0" ]]; then |
|
571 |
printError "executing 'make' in module directory failed\n" |
|
572 |
cd "$userdir" |
|
573 |
return -3 |
|
574 |
fi |
|
575 |
# extract file names from raw output |
|
576 |
while read line; do |
|
577 |
case $capture_state in |
|
578 |
WAIT_FOR_INCLUDE_OR_COMPILING) |
|
579 |
# lines stating included files look like: |
|
580 |
# ... <../relative/path/to/file> |
|
581 |
if [[ "$line" =~ ^\.+[[:blank:]].+\..+$ ]]; then |
|
582 |
sourcefile=${line##* } |
|
583 |
if [[ ! "$sourcefile" =~ ^/ ]]; then |
|
584 |
sourcefile=$(realpath ${amiroosrootdir}/modules/${module}/${sourcefile}) |
|
585 |
fi |
|
586 |
sourcefiles[${#sourcefiles[@]}]="$sourcefile" |
|
587 |
# whenever the next source file is processed, a message appears like: |
|
588 |
# Compining <filnemame> |
|
589 |
elif [[ "$line" =~ ^Compiling[[:blank:]].+\..+$ ]]; then |
|
590 |
printf "." |
|
591 |
sourcefile=${line##* } |
|
592 |
capture_state="WAIT_FOR_COMPILERCALL" |
|
593 |
fi;; |
|
594 |
WAIT_FOR_COMPILERCALL) |
|
595 |
# wait for the actual call of the compiler to retrieve the full path to the source file |
|
596 |
if [[ "$line" == *${sourcefile}* ]]; then |
|
597 |
line="${line%%${sourcefile}*}${sourcefile}" |
|
598 |
sourcefile=${line##* } |
|
599 |
sourcefile=$(realpath ${amiroosrootdir}/modules/${module}/${line##* }) |
|
600 |
sourcefiles[${#sourcefiles[@]}]="$sourcefile" |
|
601 |
capture_state="WAIT_FOR_INCLUDE_OR_COMPILING" |
|
602 |
fi;; |
|
603 |
esac |
|
604 |
done <<< "${rawout}" |
|
605 |
unset rawout |
|
606 |
printf "\n" |
|
607 |
# sort and remove duplicates |
|
608 |
IFS=$'\n'; sourcefiles=($(sort --unique <<< "${sourcefiles[*]}")); unset IFS |
|
609 |
|
|
610 |
# extract include paths |
|
611 |
local includes=() |
|
612 |
for source in ${sourcefiles[*]}; do |
|
613 |
includes[${#includes[@]}]="$(dirname ${source})" |
|
614 |
done |
|
615 |
# sort and remove duplicates |
|
616 |
IFS=$'\n'; includes=($(sort --unique <<< "${includes[*]}")); unset IFS |
|
617 |
|
|
618 |
# generate the .files file, containing all source files |
|
619 |
echo "" > ${projectdir}/${module}.includes |
|
620 |
for inc in ${includes[*]}; do |
|
621 |
echo "$inc" >> ${projectdir}/${module}.includes |
|
622 |
done |
|
623 |
# generate the .incldues file, containing all include paths |
|
624 |
echo "" > ${projectdir}/${module}.files |
|
625 |
for source in ${sourcefiles[*]}; do |
|
626 |
# skip GCC files |
|
627 |
if [[ ! "$source" =~ .*/gcc.* ]]; then |
|
628 |
echo "$source" >> ${projectdir}/${module}.files |
|
629 |
fi |
|
571 | 630 |
done |
572 |
# generate a default project configuration file if none exists so far
|
|
573 |
if [ ! -f ${projectdir}/LightRing.config ]; then
|
|
574 |
echo "// Add predefined macros for your project here. For example:" > ${projectdir}/LightRing.config
|
|
575 |
echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/LightRing.config
|
|
631 |
# generate a default project configuration file if it doesn't exist yet
|
|
632 |
if [ ! -f ${projectdir}/${module}.config ]; then
|
|
633 |
echo "// Add predefined macros for your project here. For example:" > ${projectdir}/${module}.config
|
|
634 |
echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/${module}.config
|
|
576 | 635 |
fi |
577 |
# generate a default .creator file if none exists so far
|
|
578 |
if [ ! -f ${projectdir}/LightRing}.creator ]; then
|
|
579 |
echo "[general]" > ${projectdir}/LightRing.creator
|
|
636 |
# generate a default .creator file if it doesn't exist yet
|
|
637 |
if [ ! -f ${projectdir}/${module}.creator ]; then
|
|
638 |
echo "[general]" > ${projectdir}/${module}.creator
|
|
580 | 639 |
fi |
581 | 640 |
|
582 | 641 |
# go back to user directory |
... | ... | |
593 | 652 |
return 0 |
594 | 653 |
} |
595 | 654 |
|
596 |
### create PowerManagement project files #######################################
|
|
597 |
# Create project files for the PowerManagement module.
|
|
655 |
### create project files for all modules #######################################
|
|
656 |
# Create project files for all modules.
|
|
598 | 657 |
# |
599 |
# usage: createPowerManagementProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
|
600 |
# arguments: -p, --path <path> |
|
658 |
# usage: createAllProjects <modules> [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>] |
|
659 |
# arguments: <modules> |
|
660 |
# Array containing all modules available. |
|
661 |
# -p, --path <path> |
|
601 | 662 |
# Path where to create the project files. |
602 | 663 |
# --gcc=<path> |
603 | 664 |
# Path to the GCC include directory. |
... | ... | |
605 | 666 |
# Variable to store the path to. |
606 | 667 |
# --gccout=<var> |
607 | 668 |
# Variable to store the path to the GCC include directory to. |
669 |
# If this optional arguments is absent, ths function will ask for user input. |
|
608 | 670 |
# return: 0 |
609 | 671 |
# No error or warning occurred. |
672 |
# -1 |
|
673 |
# No modules available. |
|
610 | 674 |
# |
611 |
function createPowerManagementProject {
|
|
612 |
local userdir=$(pwd)
|
|
675 |
function createAllProjects {
|
|
676 |
local modules=("${!1}")
|
|
613 | 677 |
local projectdir="" |
614 | 678 |
local gccincludedir="" |
615 | 679 |
local outvar="" |
... | ... | |
645 | 709 |
fi |
646 | 710 |
done |
647 | 711 |
|
648 |
# print message |
|
649 |
printInfo "creating QtCreator project files for the PowerManagement module...\n" |
|
712 |
# sanity check for the modules variable |
|
713 |
if [ -z "${modules[*]}" ]; then |
|
714 |
printError "no modules available\n" |
|
715 |
return -1 |
|
716 |
fi |
|
650 | 717 |
|
651 | 718 |
# read absolute project directory if required |
652 | 719 |
if [ -z "$projectdir" ]; then |
653 | 720 |
getProjectDir projectdir |
654 | 721 |
fi |
655 | 722 |
|
656 |
# retrieve absolute GCC include dir |
|
723 |
# print message |
|
724 |
printf "\n" |
|
725 |
printInfo "generating QtCreator project files for all modules...\n" |
|
726 |
|
|
727 |
# retrieve absolute GCC include path |
|
657 | 728 |
if [ -z "$gccincludedir" ]; then |
658 | 729 |
retrieveGccIncludeDir gccincludedir |
659 | 730 |
fi |
660 | 731 |
|
661 |
# move to project directory |
|
662 |
cd $projectdir |
|
663 |
|
|
664 |
# AMiRo-OS, ChibiOS, AMiRo-BLT and AMiRo-LLD relative root directories |
|
665 |
local amiroosrootdir=$(realpath $(dirname ${BASH_SOURCE[0]})/../../..) |
|
666 |
local chibiosrootdir=$(realpath ${amiroosrootdir}/kernel/ChibiOS) |
|
667 |
local amirobltrootdir=$(realpath ${amiroosrootdir}/bootloader/AMiRo-BLT) |
|
668 |
local amirolldrootdir=$(realpath ${amiroosrootdir}/periphery-lld/AMiRo-LLD) |
|
669 |
|
|
670 |
# generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
|
671 |
find $gccincludedir -type d > ${projectdir}/PowerManagement.includes |
|
672 |
echo $amiroosrootdir >> ${projectdir}/PowerManagement.includes |
|
673 |
find $amiroosrootdir/modules -type d | grep -v "/doc\|/build\|/.dep\|/LightRing\|/DiWheelDrive" >> ${projectdir}/PowerManagement.includes |
|
674 |
find $amiroosrootdir/core -type d >> ${projectdir}/PowerManagement.includes |
|
675 |
find $amiroosrootdir/unittests -type d >> ${projectdir}/PowerManagement.includes |
|
676 |
find $chibiosrootdir -type d | grep -E "/os/common/abstractions/cmsis_os$" >> ${projectdir}/PowerManagement.includes |
|
677 |
find $chibiosrootdir -type d | grep -E "/os/common/ext/CMSIS/(include|ST/STM32F4xx)$" >> ${projectdir}/PowerManagement.includes |
|
678 |
find $chibiosrootdir -type d | grep -E "/os/common/oslib/(include|src)$" >> ${projectdir}/PowerManagement.includes |
|
679 |
find $chibiosrootdir -type d | grep -E "/os/common/ports/ARMCMx(/compilers/GCC)?$" >> ${projectdir}/PowerManagement.includes |
|
680 |
find $chibiosrootdir -type d | grep -E "/os/common/startup/ARMCMx/(compilers/GCC|devices/STM32F4xx)$" >> ${projectdir}/PowerManagement.includes |
|
681 |
find $chibiosrootdir -type d | grep -E "/os/hal/(include|src)$" >> ${projectdir}/PowerManagement.includes |
|
682 |
find $chibiosrootdir -type d | grep -E "/os/hal/lib/streams" >> ${projectdir}/PowerManagement.includes |
|
683 |
find $chibiosrootdir -type d | grep -E "/os/hal/osal/(lib|rt)$" >> ${projectdir}/PowerManagement.includes |
|
684 |
find $chibiosrootdir -type d | grep -E "/os/hal/ports/(common/ARMCMx|STM32/(LLD/(ADCv2|CANv1|DACv1|DMAv2|EXTIv1|GPIOv2|I2Cv1|MACv1|OTGv1|RTCv2|SDIOv1|SPIv1|TIMv1|USARTv1|USBv1|xWDGv1)|STM32F4xx))$" >> ${projectdir}/PowerManagement.includes |
|
685 |
find $chibiosrootdir -type d | grep -E "/os/license$" >> ${projectdir}/PowerManagement.includes |
|
686 |
find $chibiosrootdir -type d | grep -E "/os/rt/(include|src)$" >> ${projectdir}/PowerManagement.includes |
|
687 |
find $chibiosrootdir -type d | grep -E "/test/(lib|rt/source/test)$" >> ${projectdir}/PowerManagement.includes |
|
688 |
find $amirobltrootdir -type d | grep -E "/Target/Source/AMiRo$" >> ${projectdir}/PowerManagement.includes |
|
689 |
echo "$(realpath ${amirolldrootdir}/..)" >> ${projectdir}/PowerManagement.includes |
|
690 |
find $amirolldrootdir -type d | grep -v "/doc" >> ${projectdir}/PowerManagement.includes |
|
691 |
# generate a file that specifies all files |
|
692 |
echo -n "" > ${projectdir}/PowerManagement.files |
|
693 |
for path in `cat ${projectdir}/PowerManagement.includes`; do |
|
694 |
find $path -maxdepth 1 -type f \( ! -iname ".*" \) | |
|
695 |
grep -Ev "^.*((/arm-none-eabi/)|(LightRing)|(DiWheelDrive)).*$" | |
|
696 |
grep -E "^.*(\.s|\.S|\.h|\.c|\.hpp|\.cpp|\.tpp|\.ld)$" | |
|
697 |
grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/ST/STM32F4xx/((stm32f4[^0x])|(stm32f40[^5])).*$" | |
|
698 |
grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/include/((core_[^c])|(core_c[^m])|(core_cm[^4A-Za-z])|(cmsis_[^g])|(cmsis_g[^c]|(cmsis_gc[^c])))" | |
|
699 |
grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/chcore_v[^7]m.*$" | |
|
700 |
grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/compilers/GCC/.*_v[^7]m.*$" | |
|
701 |
grep -Ev "^${chibiosrootdir}/os/common/startup/ARMCMx/compilers/GCC/.*_v[^7]m.*$" | |
|
702 |
grep -Ev "^${amirobltrootdir}/Target/Source/AMiRo/helper.*$" >> ${projectdir}/PowerManagement.files; |
|
732 |
# iterate over all modules |
|
733 |
local retval=1 |
|
734 |
for module in ${modules[@]}; do |
|
735 |
if [ $retval != 0 ]; then |
|
736 |
printf "\n" |
|
737 |
fi |
|
738 |
createModuleProject modules[@] --module="$module" --path="$projectdir" --gcc="$gccincludedir" |
|
739 |
retval=$? |
|
703 | 740 |
done |
704 |
# generate a default project configuration file if none exists so far |
|
705 |
if [ ! -f ${projectdir}/PowerManagement.config ]; then |
|
706 |
echo "// Add predefined macros for your project here. For example:" > ${projectdir}/PowerManagement.config |
|
707 |
echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/PowerManagement.config |
|
708 |
fi |
|
709 |
# generate a default .creator file if none exists so far |
|
710 |
if [ ! -f ${projectdir}/PowerManagement.creator ]; then |
|
711 |
echo "[general]" > ${projectdir}/PowerManagement.creator |
|
712 |
fi |
|
713 |
|
|
714 |
# go back to user directory |
|
715 |
cd $userdir |
|
716 |
|
|
717 |
# fill the output variables |
|
718 |
if [ ! -z "$outvar" ]; then |
|
719 |
eval $outvar="$projectdir" |
|
720 |
fi |
|
721 |
if [ ! -z "$gccoutvar" ]; then |
|
722 |
eval $gccoutvar="$gccincludedir" |
|
723 |
fi |
|
724 | 741 |
|
725 | 742 |
return 0 |
726 | 743 |
} |
727 | 744 |
|
728 |
### create DiWheelDrive project files ##########################################
|
|
729 |
# Create project files for the DiWheelDrive module.
|
|
745 |
### delete project files #######################################################
|
|
746 |
# Deletes all project files and optionally .user files, too.
|
|
730 | 747 |
# |
731 |
# usage: createDiWheelDriveProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
|
|
748 |
# usage: deleteProjects [-p|--path=<path>] [-m|--module=<module>] [-o|--out=<var>] [-w|-wipe]
|
|
732 | 749 |
# arguments: -p, --path <path> |
733 |
# Path where to create the project files.
|
|
734 |
# --gcc=<path>
|
|
735 |
# Path to the GCC include directory.
|
|
750 |
# Path where to delete the project files.
|
|
751 |
# -m, --module <module>
|
|
752 |
# Module name for which the project files shall be deleted.
|
|
736 | 753 |
# -o, --out <var> |
737 | 754 |
# Variable to store the path to. |
738 |
# --gccout=<var>
|
|
739 |
# Variable to store the path to the GCC include directory to.
|
|
740 |
# return: 0
|
|
741 |
# No error or warning occurred.
|
|
755 |
# -w, --wipe
|
|
756 |
# Delete .user files as well.
|
|
757 |
# return: |
|
758 |
# - 0: no error
|
|
742 | 759 |
# |
743 |
function createDiWheelDriveProject {
|
|
744 |
local userdir=$(pwd)
|
|
760 |
function deleteProjects {
|
|
761 |
local modulename=""
|
|
745 | 762 |
local projectdir="" |
746 |
local gccincludedir="" |
|
747 | 763 |
local outvar="" |
748 |
local gccoutvar="" |
|
764 |
local wipe=false |
|
765 |
local files="" |
|
749 | 766 |
|
750 | 767 |
# parse arguments |
751 | 768 |
local otherargs=() |
... | ... | |
756 | 773 |
projectdir=$(realpath "${1#*=}"); shift 1;; |
757 | 774 |
-p|--path) |
758 | 775 |
projectdir=$(realpath "$2"); shift 2;; |
759 |
--gcc=*)
|
|
760 |
gccincludedir=$(realpath "${1#*=}"); shift 1;;
|
|
761 |
--gcc)
|
|
762 |
gccincludedir=$(realpath "$2"); shift 2;;
|
|
776 |
-m=*|--module=*)
|
|
777 |
modulename="${1#*=}"; shift 1;;
|
|
778 |
-m|--module)
|
|
779 |
modulename="${2}"; shift 2;;
|
|
763 | 780 |
-o=*|--out=*) |
764 | 781 |
outvar=${1#*=}; shift 1;; |
765 | 782 |
-o|--out) |
766 | 783 |
outvar=$2; shift 2;; |
767 |
--gccout=*) |
|
768 |
gccoutvar=$(realpath "${1#*=}"); shift 1;; |
|
769 |
--gccout) |
|
770 |
gccoutvar=$(realpath "$2"); shift 2;; |
|
784 |
-w|--wipe) |
|
785 |
wipe=true; shift 1;; |
|
771 | 786 |
*) |
772 | 787 |
printError "invalid option: $1\n"; shift 1;; |
773 | 788 |
esac |
... | ... | |
777 | 792 |
fi |
778 | 793 |
done |
779 | 794 |
|
780 |
# print message |
|
781 |
printInfo "creating QtCreator project files for the DiWheelDrive module...\n" |
|
782 |
|
|
783 | 795 |
# read absolute project directory if required |
784 | 796 |
if [ -z "$projectdir" ]; then |
785 | 797 |
getProjectDir projectdir |
786 | 798 |
fi |
787 | 799 |
|
788 |
# retrieve absolute GCC include dir |
|
789 |
if [ -z "$gccincludedir" ]; then |
|
790 |
retrieveGccIncludeDir gccincludedir |
|
791 |
fi |
|
792 |
|
|
793 |
# move to project directory |
|
794 |
cd $projectdir |
|
795 |
|
|
796 |
# AMiRo-OS, ChibiOS, AMiRo-BLT and AMiRo-LLD relative root directories |
|
797 |
local amiroosrootdir=$(realpath $(dirname ${BASH_SOURCE[0]})/../../..) |
|
798 |
local chibiosrootdir=$(realpath ${amiroosrootdir}/kernel/ChibiOS) |
|
799 |
local amirobltrootdir=$(realpath ${amiroosrootdir}/bootloader/AMiRo-BLT) |
|
800 |
local amirolldrootdir=$(realpath ${amiroosrootdir}/periphery-lld/AMiRo-LLD) |
|
801 |
|
|
802 |
# generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories) |
|
803 |
find $gccincludedir -type d > ${projectdir}/DiWheelDrive.includes |
|
804 |
echo $amiroosrootdir >> ${projectdir}/DiWheelDrive.includes |
|
805 |
find $amiroosrootdir/modules -type d | grep -v "/doc\|/build\|/.dep\|/LightRing\|/PowerManagement" >> ${projectdir}/DiWheelDrive.includes |
|
806 |
find $amiroosrootdir/core -type d >> ${projectdir}/DiWheelDrive.includes |
|
807 |
find $amiroosrootdir/unittests -type d >> ${projectdir}/DiWheelDrive.includes |
|
808 |
find $chibiosrootdir -type d | grep -E "/os/common/abstractions/cmsis_os$" >> ${projectdir}/DiWheelDrive.includes |
|
809 |
find $chibiosrootdir -type d | grep -E "/os/common/ext/CMSIS/(include|ST/STM32F1xx)$" >> ${projectdir}/DiWheelDrive.includes |
|
810 |
find $chibiosrootdir -type d | grep -E "/os/common/oslib/(include|src)$" >> ${projectdir}/DiWheelDrive.includes |
|
811 |
find $chibiosrootdir -type d | grep -E "/os/common/ports/ARMCMx(/compilers/GCC)?$" >> ${projectdir}/DiWheelDrive.includes |
|
812 |
find $chibiosrootdir -type d | grep -E "/os/common/startup/ARMCMx/(compilers/GCC|devices/STM32F1xx)$" >> ${projectdir}/DiWheelDrive.includes |
|
813 |
find $chibiosrootdir -type d | grep -E "/os/hal/(include|src)$" >> ${projectdir}/DiWheelDrive.includes |
|
814 |
find $chibiosrootdir -type d | grep -E "/os/hal/lib/streams" >> ${projectdir}/DiWheelDrive.includes |
|
815 |
find $chibiosrootdir -type d | grep -E "/os/hal/osal/(lib|rt)$" >> ${projectdir}/DiWheelDrive.includes |
|
816 |
find $chibiosrootdir -type d | grep -E "/os/hal/ports/(common/ARMCMx|STM32/(LLD/(CANv1|DACv1|DMAv1|EXTIv1|GPIOv1|I2Cv1|RTCv1|SDIOv1|SPIv1|TIMv1|USARTv1|USBv1|xWDGv1)|STM32F1xx))$" >> ${projectdir}/DiWheelDrive.includes |
|
817 |
find $chibiosrootdir -type d | grep -E "/os/license$" >> ${projectdir}/DiWheelDrive.includes |
|
818 |
find $chibiosrootdir -type d | grep -E "/os/rt/(include|src)$" >> ${projectdir}/DiWheelDrive.includes |
|
819 |
find $chibiosrootdir -type d | grep -E "/test/(lib|rt/source/test)$" >> ${projectdir}/DiWheelDrive.includes |
|
820 |
find $amirobltrootdir -type d | grep -E "/Target/Source/AMiRo$" >> ${projectdir}/DiWheelDrive.includes |
|
821 |
echo "$(realpath ${amirolldrootdir}/..)" >> ${projectdir}/DiWheelDrive.includes |
|
822 |
find $amirolldrootdir -type d | grep -v "/doc" >> ${projectdir}/DiWheelDrive.includes |
|
823 |
# generate a file that specifies all files |
|
824 |
echo -n "" > ${projectdir}/DiWheelDrive.files |
|
825 |
for path in `cat ${projectdir}/DiWheelDrive.includes`; do |
|
826 |
find $path -maxdepth 1 -type f \( ! -iname ".*" \) | |
|
827 |
grep -Ev "^.*((/arm-none-eabi/)|(LightRing)|(PowerManagement)).*$" | |
|
828 |
grep -E "^.*(\.s|\.S|\.h|\.c|\.hpp|\.cpp|\.tpp|\.ld)$" | |
|
829 |
grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/ST/STM32F1xx/((stm32f1[^0x])|(stm32f10[^3])|(stm32f103[^x])|(stm32f103x[^e])).*$" | |
|
830 |
grep -Ev "^${chibiosrootdir}/os/common/ext/CMSIS/include/((core_[^c])|(core_c[^m])|(core_cm[^3A-Za-z])|(cmsis_[^g])|(cmsis_g[^c]|(cmsis_gc[^c])))" | |
|
831 |
grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/chcore_v[^7]m.*$" | |
|
832 |
grep -Ev "^${chibiosrootdir}/os/common/ports/ARMCMx/compilers/GCC/.*_v[^7]m.*$" | |
|
833 |
grep -Ev "^${chibiosrootdir}/os/common/startup/ARMCMx/compilers/GCC/.*_v[^7]m.*$" | |
|
834 |
grep -Ev "^${chibiosrootdir}/os/hal/ports/STM32/STM32F1xx/.*f10[^3].*$" | |
|
835 |
grep -Ev "^${amirobltrootdir}/Target/Source/AMiRo/helper.*$" >> ${projectdir}/DiWheelDrive.files; |
|
836 |
done |
|
837 |
# generate a default project configuration file if none exists so far |
|
838 |
if [ ! -f ${projectdir}/DiWheelDrive.config ]; then |
|
839 |
echo "// Add predefined macros for your project here. For example:" > ${projectdir}/DiWheelDrive.config |
|
840 |
echo "// #define YOUR_CONFIGURATION belongs here" >> ${projectdir}/DiWheelDrive.config |
|
800 |
# list all files to be deleted |
|
801 |
if [ -z "$modulename" ]; then |
|
802 |
if [ $wipe != true ]; then |
|
803 |
files=$(find "${projectdir}" -maxdepth 1 -type f | grep -E "^.+\.(includes|files|config|creator)$") |
|
804 |
else |
|
805 |
files=$(find "${projectdir}" -maxdepth 1 -type f | grep -E "^.+\.(includes|files|config|creator|creator\.user)$") |
|
806 |
fi |
|
807 |
else |
|
808 |
if [ $wipe != true ]; then |
|
809 |
files=$(find "${projectdir}" -maxdepth 1 -type f | grep -E "^.${modulename}\.(includes|files|config|creator)$") |
|
810 |
else |
|
811 |
files=$(find "${projectdir}" -maxdepth 1 -type f | grep -E "^.${modulename}\.(includes|files|config|creator|creator\.user)$") |
|
812 |
fi |
|
841 | 813 |
fi |
842 |
# generate a default .creator file if none exists so far |
|
843 |
if [ ! -f ${projectdir}/DiWheelDrive.creator ]; then |
|
844 |
echo "[general]" > ${projectdir}/DiWheelDrive.creator |
|
814 |
if [ ! -z "$files" ]; then |
|
815 |
printInfo "Deleting the following files:\n" |
|
816 |
while read line; do |
|
817 |
printInfo "\t$(basename ${line})\n" |
|
818 |
rm ${line} 2>&1 | tee -a $LOG_FILE |
|
819 |
done <<< "${files}" |
|
820 |
else |
|
821 |
printInfo "No project files found\n" |
|
845 | 822 |
fi |
846 | 823 |
|
847 |
# go back to user directory |
|
848 |
cd $userdir |
|
849 |
|
|
850 |
# fill the output variables |
|
824 |
# store the path to the output variable, if required |
|
851 | 825 |
if [ ! -z "$outvar" ]; then |
852 | 826 |
eval $outvar="$projectdir" |
853 | 827 |
fi |
854 |
if [ ! -z "$gccoutvar" ]; then |
|
855 |
eval $gccoutvar="$gccincludedir" |
|
856 |
fi |
|
857 |
|
|
858 |
return 0 |
|
859 |
} |
|
860 |
|
|
861 |
### create project files for all modules ####################################### |
|
862 |
# Create project files for all modules. |
|
863 |
# |
|
864 |
# usage: createAllProjects |
|
865 |
# arguments: n/a |
|
866 |
# return: 0 |
|
867 |
# No error or warning occurred. |
|
868 |
# |
|
869 |
function createAllProjects { |
|
870 |
# print message |
|
871 |
printInfo "creating QtCreator project files for the DiWheelDrive module...\n" |
|
872 |
|
|
873 |
# read project directory |
|
874 |
local projectdir="" |
|
875 |
getProjectDir projectdir |
|
876 |
printInfo "files will be created in $projectdir\n" |
|
877 |
|
|
878 |
# retrieve gcc-arm-none-eabi include dir |
|
879 |
retrieveGccIncludeDir gccincludedir |
|
880 |
|
|
881 |
# create projects |
|
882 |
createLightRingProject --path="$projectdir" --gcc="$gccincludedir" |
|
883 |
createPowerManagementProject --path="$projectdir" --gcc="$gccincludedir" |
|
884 |
createDiWheelDriveProject --path="$projectdir" --gcc="$gccincludedir" |
|
885 | 828 |
|
886 | 829 |
return 0 |
887 | 830 |
} |
... | ... | |
936 | 879 |
# log script name |
937 | 880 |
printLog "this is $(realpath ${BASH_SOURCE[0]})\n" |
938 | 881 |
|
882 |
# detect available modules and inform user |
|
883 |
local modules=() |
|
884 |
detectModules modules |
|
885 |
case "${#modules[@]}" in |
|
886 |
0) |
|
887 |
printInfo "no module has been detected\n";; |
|
888 |
1) |
|
889 |
printInfo "1 module has been detected:\n";; |
|
890 |
*) |
|
891 |
printInfo "${#modules[@]} modules have been detected:\n" |
|
892 |
esac |
|
893 |
for (( idx=0; idx<${#modules[@]}; ++idx )); do |
|
894 |
printInfo " - ${modules[$idx]}\n" |
|
895 |
done |
|
896 |
printf "\n" |
|
897 |
|
|
939 | 898 |
# parse arguments |
940 | 899 |
local otherargs=() |
941 | 900 |
while [ $# -gt 0 ]; do |
... | ... | |
943 | 902 |
case "$1" in |
944 | 903 |
-h|--help) # already handled; ignore |
945 | 904 |
shift 1;; |
905 |
-m=*|--module=*) |
|
906 |
createModuleProject modules[@] --module="${1#*=}"; printf "\n"; shift 1;; |
|
907 |
-m*|--module*) |
|
908 |
createModuleProject modules[@] --module="${2}"; printf "\n"; shift 2;; |
|
909 |
-a|--all) |
|
910 |
createAllProjects modules[@]; shift 1;; |
|
946 | 911 |
-c|--clean) |
947 | 912 |
deleteProjects; printf "\n"; shift 1;; |
948 | 913 |
-w|--wipe) |
949 | 914 |
deleteProjects --wipe; printf "\n"; shift 1;; |
950 |
--LightRing) |
|
951 |
createLightRingProject; printf "\n"; shift 1;; |
|
952 |
--PowerManagement) |
|
953 |
createPowerManagementProject; printf "\n"; shift 1;; |
|
954 |
--DiWheelDrive) |
|
955 |
createDiWheelDriveProject; printf "\n"; shift 1;; |
|
956 |
-a|--all) |
|
957 |
createAllProjects; printf "\n"; shift 1;; |
|
958 | 915 |
-q|--quit) |
959 | 916 |
quitScript; shift 1;; |
960 | 917 |
--log=*|--LOG=*) # already handled; ignore |
... | ... | |
977 | 934 |
# main menu info prompt and selection |
978 | 935 |
printInfo "QtCreator setup main menu\n" |
979 | 936 |
printf "Please select one of the following actions:\n" |
980 |
printf " [C] - clean project files\n" |
|
981 |
printf " [W] - wipe project and .user files\n" |
|
982 |
printf " [L] - create a project for the LightRing module\n" |
|
983 |
printf " [P] - create a project for the PowerManagement module\n" |
|
984 |
printf " [D] - create a project for the DiWheelDrive module\n" |
|
937 |
printf " [M] - create a project for a single module\n" |
|
985 | 938 |
printf " [A] - create a project for all modules\n" |
939 |
printf " [C] - clean all project files\n" |
|
940 |
printf " [W] - wipe all project and .user files\n" |
|
986 | 941 |
printf " [Q] - quit this setup\n" |
987 | 942 |
local userinput="" |
988 |
readUserInput "CcWwLlPpDdAaQq" userinput
|
|
943 |
readUserInput "MmAaCcWwQq" userinput
|
|
989 | 944 |
printf "\n" |
990 | 945 |
|
991 | 946 |
# evaluate user selection |
992 | 947 |
case "$userinput" in |
948 |
M|m) |
|
949 |
createModuleProject modules[@]; printf "\n";; |
|
950 |
A|a) |
|
951 |
createAllProjects modules[@]; printf "\n";; |
|
993 | 952 |
C|c) |
994 | 953 |
deleteProjects; printf "\n";; |
995 | 954 |
W|w) |
996 | 955 |
deleteProjects --wipe; printf "\n";; |
997 |
L|l) |
|
998 |
createLightRingProject; printf "\n";; |
|
999 |
P|p) |
|
1000 |
createPowerManagementProject; printf "\n";; |
|
1001 |
D|d) |
|
1002 |
createDiWheelDriveProject; printf "\n";; |
|
1003 |
A|a) |
|
1004 |
createAllProjects; printf "\n";; |
|
1005 | 956 |
Q|q) |
1006 | 957 |
quitScript;; |
1007 | 958 |
*) # sanity check (exit with error) |
Also available in: Unified diff