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@238
|
7 BBB_ADDRESS="root@192.168.7.2"
|
giuliomoro@377
|
8 BBB_LIBPD_EXECUTABLE_PATH="~/libpd/Bela"
|
giuliomoro@238
|
9 BBB_LIBPD_PROJECT_PATH="~/libpd/source/"
|
giuliomoro@238
|
10 RUN_PROJECT=1
|
giuliomoro@238
|
11 COMMAND_ARGS=
|
giuliomoro@238
|
12 RUN_IN_FOREGROUND=0
|
giuliomoro@238
|
13 RUN_WITHOUT_SCREEN=0
|
giuliomoro@238
|
14
|
giuliomoro@430
|
15 usage()
|
giuliomoro@238
|
16 {
|
giuliomoro@439
|
17 THIS_SCRIPT=`basename "$0"`
|
giuliomoro@439
|
18 echo "Usage: $THIS_SCRIPT [-c 'command-line-args'] [-nfb] <directory-with-source-files>"
|
giuliomoro@439
|
19 echo "
|
giuliomoro@439
|
20 This script copies a PureData project to the BeagleBone and runs it
|
giuliomoro@439
|
21 using libpd. The Bela-libpd executable should have first been copied
|
giuliomoro@439
|
22 to the $BBB_LIBPD_EXECUTABLE_PATH folder on the Beaglebone.
|
giuliomoro@439
|
23 The source directory should contain a file called _main.pd, which is the
|
giuliomoro@439
|
24 patch that will be loaded into Pd. All the content of the folder is
|
giuliomoro@439
|
25 recursively copied and the folder structure is flattened.
|
giuliomoro@238
|
26
|
giuliomoro@439
|
27 If the argument -n is passed, the output will not be run after copying the files.
|
giuliomoro@439
|
28
|
giuliomoro@439
|
29 The -c option passes command-line arguments to the Bela program;
|
giuliomoro@439
|
30 enclose the argument string in quotes.
|
giuliomoro@439
|
31
|
giuliomoro@439
|
32 The -b argument runs the projet in the background, so that no output is displayed
|
giuliomoro@439
|
33 in the terminal.
|
giuliomoro@439
|
34 The -f argument runs the project in the foreground of the current terminal,
|
giuliomoro@439
|
35 without screen, so the output can be piped to another destination."
|
giuliomoro@238
|
36 }
|
giuliomoro@238
|
37
|
giuliomoro@238
|
38 OPTIND=1
|
giuliomoro@238
|
39
|
giuliomoro@439
|
40 while getopts "bc:nfFh" opt; do
|
giuliomoro@439
|
41 case $opt in
|
giuliomoro@439
|
42 c)
|
giuliomoro@439
|
43 COMMAND_ARGS=$OPTARG
|
giuliomoro@439
|
44 ;;
|
giuliomoro@439
|
45 b)
|
giuliomoro@439
|
46 RUN_IN_FOREGROUND=0
|
giuliomoro@439
|
47 ;;
|
giuliomoro@439
|
48 f)
|
giuliomoro@439
|
49 RUN_WITHOUT_SCREEN=1
|
giuliomoro@439
|
50 ;;
|
giuliomoro@439
|
51 n)
|
giuliomoro@439
|
52 RUN_PROJECT=0
|
giuliomoro@439
|
53 ;;
|
giuliomoro@439
|
54 h|\?)
|
giuliomoro@439
|
55 usage
|
giuliomoro@439
|
56 exit 1
|
giuliomoro@439
|
57 esac
|
giuliomoro@238
|
58 done
|
giuliomoro@238
|
59
|
giuliomoro@238
|
60 shift $((OPTIND-1))
|
giuliomoro@238
|
61
|
giuliomoro@238
|
62 # Check that we have a directory containing at least one source file
|
giuliomoro@238
|
63 # as an argument
|
giuliomoro@238
|
64
|
giuliomoro@439
|
65 ADDITIONAL_FOLDER=$1
|
giuliomoro@439
|
66
|
giuliomoro@439
|
67 if [ -z "$ADDITIONAL_FOLDER" ]
|
giuliomoro@238
|
68 then
|
giuliomoro@439
|
69 usage
|
giuliomoro@238
|
70 exit
|
giuliomoro@238
|
71 fi
|
giuliomoro@238
|
72
|
giuliomoro@439
|
73 #reconstruct the command line options
|
giuliomoro@439
|
74 OPT=
|
giuliomoro@439
|
75 [ $RUN_IN_FOREGROUND -eq 0 ] && OPT="$OPT -b"
|
giuliomoro@439
|
76 [ $RUN_WITHOUT_SCREEN -eq 1 ] && OPT="$OPT -f"
|
giuliomoro@439
|
77
|
giuliomoro@439
|
78 ./build_project.sh -p libpd -r $ADDITIONAL_FOLDER $OPT -c "$COMMAND_ARGS" ../examples/basic_libpd/
|