giuliomoro@425
|
1 #!/bin/sh
|
andrewm@58
|
2 #
|
giuliomoro@377
|
3 # This script runs an already-compiled Bela project on the
|
andrewm@58
|
4 # BeagleBone Black.
|
andrewm@58
|
5
|
giuliomoro@332
|
6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
|
giuliomoro@377
|
7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
|
giuliomoro@377
|
8 [ -z "$BBB_SCREEN_NAME" ] && BBB_SCREEN_NAME="Bela"
|
giuliomoro@332
|
9 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
|
giuliomoro@332
|
10 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
|
giuliomoro@332
|
11 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
|
giuliomoro@332
|
12 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
|
giuliomoro@332
|
13 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
|
giuliomoro@332
|
14 [ -z "$BBB_DEFAULT_PROJECT_NAME" ] && BBB_DEFAULT_PROJECT_NAME="scriptUploadedProject"
|
andrewm@58
|
15
|
andrewm@58
|
16 function usage
|
andrewm@58
|
17 {
|
andrewm@58
|
18 THIS_SCRIPT=`basename "$0"`
|
andrewm@89
|
19 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]"
|
andrewm@58
|
20
|
andrewm@58
|
21 echo "
|
giuliomoro@377
|
22 This script runs a previously compiled Bela project on the
|
giuliomoro@425
|
23 BeagleBone Black. The -c option passes command-line arguments
|
giuliomoro@377
|
24 to the Bela program; enclose the argument string in quotes.
|
giuliomoro@425
|
25
|
giuliomoro@425
|
26 -p arg : sets the name of the project to run (default: $BBB_PROJECT_NAME )
|
andrewm@89
|
27
|
giuliomoro@425
|
28 By default, the project runs in the foreground of the current terminal,
|
giuliomoro@425
|
29 within a screen session that can be detached later. The -f argument runs
|
giuliomoro@425
|
30 the project in the foreground of the current terminal, without screen, so
|
giuliomoro@425
|
31 the output can be piped to another destination. The -b argument runs it
|
giuliomoro@425
|
32 in a screen in the background, so no output is shown. The -m argument allows
|
giuliomoro@425
|
33 to pass arguments to the Makefile before the run target. For instance,
|
giuliomoro@425
|
34 pass -m \`"projectclean"\` or \`-m "distclean"\` to clean project-specific
|
giuliomoro@425
|
35 pre-built objects, or all the pre-built objects, respectively."
|
andrewm@58
|
36 }
|
andrewm@58
|
37
|
andrewm@58
|
38 OPTIND=1
|
andrewm@58
|
39
|
giuliomoro@425
|
40 while getopts "bc:m:nfFhp:" opt; do
|
andrewm@58
|
41 case $opt in
|
andrewm@60
|
42 c) COMMAND_ARGS=$OPTARG
|
andrewm@60
|
43 ;;
|
giuliomoro@425
|
44 b) RUN_IN_FOREGROUND=0
|
andrewm@62
|
45 ;;
|
giuliomoro@425
|
46 f) RUN_WITHOUT_SCREEN=1
|
giuliomoro@425
|
47 ;;
|
giuliomoro@425
|
48 p) BBB_PROJECT_NAME=$OPTARG
|
giuliomoro@425
|
49 ;;
|
giuliomoro@425
|
50 m) BBB_MAKEFILE_OPTIONS=$OPTARG
|
giuliomoro@425
|
51 ;;
|
andrewm@58
|
52 h|\?) usage
|
andrewm@58
|
53 exit 1
|
andrewm@58
|
54 esac
|
andrewm@58
|
55 done
|
andrewm@58
|
56
|
giuliomoro@360
|
57 shift $((OPTIND-1))
|
giuliomoro@360
|
58
|
giuliomoro@332
|
59 if [ -z "$1" ]
|
giuliomoro@332
|
60 then
|
giuliomoro@332
|
61 BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
|
giuliomoro@332
|
62 else
|
giuliomoro@332
|
63 BBB_PROJECT_NAME=$1
|
giuliomoro@332
|
64 fi
|
giuliomoro@332
|
65
|
giuliomoro@425
|
66 MAKE_COMMAND="make --no-print-directory stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'"
|
giuliomoro@332
|
67 echo "Running $BBB_PROJECT_NAME..."
|
giuliomoro@425
|
68 if [ $RUN_WITHOUT_SCREEN -eq 1 ]
|
andrewm@89
|
69 then
|
giuliomoro@425
|
70 ssh -t $BBB_ADDRESS "$MAKE_COMMAND run"
|
giuliomoro@425
|
71 elif [ $RUN_IN_FOREGROUND -eq 1 ]
|
andrewm@62
|
72 then
|
giuliomoro@425
|
73 ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreenfg"
|
andrewm@62
|
74 else
|
giuliomoro@360
|
75 ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen"
|
giuliomoro@332
|
76 fi
|