annotate scripts/build_project.sh @ 68:59edd5780fef

Changed d-box code to run cleanly when built on board. Updated Makefile to add ne10 include path on board. Some extra docs in Utilities.h
author andrewm
date Fri, 17 Jul 2015 16:57:08 +0100
parents b89dd0c97a04
children 91e1a3a220d4
rev   line source
andrewm@58 1 #!/bin/bash
andrewm@58 2 #
andrewm@58 3 # This script compiles a BeagleRT project on the BeagleBone Black and
andrewm@58 4 # optionally runs it. Pass a directory path in the first argument.
andrewm@58 5 # The source files in this directory are copied to the board and compiled.
andrewm@58 6
andrewm@58 7 BBB_ADDRESS="root@192.168.7.2"
andrewm@58 8 BBB_PATH="~/BeagleRT"
andrewm@58 9 RUN_PROJECT=1
andrewm@60 10 COMMAND_ARGS=
andrewm@58 11
andrewm@58 12 function usage
andrewm@58 13 {
andrewm@58 14 THIS_SCRIPT=`basename "$0"`
andrewm@60 15 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] <directory-with-source-files>"
andrewm@58 16 echo "
andrewm@58 17 This script copies a directory of source files to the BeagleBone, compiles
andrewm@58 18 and runs it. The BeagleRT core files should have first been copied over
andrewm@58 19 using the setup_board.sh script supplied with BeagleRT.
andrewm@58 20
andrewm@58 21 The source directory should contain at least one .c, .cpp or .S file.
andrewm@58 22 If the argument -n is passed, the output will not be run after compiling.
andrewm@58 23 The argument -b will change the local path on the BeagleBone where the
andrewm@60 24 BeagleRT files are found. The -c option passes command-line arguments to
andrewm@60 25 the BeagleRT program; enclose the argument string in quotes."
andrewm@58 26 }
andrewm@58 27
andrewm@58 28 OPTIND=1
andrewm@58 29
andrewm@60 30 while getopts "b:c:nh" opt; do
andrewm@58 31 case $opt in
andrewm@58 32 b) BBB_PATH=$OPTARG
andrewm@58 33 ;;
andrewm@60 34 c) COMMAND_ARGS=$OPTARG
andrewm@60 35 ;;
andrewm@58 36 n) RUN_PROJECT=0
andrewm@58 37 ;;
andrewm@58 38 h|\?) usage
andrewm@58 39 exit 1
andrewm@58 40 esac
andrewm@58 41 done
andrewm@58 42
andrewm@58 43 shift $((OPTIND-1))
andrewm@58 44
andrewm@58 45 # Check that we have a directory containing at least one source file
andrewm@58 46 # as an argument
giuliomoro@64 47
andrewm@58 48 if [ -z "$1" ]
andrewm@58 49 then
andrewm@58 50 usage
andrewm@58 51 exit
andrewm@58 52 fi
andrewm@58 53
giuliomoro@64 54 FIND_STRING="find $* -maxdepth 10000 -type f "
giuliomoro@64 55
giuliomoro@64 56 C_FILES=$($FIND_STRING -name "*.c")
giuliomoro@64 57 CPP_FILES=$($FIND_STRING -name "*.cpp")
giuliomoro@64 58 ASM_FILES=$($FIND_STRING -name "*.S")
andrewm@58 59
andrewm@58 60 if [[ -z $C_FILES ]] && [[ -z $CPP_FILES ]] && [[ -z $ASM_FILES ]]
andrewm@58 61 then
andrewm@58 62 echo "Please provide a directory containing .c, .cpp or .S files."
andrewm@58 63 # echo "Usage: $THIS_SCRIPT [directory-with-source-files]"
andrewm@58 64 usage
andrewm@58 65 exit
andrewm@58 66 fi
andrewm@58 67
andrewm@58 68 # Stop BeagleRT and clean out old source files
andrewm@58 69 echo "Stopping BeagleRT and removing old source files..."
giuliomoro@64 70 ssh -t -t $BBB_ADDRESS "screen -X -S BeagleRT quit ; pkill BeagleRT ; make sourceclean -C $BBB_PATH"
giuliomoro@64 71
giuliomoro@64 72 #concatenate arguments to form path.
giuliomoro@64 73 BBB_SOURCE_PATH= #initially empty, will be filled with input arguments
giuliomoro@64 74 for i in "$@" #parse input arguments
giuliomoro@64 75 do
giuliomoro@64 76 if [ -d "$1" ] #check if the path is a folder
giuliomoro@64 77 then #if it is, include all of its files
giuliomoro@64 78 BBB_SOURCE_PATH+=" ${1}/* "
giuliomoro@64 79 else
giuliomoro@64 80 BBB_SOURCE_PATH+=" $1 "
giuliomoro@64 81 fi
giuliomoro@64 82 shift
giuliomoro@64 83 # Copy new souce files to the board
giuliomoro@64 84 done
andrewm@58 85
andrewm@58 86 # Copy new source files to the board
andrewm@58 87 echo "Copying new source files to BeagleBone..."
giuliomoro@64 88 scp $BBB_SOURCE_PATH "$BBB_ADDRESS:$BBB_PATH/source/"
giuliomoro@64 89
giuliomoro@64 90 if [ $? -ne 0 ]
giuliomoro@64 91 then
giuliomoro@64 92 echo "Error while copying files"
giuliomoro@64 93 exit
giuliomoro@64 94 fi
andrewm@58 95
andrewm@58 96 # Make new BeagleRT executable and run
andrewm@58 97 if [ $RUN_PROJECT -eq 0 ]
andrewm@58 98 then
andrewm@58 99 echo "Building project..."
andrewm@58 100 ssh $BBB_ADDRESS "make all -C $BBB_PATH"
andrewm@58 101 else
andrewm@58 102 echo "Building and running project..."
giuliomoro@64 103 ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
andrewm@58 104 fi