diff scripts/build_pd_heavy.sh @ 403:83e1acf38d35 prerelease

Updated build_pd_heavy to support the release flag
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 15 Jun 2016 02:37:34 +0100
parents 8a7c35ee8b3f
children 99de323c13b3
line wrap: on
line diff
--- a/scripts/build_pd_heavy.sh	Wed Jun 15 02:21:13 2016 +0100
+++ b/scripts/build_pd_heavy.sh	Wed Jun 15 02:37:34 2016 +0100
@@ -17,7 +17,7 @@
 #make sure the paths have the trailing / . 
 projectpath="../projects/heavy/hvtemp/"
 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
-[ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/"
+[ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
 BBB_DEFAULT_PROJECT_NAME="heavyProject"
 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
@@ -39,7 +39,7 @@
 
 if [ -z "$BELA_PYTHON27" ]; then
     echo "It looks like you might not have python2.7 installed. If you do, please specify the path
-    to your python2.7 executable in the environmental variable $BELA_PYTHON27"
+    to your python2.7 executable in the environmental variable \$BELA_PYTHON27"
     exit 1;
 fi;
 
@@ -48,13 +48,15 @@
 {
 printf "\nUSAGE: build_pd.sh [[-i input folder containing _main.pd file ]\
  [-o output folder for new heavy project .c files (default ../projects/heavy/hvtemp)]\
- [-b bbb path to copy to (default ~/BeagleRT)] | [-h] | [-f|--force] | [-w|--watch] | [-n|--noupload] \n"
+ [-b bbb path to copy to (default ~/Bela)] | [-h] | [-w|--watch] | [-n|--noupload] | [-r|--release arg]\n"
 printf "\nexample: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world\n"
 echo "If --watch is selected, the script will check every 1s for any file that is modified in the source folder, which triggers\
 the building process and runs the process.
-If --screen is selected, the prompt returns to the user after launching BeagleRT in a screen on the target device.
+If --screen is selected, the prompt returns to the user after launching Bela in a screen on the target device.
 If --screen and --watch are combined, while the process is running in the screen, modifications to the source files will \
-still trigger a new build."
+still trigger a new build.
+-r allows to build against a specific Heavy release. Default is the most recent version.
+"
 }
 
 while [ "$1" != "" ]; do
@@ -62,14 +64,15 @@
         -b | --bbb )            shift
                                 BBB_BELA_HOME=$1
                                 ;;
-        -f | --force)           FORCE="1"
-                                ;;
         -i | --input )          shift
                                 pdpath=$1
                                 ;;
         -o | --output )         shift
                                 projectpath=$1
                                 ;;
+        -r | --release )        shift
+                                release=$1
+                                ;;
         -v | --verbose )        verbose=1
                                 ;;
         -r | --render )         shift
@@ -90,49 +93,21 @@
     shift
 done
 
-function hasNotChanged(){
-    if [ $WATCH -eq 0 ];
-    then
-        echo "Files in the source folder did not change since the last build, use --force to force recompiling";
-        exit 0;
-    fi;
-}
+if [ -z $release ]
+then 
+  RELEASE_STRING=
+else 
+  RELEASE_STRING="-r $release"
+fi
 
-function checkChanged(){
-    PD_BACKUP_PATH="hvresources/patch_back/"
-    if [ $FORCE -eq 1 ] && [ $WATCH -eq 0 ];
-    then
-        rm -rf $PD_BACKUP_PATH;
-        return;
-    fi;
-    mkdir -p $PD_BACKUP_PATH;
-    # count files that have changed
-    HAS_CHANGED=$(rsync -nac --out-format="%f" "$pdpath" $PD_BACKUP_PATH | grep -v "\/\.$"| wc -l);
-    if [ $HAS_CHANGED -eq 0 ] && [ $FORCE -eq 0 ];
-    then
-        hasNotChanged;
-        return 1;
-    fi;
-     #if we are here and $FORCE==1, it means that $WATCH==1
-     # so let's make sure only the first run get forced:
-    FORCE=0;
-    echo "Files have changed"
-    # otherwise back up the files that have changed
-    rsync -vac "$pdpath" $PD_BACKUP_PATH
-
-    return 0;
-}
-
-function checkUploadBuildRun(){
-    checkChanged || return # exits if source files have not changed
-
+function uploadBuildRun(){
     if [ $NO_UPLOAD -eq 0 ]; then
         # remove old static files to avoid obsolete errors
         # use -rf to prevent warnings in case they do not exist
         rm -rf "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null
 
         # invoke the online compiler
-        "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath";
+        "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath" $RELEASE_STRING;
         if [ $? -ne 0 ]; then
         #echo "ERROR: an error occurred while executing the uploader.py script"
         echo "error"
@@ -162,9 +137,7 @@
 
     echo "updating files on board..."
 
-    echo rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER";
     rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER";
-    # rsync -c -rv "$projectpath"/ "$BBB_ADDRESS":"$BBB_BELA_HOME"/source;
     if [ $NO_UPLOAD -eq 0 ]; then
         # for whatever reason these big files used to hang when transferring with rsync
         scp "$projectpath"/HvContext* $BBB_NETWORK_TARGET_FOLDER
@@ -186,8 +159,8 @@
     if [ $NO_UPLOAD -eq 0 ]; then
         ssh $BBB_ADDRESS "rm -rf "$BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME;
     fi;
-    SCREEN_NAME=BeagleRT
-    # Make new BeagleRT execut/able and run
+    SCREEN_NAME=Bela
+    # Make new Bela execut/able and run
     # It does not look very nice that we type the same things over and over
     # but that is because each line is an ssh session in its own right
     MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'"
@@ -209,9 +182,9 @@
             ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreen"
         fi
     fi
-} #checkUploadBuildRun
+} #uploadBuildRun
 
-checkUploadBuildRun
+uploadBuildRun
 
 if [ $WATCH -ne 0 ]; then
     WAIT_STRING="\rWaiting for changes in $pdpath"
@@ -224,7 +197,7 @@
         sleep 0.3
         printf "$WAIT_STRING..."
         sleep 0.3
-        checkUploadBuildRun
+        uploadBuildRun
     done;
 fi;
 #ssh -t root@192.168.7.2 "kill -s 2 \`pidof heavy_template\` 2>/dev/null; sleep 0.5; rm -f ~/$filename_bbb/Release/source/heavy/HvContext_bbb.? ~/$filename_bbb/Release/heavy_template && make all -C ~/$filename_bbb/Release" &>/dev/null