# HG changeset patch # User Giulio Moro # Date 1465926730 -3600 # Node ID 8a7c35ee8b3feac08c01d622394060af1d04f057 # Parent 5848f5c8bc398df0abfa1847d86f8fbcbde7366a Adding noupload and preserve render functionalities to build_pd_heavy.sh diff -r 5848f5c8bc39 -r 8a7c35ee8b3f scripts/build_pd_heavy.sh --- a/scripts/build_pd_heavy.sh Tue Jun 14 18:24:25 2016 +0100 +++ b/scripts/build_pd_heavy.sh Tue Jun 14 18:52:10 2016 +0100 @@ -11,12 +11,13 @@ verbose="0" render="0" pdpath="" +NO_UPLOAD="0" WATCH="0" FORCE="0" #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="~/Bela/" +[ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/" [ -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 @@ -47,11 +48,11 @@ { 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 ~/Bela)] | [-h] | [-f|--force] | [-w|--watch]\n" + [-b bbb path to copy to (default ~/BeagleRT)] | [-h] | [-f|--force] | [-w|--watch] | [-n|--noupload] \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 Bela in a screen on the target device. +If --screen is selected, the prompt returns to the user after launching BeagleRT 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." } @@ -78,6 +79,8 @@ ;; -w | --watch ) WATCH=1 ;; + -n | --noupload ) NO_UPLOAD=1 + ;; -h | --help ) usage exit ;; @@ -123,37 +126,49 @@ function checkUploadBuildRun(){ checkChanged || return # exits if source files have not changed - # 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 + 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"; - if [ $? -ne 0 ]; then - #echo "ERROR: an error occurred while executing the uploader.py script" - echo "error" - exit 1 + # invoke the online compiler + "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"; + if [ $? -ne 0 ]; then + #echo "ERROR: an error occurred while executing the uploader.py script" + echo "error" + exit 1 + fi; fi; echo ""; #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*"; echo ""; + BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here + BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER + # check how to copy/sync render.cpp file... - if [ $render -eq 0 ]; then - cp "hvresources/render.cpp" $projectpath/; + # don't replace render.cpp file if custom one provided in output folder + if [ -f $projectpath"/render.cpp" ]; then + echo "Found custom render.cpp file in output folder"; + ssh -t $BBB_ADDRESS "rm ${BBB_PROJECT_FOLDER}/build/render.*" + else + if [ $render -eq 0 ]; then + cp "hvresources/render.cpp" $projectpath/; + fi; fi; cp "hvresources/HvUtils.h" $projectpath/; echo "updating files on board..." - BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here - BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER - rsync -avc --no-t --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER"; - - # for whatever reason these big files used to hang when transferring with rsync - scp "$projectpath"/HvContext* $BBB_NETWORK_TARGET_FOLDER + 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 + fi; if [ $? -ne 0 ]; then echo ""; @@ -167,10 +182,12 @@ # UPDATED_FILES=`rsync -naic --log-format="%f" "$projectpath" "$BBB_BELA_HOME"/source | grep -v "\.$"` # echo "UPDATEDFILES : $UPDATED_FILES" # exit 2 - # sets the date, remove old executable and heavy context .o/.d files - ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; rm -rf "$BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME; - SCREEN_NAME=Bela - # Make new Bela execut/able and run + # remove old executable and heavy context .o/.d files + 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 # 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'"