changeset 264:60ccd1fe5a58 prerelease

Using rsync instead of scp. scp remains as as fallback
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 16 May 2016 15:56:42 +0100
parents 7fe0d7c54bce
children 4989afa8e994
files scripts/build_project.sh
diffstat 1 files changed, 22 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/build_project.sh	Mon May 16 15:13:20 2016 +0100
+++ b/scripts/build_project.sh	Mon May 16 15:56:42 2016 +0100
@@ -6,12 +6,14 @@
 
 # set defaults unless variables are already set
 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
-[ -z "$BBB_PATH" ] && BBB_PATH="~/BeagleRT"
+[ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
 [ -z "$RUN_PROJECT" ] && RUN_PROJECT=1
 [ -z "$COMMAND_ARGS" ] && COMMAND_ARGS=
 [ -z "$RUN_IN_FOREGROUND" ] && RUN_IN_FOREGROUND=1
 [ -z "$RUN_WITHOUT_SCREEN" ] && RUN_WITHOUT_SCREEN=0
 [ -z "$SCREEN_NAME" ] && SCREEN_NAME=Bela
+[ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
+[ -x "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME="scriptUploadedProject"
 
 function usage
 {
@@ -39,13 +41,13 @@
 
 while getopts "b:c:nfFh" opt; do
     case $opt in
-        b)            BBB_PATH=$OPTARG
+        b)            BBB_BELA_HOME=$OPTARG
                       ;;
         c)            COMMAND_ARGS=$OPTARG
                       ;;
-		f)            RUN_IN_FOREGROUND=0
+        f)            RUN_IN_FOREGROUND=0
 			          ;;
-		F)            RUN_WITHOUT_SCREEN=1
+        F)            RUN_WITHOUT_SCREEN=1
 			  		  ;;
         n)    	      RUN_PROJECT=0
                       ;;
@@ -85,22 +87,26 @@
 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; screen -X -S '"$SCREEN_NAME"' quit &>/dev/null;"
 
 #concatenate arguments to form path.
-BBB_SOURCE_PATH= #initially empty, will be filled with input arguments
+HOST_SOURCE_PATH= #initially empty, will be filled with input arguments
 for i in "$@" #parse input arguments
 do
-  if [ -d "$1" ] #check if the path is a folder
-  then #if it is, include all of its files
-    BBB_SOURCE_PATH+=" ${1}/* "
-  else
-    BBB_SOURCE_PATH+=" $1 "
-  fi
+  HOST_SOURCE_PATH+=" $1 "
   shift
   # Copy new souce files to the board
 done
 
 # Copy new source files to the board
 echo "Copying new source files to BeagleBone..."
-scp $BBB_SOURCE_PATH "$BBB_ADDRESS:$BBB_PATH/source/"
+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 -C $BBB_BELA_HOME sourceclean";
+    scp $HOST_SOURCE_PATH "$BBB_ADDRESS:$BBB_BELA_HOME/source/"
+else
+    #rsync --delete makes sure it removes files that are not in the origin folder
+    rsync -av --delete-after $HOST_SOURCE_PATH "$BBB_ADDRESS:$BBB_BELA_HOME/source/"
+fi;
 
 if [ $? -ne 0 ]
 then
@@ -112,17 +118,17 @@
 if [ $RUN_PROJECT -eq 0 ]
 then
     echo "Building project..."
-    ssh $BBB_ADDRESS "make all -C $BBB_PATH"
+    ssh $BBB_ADDRESS "make all -C $BBB_BELA_HOME"
 else
     echo "Building and running project..."
 	
 	if [ $RUN_WITHOUT_SCREEN -ne 0 ]
 	then
-		ssh -t $BBB_ADDRESS "cd $BBB_PATH && make all && cd source && ../BeagleRT $COMMAND_ARGS"	
+		ssh -t $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && ../BeagleRT $COMMAND_ARGS"	
 	elif [ $RUN_IN_FOREGROUND -eq 0 ]
 	then
-	    ssh $BBB_ADDRESS "cd $BBB_PATH && make all && cd source && screen -S $SCREEN_NAME -d -m ../BeagleRT $COMMAND_ARGS"
+	    ssh $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && screen -S $SCREEN_NAME -d -m ../BeagleRT $COMMAND_ARGS"
 	else
-	    ssh -t $BBB_ADDRESS "cd $BBB_PATH && make all && cd source && screen -S $SCREEN_NAME ../BeagleRT $COMMAND_ARGS"
+	    ssh -t $BBB_ADDRESS "cd $BBB_BELA_HOME && make all && cd source && screen -S $SCREEN_NAME ../BeagleRT $COMMAND_ARGS"
 	fi
 fi