annotate scripts/build_pd.sh @ 190:3b8a28edae41

- Updated heavy scripts to work with custom header - Added -mfpu=neon flag to Makefile for custom .C files
author chnrx <chris.heinrichs@gmail.com>
date Wed, 27 Jan 2016 19:13:57 +0000
parents 28d1473742bc
children b5d59cf94c64
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@190 54 # remove old static files to avoid obsolete errors
chris@190 55 rm "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null
chris@190 56
chris@160 57 /usr/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/;
chris@160 58 if [ $? -ne 0 ]; then
chris@160 59 /usr/local/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/;
chris@160 60 if [ $? -ne 0 ]; then
chris@160 61 #echo "ERROR: an error occurred while executing the uploader.py script"
chris@160 62 echo "error"
chris@160 63 exit 1
chris@160 64 fi;
chris@160 65 fi;
chris@160 66 echo "";
chris@160 67 #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*";
chris@160 68 echo "";
chris@160 69
chris@160 70 # check how to copy/sync render.cpp file...
chris@160 71 if [ $render -eq 0 ]; then
chris@190 72 cp "hvresources/render.cpp" $projectpath/;
chris@160 73 fi;
chris@160 74
chris@190 75 cp "hvresources/HvUtils.h" $projectpath/;
chris@190 76
chris@190 77 echo "updating files on board..."
chris@190 78
chris@190 79 rsync -c -r --exclude 'HvContext*' "$projectpath"/ "$BBB_ADDRESS":"$BBB_PATH"/source;
chris@190 80
chris@190 81 scp "$projectpath"/HvContext* "$BBB_ADDRESS":"$BBB_PATH"/source;
chris@160 82
chris@160 83 if [ $? -ne 0 ]; then
chris@160 84 echo "";
chris@160 85 echo ":( :( :( ERROR: while synchronizing files with the BBB. Is the board connected and the correct SD card inserted? :( :( :(";
chris@160 86 echo "";
chris@160 87 exit 1;
chris@160 88 fi;
chris@160 89
chris@162 90 # remove old executable and heavy context .o/.d files
chris@164 91 ssh $BBB_ADDRESS "rm $BBB_PATH/BeagleRT $BBB_PATH/build/source/HvContext_bbb.d $BBB_PATH/build/source/HvContext_bbb.o $BBB_PATH/build/source/render.o $BBB_PATH/build/source/render.d";
chris@162 92
chris@160 93 # Make new BeagleRT executable and run
chris@160 94 if [ $RUN_PROJECT -eq 0 ]
chris@160 95 then
chris@160 96 echo "Building project..."
chris@160 97 ssh $BBB_ADDRESS "make all -C $BBB_PATH"
chris@160 98 else
chris@160 99 echo "Building and running project..."
chris@160 100
chris@160 101 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
chris@160 102 then
chris@160 103 ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $BBB_PATH/BeagleRT $COMMAND_ARGS"
chris@160 104 elif [ $RUN_IN_FOREGROUND -eq 0 ]
chris@160 105 then
chris@160 106 ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
chris@160 107 else
chris@160 108 ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS"
chris@160 109 fi
chris@160 110 fi
chris@160 111
chris@160 112
chris@160 113
chris@160 114
chris@160 115
chris@160 116
chris@160 117
chris@160 118
chris@160 119 #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