Mercurial > hg > beaglert
comparison scripts/build_project.sh @ 369:75689b7cd57b prerelease
Updated rsync command and command-line options
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 09 Jun 2016 02:48:58 +0100 |
parents | 276a8517da13 |
children | 137a87b745d2 |
comparison
equal
deleted
inserted
replaced
368:4fe4aa2cdfa2 | 369:75689b7cd57b |
---|---|
17 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME | 17 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME |
18 | 18 |
19 function usage | 19 function usage |
20 { | 20 { |
21 THIS_SCRIPT=`basename "$0"` | 21 THIS_SCRIPT=`basename "$0"` |
22 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-c command-line-args] [-nfF] <directory-with-source-files>" | 22 echo "Usage: $THIS_SCRIPT [-c command-line-args] [-nbfF] <directory-with-source-files>" |
23 echo " | 23 echo " |
24 This script copies a directory of source files to the BeagleBone, compiles | 24 This script copies a directory of source files to the BeagleBone, compiles |
25 and runs it. The BeagleRT core files should have first been copied over | 25 and runs it. The BeagleRT core files should have first been copied over |
26 using the setup_board.sh script supplied with BeagleRT. | 26 using the setup_board.sh script supplied with BeagleRT. |
27 | 27 |
28 The source directory should contain at least one .c, .cpp or .S file. | 28 The source directory should contain at least one .c, .cpp or .S file. |
29 If the argument -n is passed, the output will not be run after compiling. | 29 If the argument -n is passed, the output will not be run after compiling. |
30 The argument -b will change the local path on the BeagleBone where the | 30 The -c option passes command-line arguments to |
31 BeagleRT files are found. The -c option passes command-line arguments to | |
32 the BeagleRT program; enclose the argument string in quotes. | 31 the BeagleRT program; enclose the argument string in quotes. |
33 | 32 |
34 By default, the project runs in the foreground of the current terminal, | 33 By default, the project runs in the foreground of the current terminal, |
35 within a screen session that can be detached later. The -F argument runs | 34 within a screen session that can be detached later. The -f argument runs |
36 the project in the foreground of the current terminal, without screen, so | 35 the project in the foreground of the current terminal, without screen, so |
37 the output can be piped to another destination. The -f argument runs it | 36 the output can be piped to another destination. The -b argument runs it |
38 in a screen in the background, so no output is shown." | 37 in a screen in the background, so no output is shown." |
39 } | 38 } |
40 | 39 |
41 OPTIND=1 | 40 OPTIND=1 |
42 | 41 |
43 while getopts "b:c:nfFhp:" opt; do | 42 while getopts "bc:nfFhp:" opt; do |
44 case $opt in | 43 case $opt in |
45 b) BBB_BELA_HOME=$OPTARG | |
46 ;; | |
47 c) COMMAND_ARGS=$OPTARG | 44 c) COMMAND_ARGS=$OPTARG |
48 ;; | 45 ;; |
49 f) RUN_IN_FOREGROUND=0 | 46 b) RUN_IN_FOREGROUND=0 |
50 ;; | 47 ;; |
51 F) RUN_WITHOUT_SCREEN=1 | 48 f) RUN_WITHOUT_SCREEN=1 |
52 ;; | 49 ;; |
53 n) RUN_PROJECT=0 | 50 n) RUN_PROJECT=0 |
54 ;; | 51 ;; |
55 p) BBB_PROJECT_NAME=$OPTARG | 52 p) BBB_PROJECT_NAME=$OPTARG |
56 ;; | 53 ;; |
85 fi | 82 fi |
86 | 83 |
87 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here | 84 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here |
88 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER | 85 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER |
89 | 86 |
90 # Stop BeagleRT and clean out old source files | 87 echo "Stopping running process..." |
91 echo "Stopping running program..." | 88 # sets the date and stop running process |
92 # sets the date, stops the running process | 89 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; make -C $BBB_BELA_HOME stop" |
93 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; mkdir -p $BBB_PROJECT_FOLDER; screen -X -S '"$BBB_SCREEN_NAME"' quit &>/dev/null;" | |
94 | 90 |
95 #concatenate arguments to form path. | 91 #concatenate arguments to form path. |
96 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments | 92 HOST_SOURCE_PATH= #initially empty, will be filled with input arguments |
97 for i in "$@" #parse input arguments | 93 for i in "$@" #parse input arguments |
98 do | 94 do |
108 #if rsync is not available, brutally clean the destination folder | 104 #if rsync is not available, brutally clean the destination folder |
109 #and copy over all the files again and recompile them | 105 #and copy over all the files again and recompile them |
110 ssh bbb "make -C $BBB_BELA_HOME sourceclean PROJECT=$BBB_PROJECT_NAME"; | 106 ssh bbb "make -C $BBB_BELA_HOME sourceclean PROJECT=$BBB_PROJECT_NAME"; |
111 scp $HOST_SOURCE_PATH "$BBB_NETWORK_TARGET_FOLDER" | 107 scp $HOST_SOURCE_PATH "$BBB_NETWORK_TARGET_FOLDER" |
112 else | 108 else |
113 #rsync --delete makes sure it removes files that are not in the origin folder | 109 #rsync |
114 rsync -ogprv --delete-after --exclude=build $HOST_SOURCE_PATH"/" "$BBB_NETWORK_TARGET_FOLDER/" #trailing slashes used here make sure rsync does not create another folder inside the target folder | 110 # --delete makes sure it removes files that are not in the origin folder |
111 # -c evaluates changes using md5 checksum instead of file date, so we don't care about time skews | |
112 # --no-t makes sure file timestamps are not preserved, so that the Makefile will not think that targets are up to date when replacing files on the BBB | |
113 # with older files from the host. This will solve 99% of the issues with Makefile thinking a target is up to date when it is not. | |
114 rsync -avc --no-t --delete-after --exclude=build $HOST_SOURCE_PATH"/" "$BBB_NETWORK_TARGET_FOLDER/" #trailing slashes used here make sure rsync does not create another folder inside the target folder | |
115 fi; | 115 fi; |
116 | 116 |
117 if [ $? -ne 0 ] | 117 if [ $? -ne 0 ] |
118 then | 118 then |
119 echo "Error while copying files" | 119 echo "Error while copying files" |
129 else | 129 else |
130 echo "Building and running project..." | 130 echo "Building and running project..." |
131 | 131 |
132 if [ $RUN_WITHOUT_SCREEN -ne 0 ] | 132 if [ $RUN_WITHOUT_SCREEN -ne 0 ] |
133 then | 133 then |
134 echo ssh -t $BBB_ADDRESS "$MAKE_COMMAND run" | |
135 ssh -t $BBB_ADDRESS "$MAKE_COMMAND run" | 134 ssh -t $BBB_ADDRESS "$MAKE_COMMAND run" |
136 elif [ $RUN_IN_FOREGROUND -eq 0 ] | 135 elif [ $RUN_IN_FOREGROUND -eq 0 ] |
137 then | 136 then |
138 echo ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen" | |
139 ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen" | 137 ssh $BBB_ADDRESS "$MAKE_COMMAND runscreen" |
140 else | 138 else |
141 echo ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreenfg" | |
142 ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreenfg" | 139 ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreenfg" |
143 fi | 140 fi |
144 fi | 141 fi |