chris@160: #!/bin/bash chris@160: chris@160: # shell script for automatic uploading/compiling of pd patch onto bbb chris@160: # Christian Heinrichs 2015 chris@160: # chris@160: # example usage: sh upload-and-compile.sh -f bwg-tests -q -e chris@160: chris@160: workingdir=".." chris@160: verbose="0" chris@160: render="0" chris@160: pdpath="" chris@160: projectpath="../projects/heavy/hvtemp" chris@160: BBB_PATH="~/BeagleRT" chris@160: BBB_ADDRESS="root@192.168.7.2" chris@160: COMMAND_ARGS= chris@160: RUN_PROJECT=1 chris@160: RUN_IN_FOREGROUND=0 chris@160: RUN_WITHOUT_SCREEN=1 chris@160: chris@160: function usage chris@160: { chris@160: echo " chris@160: 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: " chris@160: echo "example: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world" chris@160: } chris@160: chris@160: while [ "$1" != "" ]; do chris@160: case $1 in chris@160: -b | --bbb ) shift chris@160: BBB_PATH=$1 chris@160: ;; chris@160: -i | --input ) shift chris@160: pdpath=$1 chris@160: ;; chris@160: -o | --output ) shift chris@160: projectpath=$1 chris@160: ;; chris@160: -v | --verbose ) shift chris@160: verbose=1 chris@160: ;; chris@160: -r | --render ) shift chris@160: render=1 chris@160: ;; chris@160: -h | --help ) usage chris@160: exit chris@160: ;; chris@160: * ) usage chris@160: exit 1 chris@160: esac chris@160: shift chris@160: done chris@160: chris@160: /usr/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/; chris@160: if [ $? -ne 0 ]; then chris@160: /usr/local/bin/python hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"/; chris@160: if [ $? -ne 0 ]; then chris@160: #echo "ERROR: an error occurred while executing the uploader.py script" chris@160: echo "error" chris@160: exit 1 chris@160: fi; chris@160: fi; chris@160: echo ""; chris@160: #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*"; chris@160: echo ""; chris@160: chris@160: # check how to copy/sync render.cpp file... chris@160: if [ $render -eq 0 ]; then chris@160: cp "hvresources/render.cpp" $projectpath/; chris@160: fi; chris@160: chris@160: rsync -c -r "$projectpath"/ "$BBB_ADDRESS":"$BBB_PATH"/source; chris@160: chris@160: if [ $? -ne 0 ]; then chris@160: echo ""; chris@160: echo ":( :( :( ERROR: while synchronizing files with the BBB. Is the board connected and the correct SD card inserted? :( :( :("; chris@160: echo ""; chris@160: exit 1; chris@160: fi; chris@160: chris@160: # Make new BeagleRT executable and run chris@160: if [ $RUN_PROJECT -eq 0 ] chris@160: then chris@160: echo "Building project..." chris@160: ssh $BBB_ADDRESS "make all -C $BBB_PATH" chris@160: else chris@160: echo "Building and running project..." chris@160: chris@160: if [ $RUN_WITHOUT_SCREEN -ne 0 ] chris@160: then chris@160: ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $BBB_PATH/BeagleRT $COMMAND_ARGS" chris@160: elif [ $RUN_IN_FOREGROUND -eq 0 ] chris@160: then chris@160: ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" chris@160: else chris@160: ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS" chris@160: fi chris@160: fi chris@160: chris@160: chris@160: chris@160: chris@160: chris@160: chris@160: chris@160: chris@160: #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