changeset 439:e49ae69acbe8 prerelease

Rebuilt run_pd_libpd.sh. Minor fixes, adjusted verbosity
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 18 Jun 2016 04:19:17 +0100
parents ad3f61134bb4
children 7a074e238db3
files scripts/build_pd_heavy.sh scripts/build_project.sh scripts/run_pd_libpd.sh scripts/update_board
diffstat 4 files changed, 62 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/build_pd_heavy.sh	Sat Jun 18 02:25:48 2016 +0100
+++ b/scripts/build_pd_heavy.sh	Sat Jun 18 04:19:17 2016 +0100
@@ -93,7 +93,7 @@
     shift
 done
 
-if [ -z $release ]
+if [ -z "$release" ]
 then 
   RELEASE_STRING=
 else 
--- a/scripts/build_project.sh	Sat Jun 18 02:25:48 2016 +0100
+++ b/scripts/build_project.sh	Sat Jun 18 04:19:17 2016 +0100
@@ -31,7 +31,8 @@
     the Bela program; enclose the argument string in quotes.
 	
     -p arg : sets the name of the project to run (default: $BBB_PROJECT_NAME ) 
-
+    -r arg : additional folder which contents will be copied to the destination folder. Use this, e.g.: for audio files or Pd/pyo sources
+    
     By default, the project runs in the foreground of the current terminal,
     within a screen session that can be detached later. The -f argument runs
     the project in the foreground of the current terminal, without screen, so
@@ -44,7 +45,7 @@
 
 OPTIND=1
 
-while getopts "bc:m:nfFhp:" opt; do
+while getopts "bc:m:nfFhp:r:b" opt; do
     case $opt in
         c)            COMMAND_ARGS=$OPTARG
                       ;;
@@ -56,6 +57,8 @@
                       ;;
 	p)            BBB_PROJECT_NAME=$OPTARG
 		      ;;	
+	r)            ADDITIONAL_PATH=$OPTARG
+	              ;;
 	m)            BBB_MAKEFILE_OPTIONS=$OPTARG
 	              ;;
         h|\?)         usage
@@ -65,6 +68,9 @@
 
 shift $((OPTIND-1))
 
+#Only include all the files if the provided path is not empty
+[ -z "$ADDITIONAL_PATH" ] || ADDITIONAL_PATH="$ADDITIONAL_PATH/*"
+
 # Check that we have a directory containing at least one source file
 # as an argument
 
@@ -80,7 +86,7 @@
 CPP_FILES=$($FIND_STRING -name "*.cpp")
 ASM_FILES=$($FIND_STRING -name "*.S")
 
-if [ -z $C_FILES ] && [ -z $CPP_FILES ] && [ -z $ASM_FILES ]
+if [ -z "$C_FILES" ] && [ -z "$CPP_FILES" ] && [ -z "$ASM_FILES" ]
 then
     echo "Please provide a directory containing .c, .cpp or .S files."
 #    echo "Usage: $THIS_SCRIPT [directory-with-source-files]"
@@ -93,7 +99,7 @@
 
 echo "Stopping running process..."
 # sets the date and stop running process
-ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; make --no-print-directory -C $BBB_BELA_HOME stop"
+ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; make QUIET=true --no-print-directory -C $BBB_BELA_HOME stop"
 
 #concatenate arguments to form path.
 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments
@@ -106,20 +112,19 @@
 
 # Copy new source files to the board
 echo "Copying new source files to BeagleBone..."
-if [ -z `which rsync` ];
+if [ -z "`which rsync`" ];
 then
     #if rsync is not available, brutally clean the destination folder
     #and copy over all the files again and recompile them
     ssh bbb "make --no-print-directory -C $BBB_BELA_HOME sourceclean PROJECT=$BBB_PROJECT_NAME";
-    scp $HOST_SOURCE_PATH "$BBB_NETWORK_TARGET_FOLDER"
+    scp -r $HOST_SOURCE_PATH $ADDITIONAL_PATH "$BBB_NETWORK_TARGET_FOLDER"
 else
     #rsync 
     # --delete makes sure it removes files that are not in the origin folder
     # -c evaluates changes using md5 checksum instead of file date, so we don't care about time skews 
     # --no-t makes sure file timestamps are not preserved, so that the Makefile will not think that targets are up to date when replacing files on the BBB
     #  with older files from the host. This will solve 99% of the issues with Makefile thinking a target is up to date when it is not.
-
-    rsync -avc --no-t --delete-after --exclude=$BBB_PROJECT_NAME --exclude=build $HOST_SOURCE_PATH"/" "$BBB_NETWORK_TARGET_FOLDER/" #trailing slashes used here make sure rsync does not create another folder inside the target folder
+    rsync -ac --out-format="   %n" --no-t --delete-after --exclude=$BBB_PROJECT_NAME --exclude=build $HOST_SOURCE_PATH"/" $ADDITIONAL_PATH "$BBB_NETWORK_TARGET_FOLDER/" #trailing slashes used here make sure rsync does not create another folder inside the target folder
 fi;
 
 if [ $? -ne 0 ]
@@ -129,7 +134,7 @@
 fi
 
 # Make new Bela executable and run
-MAKE_COMMAND="make --no-print-directory -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS' $BBB_MAKEFILE_OPTIONS"
+MAKE_COMMAND="make --no-print-directory QUIET=true -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS' $BBB_MAKEFILE_OPTIONS"
 if [ $RUN_PROJECT -eq 0 ]
 then
     echo "Building project..."
--- a/scripts/run_pd_libpd.sh	Sat Jun 18 02:25:48 2016 +0100
+++ b/scripts/run_pd_libpd.sh	Sat Jun 18 04:19:17 2016 +0100
@@ -14,40 +14,47 @@
 
 usage()
 {
-    THIS_SCRIPT=`basename "$0"`
-    echo "Usage: $THIS_SCRIPT [-c command-line-args] [-nfF] <directory-with-source-files>"
-    echo "
-    This script copies a PureData project to the BeagleBone and runs it 
-    using libpd. The Bela-libpd executable should have first been copied
-    to the $BBB_LIBPD_EXECUTABLE_PATH folder on the Beaglebone.
-    The source directory should contain a file called _main.pd, which is the 
-    patch that will be loaded into Pd. All the content of the folder is 
-    recursively copied and the folder structure is flattened.
-    If the argument -n is passed, the output will not be run after compiling.
-    The -c option passes command-line arguments to the Bela program; 
-    enclose the argument string in quotes.
+	THIS_SCRIPT=`basename "$0"`
+	echo "Usage: $THIS_SCRIPT [-c 'command-line-args'] [-nfb] <directory-with-source-files>"
+	echo "
+	This script copies a PureData project to the BeagleBone and runs it 
+	using libpd. The Bela-libpd executable should have first been copied
+	to the $BBB_LIBPD_EXECUTABLE_PATH folder on the Beaglebone.
+	The source directory should contain a file called _main.pd, which is the 
+	patch that will be loaded into Pd. All the content of the folder is 
+	recursively copied and the folder structure is flattened.
 	
-    The -f argument runs the project in the foreground of the current terminal,
-    within a screen session that can be detached later with ctrl-A ctrl-D.
-    The -F argument runs the project in the foreground of the current terminal,
-    without screen, so	the output can be piped to another destination."
+	If the argument -n is passed, the output will not be run after copying the files.
+	
+	The -c option passes command-line arguments to the Bela program; 
+	enclose the argument string in quotes.
+	
+	The -b argument runs the projet in the background, so that no output is displayed
+	in the terminal.
+	The -f argument runs the project in the foreground of the current terminal,
+	without screen, so the output can be piped to another destination."
 }
 
 OPTIND=1
 
-while getopts "b:c:nfFh" opt; do
-    case $opt in
-        c)            COMMAND_ARGS=$OPTARG
-                      ;;
-		f)            RUN_IN_FOREGROUND=1
-			          ;;
-		F)            RUN_WITHOUT_SCREEN=1
-			  		  ;;
-        n)    	      RUN_PROJECT=0
-                      ;;
-        h|\?)         usage
-                      exit 1
-    esac
+while getopts "bc:nfFh" opt; do
+	case $opt in
+	c)
+		COMMAND_ARGS=$OPTARG
+	;;
+	b)
+		RUN_IN_FOREGROUND=0
+	;;
+	f)
+		RUN_WITHOUT_SCREEN=1
+	;;
+	n)
+		RUN_PROJECT=0
+	;;
+	h|\?)
+		usage
+		exit 1
+	esac
 done
 
 shift $((OPTIND-1))
@@ -55,53 +62,17 @@
 # Check that we have a directory containing at least one source file
 # as an argument
 
-if [ -z "$1" ]
+ADDITIONAL_FOLDER=$1
+
+if [ -z "$ADDITIONAL_FOLDER" ]
 then
-    usage
-    exit
-fi
-
-FIND_STRING="find $* -maxdepth 10000 -type f "
-
-PROJECT_FILES=$($FIND_STRING)
-
-if [[ -z $PROJECT_FILES ]]
-then
-    echo "Please provide a directory containing the _main.pd file and additional abstractions"
-    usage
-    exit
-fi
-
-# Stop Bela and clean out old source files
-echo "Stopping Bela and removing old source files..."
-ssh -t -t $BBB_ADDRESS "screen -X -S Bela quit &>/dev/null;\
- pkill Bela ; rm -rf $BBB_LIBPD_PROJECT_PATH/; mkdir -p $BBB_LIBPD_PROJECT_PATH; "
-
-# Copy new source files to the board
-echo "Copying new pd projects to BeagleBone..."
-scp $PROJECT_FILES "$BBB_ADDRESS:$BBB_LIBPD_PROJECT_PATH"
-
-if [ $? -ne 0 ]
-then
-	echo "Error while copying files"
+	usage
 	exit
 fi
 
-# Make new Bela executable and run
-if [ $RUN_PROJECT -eq 0 ]
-then
-    echo "Files copied. Run without \"-n\" to run the project"
-else
-    echo "Running project..."
-	
-	if [ $RUN_WITHOUT_SCREEN -ne 0 ]
-	then
-		ssh -t $BBB_ADDRESS "cd $BBB_LIBPD_PROJECT_PATH && $BBB_LIBPD_EXECUTABLE_PATH $COMMAND_ARGS"
-	elif [ $RUN_IN_FOREGROUND -eq 0 ]
-	then
-	    ssh $BBB_ADDRESS "cd $BBB_LIBPD_PROJECT_PATH && screen -S Bela -d -m \
-         $BBB_LIBPD_EXECUTABLE_PATH $COMMAND_ARGS"
-	else
-	    ssh -t $BBB_ADDRESS "cd $BBB_LIBPD_PROJECT_PATH && screen -S Bela $BBB_LIBPD_EXECUTABLE_PATH $COMMAND_ARGS"
-	fi
-fi
+#reconstruct the command line options 
+OPT=
+[ $RUN_IN_FOREGROUND -eq 0 ] && OPT="$OPT -b"
+[ $RUN_WITHOUT_SCREEN -eq 1 ] && OPT="$OPT -f"
+
+./build_project.sh -p libpd -r $ADDITIONAL_FOLDER $OPT -c "$COMMAND_ARGS" ../examples/basic_libpd/
--- a/scripts/update_board	Sat Jun 18 02:25:48 2016 +0100
+++ b/scripts/update_board	Sat Jun 18 04:19:17 2016 +0100
@@ -98,7 +98,7 @@
     printf "y\n"
   else 
     read REPLY;
-    [ -z $REPLY ] || { [ $REPLY !=  y ]  && [ $REPLY != Y ]; } && { echo "Aborting..."; exit 1; }
+    [ -z "$REPLY" ] || { [ "$REPLY" !=  y ]  && [ "$REPLY" != Y ]; } && { echo "Aborting..."; exit 1; }
   fi
 else
   echo "Installing Bela core code in $BBB_ADDRESS:$BBB_BELA_HOME"