Mercurial > hg > beaglert
comparison scripts/build_pd_heavy.sh @ 398:8a7c35ee8b3f prerelease
Adding noupload and preserve render functionalities to build_pd_heavy.sh
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 14 Jun 2016 18:52:10 +0100 |
parents | a430a16d2c02 |
children | 83e1acf38d35 |
comparison
equal
deleted
inserted
replaced
397:5848f5c8bc39 | 398:8a7c35ee8b3f |
---|---|
9 | 9 |
10 workingdir=".." | 10 workingdir=".." |
11 verbose="0" | 11 verbose="0" |
12 render="0" | 12 render="0" |
13 pdpath="" | 13 pdpath="" |
14 NO_UPLOAD="0" | |
14 WATCH="0" | 15 WATCH="0" |
15 FORCE="0" | 16 FORCE="0" |
16 #make sure the paths have the trailing / . | 17 #make sure the paths have the trailing / . |
17 projectpath="../projects/heavy/hvtemp/" | 18 projectpath="../projects/heavy/hvtemp/" |
18 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" | 19 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" |
19 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/" | 20 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/" |
20 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/" | 21 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/" |
21 BBB_DEFAULT_PROJECT_NAME="heavyProject" | 22 BBB_DEFAULT_PROJECT_NAME="heavyProject" |
22 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME | 23 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME |
23 COMMAND_ARGS= | 24 COMMAND_ARGS= |
24 RUN_PROJECT=1 | 25 RUN_PROJECT=1 |
45 | 46 |
46 function usage | 47 function usage |
47 { | 48 { |
48 printf "\nUSAGE: build_pd.sh [[-i input folder containing _main.pd file ]\ | 49 printf "\nUSAGE: build_pd.sh [[-i input folder containing _main.pd file ]\ |
49 [-o output folder for new heavy project .c files (default ../projects/heavy/hvtemp)]\ | 50 [-o output folder for new heavy project .c files (default ../projects/heavy/hvtemp)]\ |
50 [-b bbb path to copy to (default ~/Bela)] | [-h] | [-f|--force] | [-w|--watch]\n" | 51 [-b bbb path to copy to (default ~/BeagleRT)] | [-h] | [-f|--force] | [-w|--watch] | [-n|--noupload] \n" |
51 printf "\nexample: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world\n" | 52 printf "\nexample: build_pd.sh -i ../projects/heavy/pd/hello-world -o ../projects/heavy/hello-world\n" |
52 echo "If --watch is selected, the script will check every 1s for any file that is modified in the source folder, which triggers\ | 53 echo "If --watch is selected, the script will check every 1s for any file that is modified in the source folder, which triggers\ |
53 the building process and runs the process. | 54 the building process and runs the process. |
54 If --screen is selected, the prompt returns to the user after launching Bela in a screen on the target device. | 55 If --screen is selected, the prompt returns to the user after launching BeagleRT in a screen on the target device. |
55 If --screen and --watch are combined, while the process is running in the screen, modifications to the source files will \ | 56 If --screen and --watch are combined, while the process is running in the screen, modifications to the source files will \ |
56 still trigger a new build." | 57 still trigger a new build." |
57 } | 58 } |
58 | 59 |
59 while [ "$1" != "" ]; do | 60 while [ "$1" != "" ]; do |
75 render=1 | 76 render=1 |
76 ;; | 77 ;; |
77 -s | --screen ) RUN_WITHOUT_SCREEN="0" | 78 -s | --screen ) RUN_WITHOUT_SCREEN="0" |
78 ;; | 79 ;; |
79 -w | --watch ) WATCH=1 | 80 -w | --watch ) WATCH=1 |
81 ;; | |
82 -n | --noupload ) NO_UPLOAD=1 | |
80 ;; | 83 ;; |
81 -h | --help ) usage | 84 -h | --help ) usage |
82 exit | 85 exit |
83 ;; | 86 ;; |
84 * ) usage | 87 * ) usage |
121 } | 124 } |
122 | 125 |
123 function checkUploadBuildRun(){ | 126 function checkUploadBuildRun(){ |
124 checkChanged || return # exits if source files have not changed | 127 checkChanged || return # exits if source files have not changed |
125 | 128 |
126 # remove old static files to avoid obsolete errors | 129 if [ $NO_UPLOAD -eq 0 ]; then |
127 # use -rf to prevent warnings in case they do not exist | 130 # remove old static files to avoid obsolete errors |
128 rm -rf "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null | 131 # use -rf to prevent warnings in case they do not exist |
129 | 132 rm -rf "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null |
130 # invoke the online compiler | 133 |
131 "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"; | 134 # invoke the online compiler |
132 if [ $? -ne 0 ]; then | 135 "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"; |
133 #echo "ERROR: an error occurred while executing the uploader.py script" | 136 if [ $? -ne 0 ]; then |
134 echo "error" | 137 #echo "ERROR: an error occurred while executing the uploader.py script" |
135 exit 1 | 138 echo "error" |
139 exit 1 | |
140 fi; | |
136 fi; | 141 fi; |
137 | 142 |
138 echo ""; | 143 echo ""; |
139 #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*"; | 144 #echo "*|*|* Successfully uploaded and converted pd patch into super-fast optimized C code. Brought to you by Heavy! *|*|*"; |
140 echo ""; | 145 echo ""; |
141 | |
142 # check how to copy/sync render.cpp file... | |
143 if [ $render -eq 0 ]; then | |
144 cp "hvresources/render.cpp" $projectpath/; | |
145 fi; | |
146 | |
147 cp "hvresources/HvUtils.h" $projectpath/; | |
148 | |
149 echo "updating files on board..." | |
150 | 146 |
151 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here | 147 BBB_PROJECT_FOLDER=$BBB_PROJECT_HOME"/"$BBB_PROJECT_NAME #make sure there is no trailing slash here |
152 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER | 148 BBB_NETWORK_TARGET_FOLDER=$BBB_ADDRESS:$BBB_PROJECT_FOLDER |
153 rsync -avc --no-t --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER"; | 149 |
154 | 150 # check how to copy/sync render.cpp file... |
155 # for whatever reason these big files used to hang when transferring with rsync | 151 # don't replace render.cpp file if custom one provided in output folder |
156 scp "$projectpath"/HvContext* $BBB_NETWORK_TARGET_FOLDER | 152 if [ -f $projectpath"/render.cpp" ]; then |
153 echo "Found custom render.cpp file in output folder"; | |
154 ssh -t $BBB_ADDRESS "rm ${BBB_PROJECT_FOLDER}/build/render.*" | |
155 else | |
156 if [ $render -eq 0 ]; then | |
157 cp "hvresources/render.cpp" $projectpath/; | |
158 fi; | |
159 fi; | |
160 | |
161 cp "hvresources/HvUtils.h" $projectpath/; | |
162 | |
163 echo "updating files on board..." | |
164 | |
165 echo rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER"; | |
166 rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER"; | |
167 # rsync -c -rv "$projectpath"/ "$BBB_ADDRESS":"$BBB_BELA_HOME"/source; | |
168 if [ $NO_UPLOAD -eq 0 ]; then | |
169 # for whatever reason these big files used to hang when transferring with rsync | |
170 scp "$projectpath"/HvContext* $BBB_NETWORK_TARGET_FOLDER | |
171 fi; | |
157 | 172 |
158 if [ $? -ne 0 ]; then | 173 if [ $? -ne 0 ]; then |
159 echo ""; | 174 echo ""; |
160 echo ":( :( :( ERROR: while synchronizing files with the BBB. Is the board connected and the correct SD card inserted? :( :( :("; | 175 echo ":( :( :( ERROR: while synchronizing files with the BBB. Is the board connected and the correct SD card inserted? :( :( :("; |
161 echo ""; | 176 echo ""; |
165 #produce a list of files which content has changed (not just the date) | 180 #produce a list of files which content has changed (not just the date) |
166 #TODO: could be made faster (perhaps) by backing up the folder locally instead of bbb | 181 #TODO: could be made faster (perhaps) by backing up the folder locally instead of bbb |
167 # UPDATED_FILES=`rsync -naic --log-format="%f" "$projectpath" "$BBB_BELA_HOME"/source | grep -v "\.$"` | 182 # UPDATED_FILES=`rsync -naic --log-format="%f" "$projectpath" "$BBB_BELA_HOME"/source | grep -v "\.$"` |
168 # echo "UPDATEDFILES : $UPDATED_FILES" | 183 # echo "UPDATEDFILES : $UPDATED_FILES" |
169 # exit 2 | 184 # exit 2 |
170 # sets the date, remove old executable and heavy context .o/.d files | 185 # remove old executable and heavy context .o/.d files |
171 ssh $BBB_ADDRESS "date -s '`date`' > /dev/null; rm -rf "$BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME; | 186 if [ $NO_UPLOAD -eq 0 ]; then |
172 SCREEN_NAME=Bela | 187 ssh $BBB_ADDRESS "rm -rf "$BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME; |
173 # Make new Bela execut/able and run | 188 fi; |
189 SCREEN_NAME=BeagleRT | |
190 # Make new BeagleRT execut/able and run | |
174 # It does not look very nice that we type the same things over and over | 191 # It does not look very nice that we type the same things over and over |
175 # but that is because each line is an ssh session in its own right | 192 # but that is because each line is an ssh session in its own right |
176 MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'" | 193 MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'" |
177 if [ $RUN_PROJECT -eq 0 ] | 194 if [ $RUN_PROJECT -eq 0 ] |
178 then | 195 then |