annotate scripts/.bela_common @ 523:42f6af3a5f1d prerelease

build_project and build_pd_heavy mostly done
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 23 Jun 2016 04:31:09 +0100
parents c774bd8ad108
children 1ca196e35105
rev   line source
giuliomoro@516 1 [ -z "$BBB_USER" ] && BBB_USER="root"
giuliomoro@516 2 [ -z "$BBB_HOSTNAME" ] && BBB_HOSTNAME="192.168.7.2"
giuliomoro@516 3 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="$BBB_USER@$BBB_HOSTNAME"
giuliomoro@445 4 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
giuliomoro@445 5 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela"
giuliomoro@445 6 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
giuliomoro@445 7 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
giuliomoro@445 8 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
giuliomoro@445 9 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
giuliomoro@445 10 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
giuliomoro@445 11 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
giuliomoro@445 12 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
giuliomoro@445 13
giuliomoro@445 14 trap "echo; exit 0;" 2 9
giuliomoro@445 15 folder_has_changed(){
giuliomoro@447 16 [ -z "$2" ] && { echo "Error: folder_has_changed(folder, reference, [filter])"; return 1; }
giuliomoro@445 17 [ -z "$3" ] && FILTER="." || FILTER="$3"
giuliomoro@523 18 # Do not watch hidden files or folders
giuliomoro@523 19 find "$1" -type f -not -path '*/\.*' -newer "$2" | grep "$FILTER"
giuliomoro@445 20 return $?
giuliomoro@445 21 }
giuliomoro@445 22
giuliomoro@445 23 wait_for_change(){
giuliomoro@447 24 [ -z "$2" ] && { echo "Error: folder_has_changed(folder, reference, [filter])"; return 1; }
giuliomoro@445 25 [ -z "$4" ] && SLEEP=0.5 || SLEEP="$4"
giuliomoro@445 26 while ! folder_has_changed "$1" "$2" "$3"
giuliomoro@445 27 do
giuliomoro@445 28 sleep $SLEEP;
giuliomoro@445 29 done
giuliomoro@445 30 }
giuliomoro@445 31
giuliomoro@445 32 set_date(){
giuliomoro@445 33 # an optional parameter will be executed as part of the same ssh session
giuliomoro@518 34 ssh $BBB_ADDRESS "date -s \"`date '+%Y%m%d %T %z'`\" > /dev/null; $1"
giuliomoro@445 35 }
giuliomoro@515 36
giuliomoro@515 37 check_board_alive(){
giuliomoro@515 38 printf "Checking the board is up and running at $BBB_ADDRESS..."
giuliomoro@515 39 ssh -o ConnectTimeout=10 $BBB_ADDRESS exit && printf "done\n" || {
giuliomoro@515 40 printf "\nERROR: the board does not respond at $BBB_ADDRESS, check that the address is correct and the board is connected.\n";
giuliomoro@515 41 exit 1;
giuliomoro@515 42 }
giuliomoro@515 43 }
giuliomoro@523 44
giuliomoro@523 45 build_script_usage(){
giuliomoro@523 46 echo " The program can be run in one of the following modes:
giuliomoro@523 47 -f arg : runs in the foreground (default).
giuliomoro@523 48 -b arg : runs in the background (no output is shown)
giuliomoro@523 49
giuliomoro@523 50 When running in the foreground you can stop the currently running program
giuliomoro@523 51 with ctrl-C.
giuliomoro@523 52 When running in the background, you can use \`./stop_running.sh' to stop
giuliomoro@523 53 the current process and \`./connect_to_project.sh' to see the program's output.
giuliomoro@523 54
giuliomoro@523 55 Other options:
giuliomoro@523 56 --clean : cleans the pre-compiled object files on the board (same as \`-m coreclean').
giuliomoro@523 57 If the linker issues warnings during a build, or you see that your latest changes are not
giuliomoro@523 58 being applied to the running program, try to add the --clean flag for the next build and see
giuliomoro@523 59 if that fixes it.
giuliomoro@523 60
giuliomoro@523 61 --watch: the script will wait for changes in the source folder and when it detects them it
giuliomoro@523 62 triggers a new build. If you do not run the program with -b, then you will have to
giuliomoro@523 63 either kill the process or detach from the screen in order for the watchdog to be active.
giuliomoro@523 64 -n : the output will not be run after compiling.
giuliomoro@523 65 -c \"args\" : passes command-line arguments to the Bela program; e
giuliomoro@523 66 close the argument string in quotes.
giuliomoro@523 67 -p arg : sets the name of the project to in the remote folder (default: $BBB_PROJECT_NAME )
giuliomoro@523 68 do not use spaces in your project names, please
giuliomoro@523 69 -m \"args\" allows to pass arguments to the Makefile before the run target. For instance,
giuliomoro@523 70 pass -m \`"projectclean"\` or \`-m "distclean"\` to clean project-specific
giuliomoro@523 71 pre-built objects, or all the pre-built objects, respectively.
giuliomoro@523 72 "
giuliomoro@523 73 }