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