giuliomoro@425: #!/bin/sh andrewm@58: # giuliomoro@377: # This script runs an already-compiled Bela project on the andrewm@58: # BeagleBone Black. andrewm@58: giuliomoro@462: SCRIPTDIR=$(dirname "$0") giuliomoro@462: [ -z $SCRIPTDIR ] && SCRIPTDIR="./" || SCRIPTDIR=$SCRIPTDIR/ giuliomoro@462: . $SCRIPTDIR.bela_common || { echo "You must be in Bela/scripts to run these scripts" | exit 1; } andrewm@58: giuliomoro@430: usage() andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@89: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-fF]" andrewm@58: andrewm@58: echo " giuliomoro@377: This script runs a previously compiled Bela project on the giuliomoro@425: BeagleBone Black. The -c option passes command-line arguments giuliomoro@377: to the Bela program; enclose the argument string in quotes. giuliomoro@425: giuliomoro@425: -p arg : sets the name of the project to run (default: $BBB_PROJECT_NAME ) andrewm@89: giuliomoro@425: By default, the project runs in the foreground of the current terminal, giuliomoro@425: within a screen session that can be detached later. The -f argument runs giuliomoro@425: the project in the foreground of the current terminal, without screen, so giuliomoro@425: the output can be piped to another destination. The -b argument runs it giuliomoro@425: in a screen in the background, so no output is shown. The -m argument allows giuliomoro@425: to pass arguments to the Makefile before the run target. For instance, giuliomoro@425: pass -m \`"projectclean"\` or \`-m "distclean"\` to clean project-specific giuliomoro@425: pre-built objects, or all the pre-built objects, respectively." andrewm@58: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: giuliomoro@425: while getopts "bc:m:nfFhp:" opt; do andrewm@58: case $opt in andrewm@60: c) COMMAND_ARGS=$OPTARG andrewm@60: ;; giuliomoro@425: b) RUN_IN_FOREGROUND=0 andrewm@62: ;; giuliomoro@425: f) RUN_WITHOUT_SCREEN=1 giuliomoro@425: ;; giuliomoro@425: p) BBB_PROJECT_NAME=$OPTARG giuliomoro@425: ;; giuliomoro@425: m) BBB_MAKEFILE_OPTIONS=$OPTARG giuliomoro@425: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: esac andrewm@58: done andrewm@58: giuliomoro@360: shift $((OPTIND-1)) giuliomoro@360: giuliomoro@332: if [ -z "$1" ] giuliomoro@332: then giuliomoro@332: BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME giuliomoro@332: else giuliomoro@332: BBB_PROJECT_NAME=$1 giuliomoro@332: fi giuliomoro@332: giuliomoro@425: MAKE_COMMAND="make --no-print-directory stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'" giuliomoro@332: echo "Running $BBB_PROJECT_NAME..." giuliomoro@425: if [ $RUN_WITHOUT_SCREEN -eq 1 ] andrewm@89: then giuliomoro@425: ssh -t $BBB_ADDRESS "$MAKE_COMMAND run" giuliomoro@425: elif [ $RUN_IN_FOREGROUND -eq 1 ] andrewm@62: then giuliomoro@425: ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreenfg" andrewm@62: else giuliomoro@360: ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen" giuliomoro@332: fi