comparison scripts/build_pd_heavy.sh @ 403:83e1acf38d35 prerelease

Updated build_pd_heavy to support the release flag
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 15 Jun 2016 02:37:34 +0100
parents 8a7c35ee8b3f
children 99de323c13b3
comparison
equal deleted inserted replaced
402:c29f07b7350e 403:83e1acf38d35
15 WATCH="0" 15 WATCH="0"
16 FORCE="0" 16 FORCE="0"
17 #make sure the paths have the trailing / . 17 #make sure the paths have the trailing / .
18 projectpath="../projects/heavy/hvtemp/" 18 projectpath="../projects/heavy/hvtemp/"
19 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" 19 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
20 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/BeagleRT/" 20 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
21 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/" 21 [ -z "$BBB_PROJECT_HOME" ] && BBB_PROJECT_HOME="${BBB_BELA_HOME}/projects/"
22 BBB_DEFAULT_PROJECT_NAME="heavyProject" 22 BBB_DEFAULT_PROJECT_NAME="heavyProject"
23 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME 23 [ -z "$BBB_PROJECT_NAME" ] && BBB_PROJECT_NAME=$BBB_DEFAULT_PROJECT_NAME
24 COMMAND_ARGS= 24 COMMAND_ARGS=
25 RUN_PROJECT=1 25 RUN_PROJECT=1
37 done; 37 done;
38 fi; 38 fi;
39 39
40 if [ -z "$BELA_PYTHON27" ]; then 40 if [ -z "$BELA_PYTHON27" ]; then
41 echo "It looks like you might not have python2.7 installed. If you do, please specify the path 41 echo "It looks like you might not have python2.7 installed. If you do, please specify the path
42 to your python2.7 executable in the environmental variable $BELA_PYTHON27" 42 to your python2.7 executable in the environmental variable \$BELA_PYTHON27"
43 exit 1; 43 exit 1;
44 fi; 44 fi;
45 45
46 46
47 function usage 47 function usage
48 { 48 {
49 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 ]\
50 [-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)]\
51 [-b bbb path to copy to (default ~/BeagleRT)] | [-h] | [-f|--force] | [-w|--watch] | [-n|--noupload] \n" 51 [-b bbb path to copy to (default ~/Bela)] | [-h] | [-w|--watch] | [-n|--noupload] | [-r|--release arg]\n"
52 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"
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 echo "If --watch is selected, the script will check every 1s for any file that is modified in the source folder, which triggers\
54 the building process and runs the process. 54 the building process and runs the process.
55 If --screen is selected, the prompt returns to the user after launching BeagleRT in a screen on the target device. 55 If --screen is selected, the prompt returns to the user after launching Bela in a screen on the target device.
56 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 \
57 still trigger a new build." 57 still trigger a new build.
58 -r allows to build against a specific Heavy release. Default is the most recent version.
59 "
58 } 60 }
59 61
60 while [ "$1" != "" ]; do 62 while [ "$1" != "" ]; do
61 case $1 in 63 case $1 in
62 -b | --bbb ) shift 64 -b | --bbb ) shift
63 BBB_BELA_HOME=$1 65 BBB_BELA_HOME=$1
64 ;; 66 ;;
65 -f | --force) FORCE="1"
66 ;;
67 -i | --input ) shift 67 -i | --input ) shift
68 pdpath=$1 68 pdpath=$1
69 ;; 69 ;;
70 -o | --output ) shift 70 -o | --output ) shift
71 projectpath=$1 71 projectpath=$1
72 ;;
73 -r | --release ) shift
74 release=$1
72 ;; 75 ;;
73 -v | --verbose ) verbose=1 76 -v | --verbose ) verbose=1
74 ;; 77 ;;
75 -r | --render ) shift 78 -r | --render ) shift
76 render=1 79 render=1
88 exit 1 91 exit 1
89 esac 92 esac
90 shift 93 shift
91 done 94 done
92 95
93 function hasNotChanged(){ 96 if [ -z $release ]
94 if [ $WATCH -eq 0 ]; 97 then
95 then 98 RELEASE_STRING=
96 echo "Files in the source folder did not change since the last build, use --force to force recompiling"; 99 else
97 exit 0; 100 RELEASE_STRING="-r $release"
98 fi; 101 fi
99 } 102
100 103 function uploadBuildRun(){
101 function checkChanged(){
102 PD_BACKUP_PATH="hvresources/patch_back/"
103 if [ $FORCE -eq 1 ] && [ $WATCH -eq 0 ];
104 then
105 rm -rf $PD_BACKUP_PATH;
106 return;
107 fi;
108 mkdir -p $PD_BACKUP_PATH;
109 # count files that have changed
110 HAS_CHANGED=$(rsync -nac --out-format="%f" "$pdpath" $PD_BACKUP_PATH | grep -v "\/\.$"| wc -l);
111 if [ $HAS_CHANGED -eq 0 ] && [ $FORCE -eq 0 ];
112 then
113 hasNotChanged;
114 return 1;
115 fi;
116 #if we are here and $FORCE==1, it means that $WATCH==1
117 # so let's make sure only the first run get forced:
118 FORCE=0;
119 echo "Files have changed"
120 # otherwise back up the files that have changed
121 rsync -vac "$pdpath" $PD_BACKUP_PATH
122
123 return 0;
124 }
125
126 function checkUploadBuildRun(){
127 checkChanged || return # exits if source files have not changed
128
129 if [ $NO_UPLOAD -eq 0 ]; then 104 if [ $NO_UPLOAD -eq 0 ]; then
130 # remove old static files to avoid obsolete errors 105 # remove old static files to avoid obsolete errors
131 # use -rf to prevent warnings in case they do not exist 106 # use -rf to prevent warnings in case they do not exist
132 rm -rf "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null 107 rm -rf "$projectpath"/Hv* "$projectpath"/Message* "$projectpath"/Control* "$projectpath"/Signal* &>/dev/null
133 108
134 # invoke the online compiler 109 # invoke the online compiler
135 "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath"; 110 "$BELA_PYTHON27" hvresources/uploader.py "$pdpath"/ -n bbb -g c -o "$projectpath" $RELEASE_STRING;
136 if [ $? -ne 0 ]; then 111 if [ $? -ne 0 ]; then
137 #echo "ERROR: an error occurred while executing the uploader.py script" 112 #echo "ERROR: an error occurred while executing the uploader.py script"
138 echo "error" 113 echo "error"
139 exit 1 114 exit 1
140 fi; 115 fi;
160 135
161 cp "hvresources/HvUtils.h" $projectpath/; 136 cp "hvresources/HvUtils.h" $projectpath/;
162 137
163 echo "updating files on board..." 138 echo "updating files on board..."
164 139
165 echo rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER";
166 rsync -c -rv --exclude 'HvContext*' "$projectpath"/ "$BBB_NETWORK_TARGET_FOLDER"; 140 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 141 if [ $NO_UPLOAD -eq 0 ]; then
169 # for whatever reason these big files used to hang when transferring with rsync 142 # for whatever reason these big files used to hang when transferring with rsync
170 scp "$projectpath"/HvContext* $BBB_NETWORK_TARGET_FOLDER 143 scp "$projectpath"/HvContext* $BBB_NETWORK_TARGET_FOLDER
171 fi; 144 fi;
172 145
184 # exit 2 157 # exit 2
185 # remove old executable and heavy context .o/.d files 158 # remove old executable and heavy context .o/.d files
186 if [ $NO_UPLOAD -eq 0 ]; then 159 if [ $NO_UPLOAD -eq 0 ]; then
187 ssh $BBB_ADDRESS "rm -rf "$BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME; 160 ssh $BBB_ADDRESS "rm -rf "$BBB_PROJECT_FOLDER/$BBB_PROJECT_NAME;
188 fi; 161 fi;
189 SCREEN_NAME=BeagleRT 162 SCREEN_NAME=Bela
190 # Make new BeagleRT execut/able and run 163 # Make new Bela execut/able and run
191 # It does not look very nice that we type the same things over and over 164 # It does not look very nice that we type the same things over and over
192 # but that is because each line is an ssh session in its own right 165 # but that is because each line is an ssh session in its own right
193 MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'" 166 MAKE_COMMAND="make stop -C $BBB_BELA_HOME PROJECT='$BBB_PROJECT_NAME' CL='$COMMAND_ARGS'"
194 if [ $RUN_PROJECT -eq 0 ] 167 if [ $RUN_PROJECT -eq 0 ]
195 then 168 then
207 else 180 else
208 # Run in screen and detach 181 # Run in screen and detach
209 ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreen" 182 ssh -t $BBB_ADDRESS "$MAKE_COMMAND runscreen"
210 fi 183 fi
211 fi 184 fi
212 } #checkUploadBuildRun 185 } #uploadBuildRun
213 186
214 checkUploadBuildRun 187 uploadBuildRun
215 188
216 if [ $WATCH -ne 0 ]; then 189 if [ $WATCH -ne 0 ]; then
217 WAIT_STRING="\rWaiting for changes in $pdpath" 190 WAIT_STRING="\rWaiting for changes in $pdpath"
218 while true; do 191 while true; do
219 printf "$WAIT_STRING " 192 printf "$WAIT_STRING "
222 sleep 0.3 195 sleep 0.3
223 printf "$WAIT_STRING.. " 196 printf "$WAIT_STRING.. "
224 sleep 0.3 197 sleep 0.3
225 printf "$WAIT_STRING..." 198 printf "$WAIT_STRING..."
226 sleep 0.3 199 sleep 0.3
227 checkUploadBuildRun 200 uploadBuildRun
228 done; 201 done;
229 fi; 202 fi;
230 #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 203 #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