annotate scripts/build_pd.sh @ 162:c3e8226a5651 heavy-updated

- added additional flags to C rules (-DNDEBUG, -mfpu=neon) - sample-accurate envelope triggering pd/heavy example
author chnrx <chris.heinrichs@gmail.com>
date Thu, 12 Nov 2015 14:59:46 +0000
parents 07735c9d95c8
children 40badaff5729
rev   line source
chris@160 1 #!/bin/bash
chris@160 2
chris@160 3 # shell script for automatic uploading/compiling of pd patch onto bbb
chris@160 4 # Christian Heinrichs 2015
chris@160 5 #
chris@160 6 # example usage: sh upload-and-compile.sh -f bwg-tests -q -e
chris@160 7
chris@160 8 workingdir=".."
chris@160 9 verbose="0"
chris@160 10 render="0"
chris@160 11 pdpath=""
chris@160 12 projectpath="../projects/heavy/hvtemp"
chris@160 13 BBB_PATH="~/BeagleRT"
chris@160 14 BBB_ADDRESS="root@192.168.7.2"
chris@160 15 COMMAND_ARGS=
chris@160 16 RUN_PROJECT=1
chris@160 17 RUN_IN_FOREGROUND=0
chris@160 18 RUN_WITHOUT_SCREEN=1
chris@160 19
chris@160 20 function usage
chris@160 21 {
chris@160 22 echo "
chris@162 23 USAGE: 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]]
chris@160 24 "
chris@160 25 echo "example: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world"
chris@160 26 }
chris@160 27
chris@160 28 while [ "$1" != "" ]; do
chris@160 29 case $1 in
chris@160 30 -b | --bbb ) shift
chris@160 31 BBB_PATH=$1
chris@160 32 ;;
chris@160 33 -i | --input ) shift
chris@160 34 pdpath=$1
chris@160 35 ;;
chris@160 36 -o | --output ) shift
chris@160 37 projectpath=$1
chris@160 38 ;;
chris@160 39 -v | --verbose ) shift
chris@160 40 verbose=1
chris@160 41 ;;
chris@160 42 -r | --render ) shift
chris@160 43 render=1
chris@160 44 ;;
chris@160 45 -h | --help ) usage
chris@160 46 exit
chris@160 47 ;;
chris@160 48 * ) usage
chris@160 49 exit 1
chris@160 50 esac
chris@160 51 shift
chris@160 52 done
chris@160 53
chris@160 54 /usr/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/;
chris@160 55 if [ $? -ne 0 ]; then
chris@160 56 /usr/local/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/;
chris@160 57 if [ $? -ne 0 ]; then
chris@160 58 #echo "ERROR: an error occurred while executing the uploader.py script"
chris@160 59 echo "error"
chris@160 60 exit 1
chris@160 61 fi;
chris@160 62 fi;
chris@160 63 echo "";
chris@160 64 #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*";
chris@160 65 echo "";
chris@160 66
chris@160 67 # check how to copy/sync render.cpp file...
chris@160 68 if [ $render -eq 0 ]; then
chris@160 69 cp "hvresources/render.cpp" $projectpath/;
chris@160 70 fi;
chris@160 71
chris@160 72 rsync -c -r "$projectpath"/ "$BBB_ADDRESS":"$BBB_PATH"/source;
chris@160 73
chris@160 74 if [ $? -ne 0 ]; then
chris@160 75 echo "";
chris@160 76 echo ":( :( :( ERROR: while synchronizing files with the BBB. Is the board connected and the correct SD card inserted? :( :( :(";
chris@160 77 echo "";
chris@160 78 exit 1;
chris@160 79 fi;
chris@160 80
chris@162 81 # remove old executable and heavy context .o/.d files
chris@162 82 ssh $BBB_ADDRESS "rm $BBB_PATH/BeagleRT $BBB_PATH/build/source/HvContext_bbb.d $BBB_PATH/build/source/HvContext_bbb.o";
chris@162 83
chris@160 84 # Make new BeagleRT executable and run
chris@160 85 if [ $RUN_PROJECT -eq 0 ]
chris@160 86 then
chris@160 87 echo "Building project..."
chris@160 88 ssh $BBB_ADDRESS "make all -C $BBB_PATH"
chris@160 89 else
chris@160 90 echo "Building and running project..."
chris@160 91
chris@160 92 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
chris@160 93 then
chris@160 94 ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $BBB_PATH/BeagleRT $COMMAND_ARGS"
chris@160 95 elif [ $RUN_IN_FOREGROUND -eq 0 ]
chris@160 96 then
chris@160 97 ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
chris@160 98 else
chris@160 99 ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS"
chris@160 100 fi
chris@160 101 fi
chris@160 102
chris@160 103
chris@160 104
chris@160 105
chris@160 106
chris@160 107
chris@160 108
chris@160 109
chris@160 110 #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