comparison scripts/build_project.sh @ 90:c74006ef86ca

Added foreground run option to build script
author andrewm
date Sun, 19 Jul 2015 16:42:51 +0100
parents 91e1a3a220d4
children f2d47df23c68
comparison
equal deleted inserted replaced
89:d41631e0fe0e 90:c74006ef86ca
6 6
7 BBB_ADDRESS="root@192.168.7.2" 7 BBB_ADDRESS="root@192.168.7.2"
8 BBB_PATH="~/BeagleRT" 8 BBB_PATH="~/BeagleRT"
9 RUN_PROJECT=1 9 RUN_PROJECT=1
10 COMMAND_ARGS= 10 COMMAND_ARGS=
11 RUN_IN_FOREGROUND=0
12 RUN_WITHOUT_SCREEN=0
11 13
12 function usage 14 function usage
13 { 15 {
14 THIS_SCRIPT=`basename "$0"` 16 THIS_SCRIPT=`basename "$0"`
15 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-n] <directory-with-source-files>" 17 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-nfF] <directory-with-source-files>"
16 echo " 18 echo "
17 This script copies a directory of source files to the BeagleBone, compiles 19 This script copies a directory of source files to the BeagleBone, compiles
18 and runs it. The BeagleRT core files should have first been copied over 20 and runs it. The BeagleRT core files should have first been copied over
19 using the setup_board.sh script supplied with BeagleRT. 21 using the setup_board.sh script supplied with BeagleRT.
20 22
21 The source directory should contain at least one .c, .cpp or .S file. 23 The source directory should contain at least one .c, .cpp or .S file.
22 If the argument -n is passed, the output will not be run after compiling. 24 If the argument -n is passed, the output will not be run after compiling.
23 The argument -b will change the local path on the BeagleBone where the 25 The argument -b will change the local path on the BeagleBone where the
24 BeagleRT files are found. The -c option passes command-line arguments to 26 BeagleRT files are found. The -c option passes command-line arguments to
25 the BeagleRT program; enclose the argument string in quotes." 27 the BeagleRT program; enclose the argument string in quotes.
28
29 The -f argument runs the project in the foreground of the current terminal,
30 within a screen session that can be detached later. The -F argument runs
31 the project in the foreground of the current terminal, without screen, so
32 the output can be piped to another destination."
26 } 33 }
27 34
28 OPTIND=1 35 OPTIND=1
29 36
30 while getopts "b:c:nh" opt; do 37 while getopts "b:c:nfFh" opt; do
31 case $opt in 38 case $opt in
32 b) BBB_PATH=$OPTARG 39 b) BBB_PATH=$OPTARG
33 ;; 40 ;;
34 c) COMMAND_ARGS=$OPTARG 41 c) COMMAND_ARGS=$OPTARG
35 ;; 42 ;;
43 f) RUN_IN_FOREGROUND=1
44 ;;
45 F) RUN_WITHOUT_SCREEN=1
46 ;;
36 n) RUN_PROJECT=0 47 n) RUN_PROJECT=0
37 ;; 48 ;;
38 h|\?) usage 49 h|\?) usage
39 exit 1 50 exit 1
40 esac 51 esac
98 then 109 then
99 echo "Building project..." 110 echo "Building project..."
100 ssh $BBB_ADDRESS "make all -C $BBB_PATH" 111 ssh $BBB_ADDRESS "make all -C $BBB_PATH"
101 else 112 else
102 echo "Building and running project..." 113 echo "Building and running project..."
103 ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS" 114
115 if [ $RUN_WITHOUT_SCREEN -ne 0 ]
116 then
117 ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && $BBB_PATH/BeagleRT $COMMAND_ARGS"
118 elif [ $RUN_IN_FOREGROUND -eq 0 ]
119 then
120 ssh $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT -d -m $BBB_PATH/BeagleRT $COMMAND_ARGS"
121 else
122 ssh -t $BBB_ADDRESS "make all -C $BBB_PATH && screen -S BeagleRT $BBB_PATH/BeagleRT $COMMAND_ARGS"
123 fi
104 fi 124 fi