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@529
|
39 ssh -o StrictHostKeyChecking=no -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@525
|
45 build_script_usage_brief(){
|
giuliomoro@525
|
46 printf "Usage: $THIS_SCRIPT [-c command-line-args] [-nbfF] [--watch] [--clean]%s <directory-with-source-files>" "$1"
|
giuliomoro@525
|
47 }
|
giuliomoro@525
|
48
|
giuliomoro@523
|
49 build_script_usage(){
|
giuliomoro@523
|
50 echo " The program can be run in one of the following modes:
|
giuliomoro@523
|
51 -f arg : runs in the foreground (default).
|
giuliomoro@523
|
52 -b arg : runs in the background (no output is shown)
|
giuliomoro@523
|
53
|
giuliomoro@523
|
54 When running in the foreground you can stop the currently running program
|
giuliomoro@523
|
55 with ctrl-C.
|
giuliomoro@523
|
56 When running in the background, you can use \`./stop_running.sh' to stop
|
giuliomoro@523
|
57 the current process and \`./connect_to_project.sh' to see the program's output.
|
giuliomoro@523
|
58
|
giuliomoro@523
|
59 Other options:
|
giuliomoro@525
|
60 --clean : cleans the pre-compiled object files on the board (same as \`-m projectclean').
|
giuliomoro@523
|
61 If the linker issues warnings during a build, or you see that your latest changes are not
|
giuliomoro@523
|
62 being applied to the running program, try to add the --clean flag for the next build and see
|
giuliomoro@523
|
63 if that fixes it.
|
giuliomoro@523
|
64
|
giuliomoro@523
|
65 --watch: the script will wait for changes in the source folder and when it detects them it
|
giuliomoro@523
|
66 triggers a new build. If you do not run the program with -b, then you will have to
|
giuliomoro@523
|
67 either kill the process or detach from the screen in order for the watchdog to be active.
|
giuliomoro@523
|
68 -n : the output will not be run after compiling.
|
giuliomoro@523
|
69 -c \"args\" : passes command-line arguments to the Bela program; e
|
giuliomoro@523
|
70 close the argument string in quotes.
|
giuliomoro@523
|
71 -p arg : sets the name of the project to in the remote folder (default: $BBB_PROJECT_NAME )
|
giuliomoro@523
|
72 do not use spaces in your project names, please
|
giuliomoro@523
|
73 -m \"args\" allows to pass arguments to the Makefile before the run target. For instance,
|
giuliomoro@523
|
74 pass -m \`"projectclean"\` or \`-m "distclean"\` to clean project-specific
|
giuliomoro@523
|
75 pre-built objects, or all the pre-built objects, respectively.
|
giuliomoro@523
|
76 "
|
giuliomoro@523
|
77 }
|