Revision cacd990c

View differences:

bootloader/AMiRo-BLT
1
Subproject commit 5c8c470ff389fb8e049be416b1e7382e5f62dfc7
1
Subproject commit d5a2a7ce252878928ae693d2de59b95eac51af77
tools/ide/QtCreator/QtCreatorSetup.sh
62 62
#
63 63
function printHelp {
64 64
  printInfo "printing help text\n"
65
  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
65
  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-m|--module=<module>] [-a|--all] [-c|--clean] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
66 66
  printf "\n"
67 67
  printf "options:  -h, --help\n"
68 68
  printf "              Print this help text.\n"
69
  printf "          --module=<module>\n"
69
  printf "          -m, --module <module>\n"
70 70
  printf "              Create project for a single module.\n"
71 71
  printf "          -a, --all\n"
72 72
  printf "              Create projects for all modules.\n"
......
108 108
#            -1
109 109
#                 Error: Command 'arm-none-eabi-gcc' not found.
110 110
#            -2
111
#                 Error: include directory could not be resolved
111
#                 Error: include directory could not be resolved.
112 112
#
113 113
function retrieveGccIncludeDir {
114 114
  # retrieve binary path or link
......
325 325
  fi
326 326

  
327 327
  # change to project directory
328
  local amiroosrootdir=$(realpath $(dirname ${BASH_SOURCE[0]})/../../..)
329 328
  cd "$projectdir"
330 329

  
331 330
  # run make, but only run the GCC preprocessor and produce no binaries
332 331
  local sourcefiles=()
333 332
  local sourcefile=""
334
  local parse_state="WAIT_FOR_INCLUDE_OR_COMPILE"
333
  local parse_state="WAIT_FOR_INCLUDE_COMPILE_MAKE"
334
  local makedirs=()
335 335
  # capture all output from make and GCC and append the return value of make as last line
336 336
  printInfo "processing project (this may take a while)...\n"
337
  local rawout=$(make --directory ${amiroosrootdir}/modules/${module} --always-make USE_OPT="-v -E -H" USE_VERBOSE_COMPILE="no" OUTFILES="" 2>&1 && echo $?)
337
  local rawout=$(make --directory ${modulesdir}/${module} --always-make USE_OPT="-v -E -H" USE_VERBOSE_COMPILE="no" OUTFILES="" 2>&1 && echo $?)
338 338
  # check whether the make call was successfull
339 339
  if [[ $(echo "${rawout}" | tail -n 1) != "0" ]]; then
340 340
    printError "executing 'make' in module directory failed\n"
......
342 342
    return -3
343 343
  else
344 344
    # cleanup
345
    make --directory ${amiroosrootdir}/modules/${module} clean &>/dev/null
345
    make --directory ${modulesdir}/${module} clean &>/dev/null
346 346
  fi
347 347
  # extract file names from raw output
348 348
  IFS=$'\n'; rawout=($rawout); unset IFS
349 349
  for line in "${rawout[@]}"; do
350 350
    case $parse_state in
351
      WAIT_FOR_INCLUDE_OR_COMPILE)
352
        # lines stating included files look like:
351
      WAIT_FOR_INCLUDE_COMPILE_MAKE)
352
        # lines stating include files look like:
353 353
        # ... <../relative/path/to/file>
354 354
        if [[ "$line" =~ ^\.+[[:blank:]].+\..+$ ]]; then
355 355
          sourcefile=${line##* }
356 356
          if [[ ! "$sourcefile" =~ ^/ ]]; then
357
            sourcefile=$(realpath ${amiroosrootdir}/modules/${module}/${sourcefile})
357
            sourcefile=$(realpath ${makedirs[-1]}/${sourcefile})
358 358
          fi
359 359
          sourcefiles[${#sourcefiles[@]}]="$sourcefile"
360 360
        # whenever the next source file is processed, a message appears like:
361
        # Compining <filnemame>
361
        # Compiling <filename>
362 362
        elif [[ "$line" =~ ^Compiling[[:blank:]](.+\..+)$ ]]; then
363 363
          printf "."
364 364
          sourcefile=${BASH_REMATCH[1]}
365 365
          parse_state="WAIT_FOR_COMPILERCALL"
366
        # if make is called again in another directory, a message appears like:
367
        # make[1]: Entering directory 'directory'
368
        elif [[ "$line" =~ ^make(\[[0-9]+\])?:\ Entering\ directory\ \'.+\'$ ]]; then
369
          makedirs+=($(echo "$line" | (cut -d "'" -f 2)))
370
        # if make is leaving a directory, a message appears like:
371
        # make[1]: Leaving directory 'directory'
372
        elif [[ "$line" =~ ^make(\[[0-9]+\])?:\ Leaving\ directory\ \'.+\'$ ]]; then
373
          unset makedirs[-1]
366 374
        fi;;
367 375
      WAIT_FOR_COMPILERCALL)
368 376
        # wait for the actual call of the compiler to retrieve the full path to the source file
369 377
        if [[ "$line" == *${sourcefile}* ]]; then
370 378
          line="${line%%${sourcefile}*}${sourcefile}"
371
          sourcefile=$(realpath ${amiroosrootdir}/modules/${module}/${line##* })
379
          line="${line##* }"
380
          if [[ "$line" =~ ^/ ]]; then
381
            # aboslute path
382
            sourcefile=$line
383
          else
384
            # relative path
385
            sourcefile=$(realpath ${makedirs[-1]}/${line##* })
386
          fi
372 387
          sourcefiles[${#sourcefiles[@]}]="$sourcefile"
373
          parse_state="WAIT_FOR_INCLUDE_OR_COMPILE"
388
          parse_state="WAIT_FOR_INCLUDE_COMPILE_MAKE"
374 389
        fi;;
375 390
    esac
376 391
  done
......
387 402
  # sort and remove duplicates
388 403
  IFS=$'\n'; includes=($(sort --unique <<< "${includes[*]}")); unset IFS
389 404

  
390
  # generate the .files file, containing all source files
405
  # generate the .incldues file, containing all include paths
391 406
  echo "" > ${projectdir}/${module}.includes
392 407
  for inc in ${includes[*]}; do
393 408
    echo "$inc" >> ${projectdir}/${module}.includes
394 409
  done
395
  # generate the .incldues file, containing all include paths
410
  # generate the .files file, containing all source files
396 411
  echo "" > ${projectdir}/${module}.files
397 412
  for source in ${sourcefiles[*]}; do
398 413
    # skip GCC files
......
448 463
#
449 464
function createAllProjects {
450 465
  local modules=("${!1}")
451
  local projectdir=""
466
  local projectsdir=""
452 467
  local gccincludedir=""
453 468
  local outvar=""
454 469
  local gccoutvar=""
......
459 474
    if ( parseIsOption $1 ); then
460 475
      case "$1" in
461 476
        -p=*|--path=*)
462
          projectdir=$(realpath "${1#*=}"); shift 1;;
477
          projectsdir=$(realpath "${1#*=}"); shift 1;;
463 478
        -p|--path)
464
          projectdir=$(realpath "$2"); shift 2;;
479
          projectsdir=$(realpath "$2"); shift 2;;
465 480
        --gcc=*)
466 481
          gccincludedir=$(realpath "${1#*=}"); shift 1;;
467 482
        --gcc)
......
490 505
  fi
491 506

  
492 507
  # read absolute project directory if required
493
  if [ -z "$projectdir" ]; then
494
    getProjectDir projectdir
508
  if [ -z "$projectsdir" ]; then
509
    getProjectDir projectsdir
495 510
  fi
496 511

  
497 512
  # check for existing project files
498
  local projectfiles=()
513
  local projectfiles=""
499 514
  for module in ${modules[@]}; do
500
    local pfiles="$(find ${projectdir} -maxdepth 1 -type f | grep -E "${module}\.(includes|files|config|creator)$")"
501
    IFS=$'\n'; pfiles=($pfiles); unset IFS
502
    projectfiles=( ${projectfiles[*]} ${pfiles[*]} )
515
    projectfiles+="$(find ${projectsdir} -maxdepth 1 -type f | grep -E "${module}\.(includes|files|config|creator)$")"
503 516
  done
517
  IFS=$'\n'; projectfiles=($projectfiles); unset IFS
504 518
  if [ ! -z "${projectfiles[*]}" ]; then
505 519
    printWarning "The following files will be removed:\n"
506 520
    for pfile in ${projectfiles[@]}; do
......
541 555
    if [ $retval != 0 ]; then
542 556
      printf "\n"
543 557
    fi
544
    createModuleProject modules[@] --module="$module" --path="$projectdir" --gcc="$gccincludedir"
558
    createModuleProject modules[@] --module="$module" --path="$projectsdir" --gcc="$gccincludedir"
545 559
    retval=$?
546 560
  done
547 561

  
......
636 650
}
637 651

  
638 652
### main function of this script ###############################################
639
# Creates, deletes and wipes QtCreator project files for the three AMiRo base modules.
653
# Creates, deletes and wipes QtCreator project files for any module supported by AMiRo-OS.
640 654
#
641 655
# usage:      see function printHelp
642 656
# arguments:  see function printHelp

Also available in: Unified diff