Mercurial > hg > beaglert
annotate scripts/run_pd_libpd.sh @ 468:85cf9c0da052 prerelease
merge
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 20 Jun 2016 17:08:02 +0100 |
parents | d9a4fc5357e7 |
children |
rev | line source |
---|---|
giuliomoro@425 | 1 #!/bin/sh |
giuliomoro@238 | 2 # |
giuliomoro@377 | 3 # This script compiles a Bela project on the BeagleBone Black and |
giuliomoro@238 | 4 # optionally runs it. Pass a directory path in the first argument. |
giuliomoro@238 | 5 # The source files in this directory are copied to the board and compiled. |
giuliomoro@238 | 6 |
giuliomoro@462 | 7 SCRIPTDIR=$(dirname "$0") |
giuliomoro@462 | 8 [ -z $SCRIPTDIR ] && SCRIPTDIR="./" || SCRIPTDIR=$SCRIPTDIR/ |
giuliomoro@462 | 9 . $SCRIPTDIR.bela_common || { echo "You must be in Bela/scripts to run these scripts" | exit 1; } |
giuliomoro@462 | 10 |
giuliomoro@238 | 11 RUN_PROJECT=1 |
giuliomoro@238 | 12 COMMAND_ARGS= |
giuliomoro@238 | 13 RUN_IN_FOREGROUND=0 |
giuliomoro@238 | 14 RUN_WITHOUT_SCREEN=0 |
giuliomoro@238 | 15 |
giuliomoro@430 | 16 usage() |
giuliomoro@238 | 17 { |
giuliomoro@439 | 18 THIS_SCRIPT=`basename "$0"` |
giuliomoro@439 | 19 echo "Usage: $THIS_SCRIPT [-c 'command-line-args'] [-nfb] <directory-with-source-files>" |
giuliomoro@439 | 20 echo " |
giuliomoro@439 | 21 This script copies a PureData project to the BeagleBone and runs it |
giuliomoro@439 | 22 using libpd. The Bela-libpd executable should have first been copied |
giuliomoro@439 | 23 to the $BBB_LIBPD_EXECUTABLE_PATH folder on the Beaglebone. |
giuliomoro@439 | 24 The source directory should contain a file called _main.pd, which is the |
giuliomoro@439 | 25 patch that will be loaded into Pd. All the content of the folder is |
giuliomoro@439 | 26 recursively copied and the folder structure is flattened. |
giuliomoro@238 | 27 |
giuliomoro@439 | 28 If the argument -n is passed, the output will not be run after copying the files. |
giuliomoro@439 | 29 |
giuliomoro@439 | 30 The -c option passes command-line arguments to the Bela program; |
giuliomoro@439 | 31 enclose the argument string in quotes. |
giuliomoro@439 | 32 |
giuliomoro@439 | 33 The -b argument runs the projet in the background, so that no output is displayed |
giuliomoro@439 | 34 in the terminal. |
giuliomoro@439 | 35 The -f argument runs the project in the foreground of the current terminal, |
giuliomoro@439 | 36 without screen, so the output can be piped to another destination." |
giuliomoro@238 | 37 } |
giuliomoro@238 | 38 |
giuliomoro@238 | 39 OPTIND=1 |
giuliomoro@238 | 40 |
giuliomoro@439 | 41 while getopts "bc:nfFh" opt; do |
giuliomoro@439 | 42 case $opt in |
giuliomoro@439 | 43 c) |
giuliomoro@439 | 44 COMMAND_ARGS=$OPTARG |
giuliomoro@439 | 45 ;; |
giuliomoro@439 | 46 b) |
giuliomoro@439 | 47 RUN_IN_FOREGROUND=0 |
giuliomoro@439 | 48 ;; |
giuliomoro@439 | 49 f) |
giuliomoro@439 | 50 RUN_WITHOUT_SCREEN=1 |
giuliomoro@439 | 51 ;; |
giuliomoro@439 | 52 n) |
giuliomoro@439 | 53 RUN_PROJECT=0 |
giuliomoro@439 | 54 ;; |
giuliomoro@439 | 55 h|\?) |
giuliomoro@439 | 56 usage |
giuliomoro@439 | 57 exit 1 |
giuliomoro@439 | 58 esac |
giuliomoro@238 | 59 done |
giuliomoro@238 | 60 |
giuliomoro@238 | 61 shift $((OPTIND-1)) |
giuliomoro@238 | 62 |
giuliomoro@238 | 63 # Check that we have a directory containing at least one source file |
giuliomoro@238 | 64 # as an argument |
giuliomoro@238 | 65 |
giuliomoro@439 | 66 ADDITIONAL_FOLDER=$1 |
giuliomoro@439 | 67 |
giuliomoro@439 | 68 if [ -z "$ADDITIONAL_FOLDER" ] |
giuliomoro@238 | 69 then |
giuliomoro@439 | 70 usage |
giuliomoro@238 | 71 exit |
giuliomoro@238 | 72 fi |
giuliomoro@238 | 73 |
giuliomoro@439 | 74 #reconstruct the command line options |
giuliomoro@439 | 75 OPT= |
giuliomoro@439 | 76 [ $RUN_IN_FOREGROUND -eq 0 ] && OPT="$OPT -b" |
giuliomoro@439 | 77 [ $RUN_WITHOUT_SCREEN -eq 1 ] && OPT="$OPT -f" |
giuliomoro@439 | 78 |
giuliomoro@439 | 79 ./build_project.sh -p libpd -r $ADDITIONAL_FOLDER $OPT -c "$COMMAND_ARGS" ../examples/basic_libpd/ |