diff scripts/build_project.sh @ 64:b89dd0c97a04 newapi

added Makefile, added default_main, added error checking in scripts
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 15 Jul 2015 19:59:29 +0100
parents 3ada83df91a5
children 91e1a3a220d4
line wrap: on
line diff
--- a/scripts/build_project.sh	Wed Jul 15 19:46:51 2015 +0100
+++ b/scripts/build_project.sh	Wed Jul 15 19:59:29 2015 +0100
@@ -44,15 +44,18 @@
 
 # Check that we have a directory containing at least one source file
 # as an argument
+
 if [ -z "$1" ]
 then
     usage
     exit
 fi
 
-C_FILES=$(find "$1" -maxdepth 1 -type f -name "*.c")
-CPP_FILES=$(find "$1" -maxdepth 1 -type f -name "*.cpp")
-ASM_FILES=$(find "$1" -maxdepth 1 -type f -name "*.S")
+FIND_STRING="find $* -maxdepth 10000 -type f "
+
+C_FILES=$($FIND_STRING -name "*.c")
+CPP_FILES=$($FIND_STRING -name "*.cpp")
+ASM_FILES=$($FIND_STRING -name "*.S")
 
 if [[ -z $C_FILES ]] && [[ -z $CPP_FILES ]] && [[ -z $ASM_FILES ]]
 then
@@ -64,11 +67,31 @@
 
 # Stop BeagleRT and clean out old source files
 echo "Stopping BeagleRT and removing old source files..."
-ssh -t -t $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; sleep 0.5; make sourceclean -C $BBB_PATH"
+ssh -t -t $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; make sourceclean -C $BBB_PATH"
+
+#concatenate arguments to form path.
+BBB_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
+  shift
+  # Copy new souce files to the board
+done
 
 # Copy new source files to the board
 echo "Copying new source files to BeagleBone..."
-scp "$1"/* "$BBB_ADDRESS:$BBB_PATH/source/"
+scp $BBB_SOURCE_PATH "$BBB_ADDRESS:$BBB_PATH/source/"
+
+if [ $? -ne 0 ]
+then
+	echo "Error while copying files"
+	exit
+fi
 
 # Make new BeagleRT executable and run
 if [ $RUN_PROJECT -eq 0 ]
@@ -77,5 +100,5 @@
     ssh $BBB_ADDRESS "make all -C $BBB_PATH"
 else
     echo "Building and running project..."
-    ssh $BBB_ADDRESS "make all -C $BBB_PATH ; screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
+    ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
 fi
\ No newline at end of file