comparison SCRIPTS/process.sh @ 86:413a9d26189e

Handle VamPy plugins
author Chris Cannam
date Tue, 24 Feb 2015 18:00:31 +0000
parents 5936362b8a40
children c678de1d1a92
comparison
equal deleted inserted replaced
85:5936362b8a40 86:413a9d26189e
6 ## the plugin builds! 6 ## the plugin builds!
7 ## plugin loads 7 ## plugin loads
8 ## passes vamp-plugin-tester tests 8 ## passes vamp-plugin-tester tests
9 ## does not export any unnecessary symbols 9 ## does not export any unnecessary symbols
10 ## has valid .cat and .n3 10 ## has valid .cat and .n3
11
12 set -eu
11 13
12 mydir=$(dirname "$0") 14 mydir=$(dirname "$0")
13 case "$mydir" in /*);; *) mydir=$(pwd)/"$mydir";; esac 15 case "$mydir" in /*);; *) mydir=$(pwd)/"$mydir";; esac
14 16
15 . "$mydir"/include.sh 17 . "$mydir"/include.sh
169 notbuilt="/tmp/notbuilt.$$.txt" 171 notbuilt="/tmp/notbuilt.$$.txt"
170 172
171 trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0 173 trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0
172 touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt" 174 touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt"
173 175
176 target_for() {
177 local dir="$1"
178 if grep -q "^$dir: " METADATA/maketarget.txt ; then
179 grep "^$dir: " METADATA/maketarget.txt | head -1 | sed 's/^[^:]*: //'
180 fi
181 }
182
183 plugin_dir_for() {
184 local dir="$1"
185 if grep -q "^$dir: " METADATA/plugindir.txt ; then
186 echo "$dir"/$(grep "^$dir: " METADATA/plugindir.txt | head -1 | sed 's/^[^:]*: //')
187 fi
188 }
189
174 configure() { 190 configure() {
175 dir="$1" 191 local dir="$1"
176 if [ -f "$dir/configure" ] ; then 192 if [ -f "$dir/configure" ] ; then
177 ( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt" 193 ( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt"
178 fi 194 fi
179 } 195 }
180 196
181 find_makefile() { 197 find_makefile() {
182 dir="$1" 198 local dir="$1"
183 for f in \ 199 for f in \
184 build/$platform$bits/Makefile.$platform$bits \ 200 build/$platform$bits/Makefile.$platform$bits \
185 build/$platform/Makefile.$platform$bits \ 201 build/$platform/Makefile.$platform$bits \
186 build/$platform$bits/Makefile.$platform \ 202 build/$platform$bits/Makefile.$platform \
187 build/$platform$bits/Makefile \ 203 build/$platform$bits/Makefile \
203 break 219 break
204 fi 220 fi
205 done 221 done
206 } 222 }
207 223
224 find_vampy_plugins_in() {
225 local dir="$1"
226 local pdir=$(plugin_dir_for "$dir")
227 if [ -z "$pdir" ]; then
228 pdir="$dir"
229 fi
230 find "$pdir" -name \*.py -print0 | xargs -0 grep -l 'import.*\bvampy\b'
231 }
232
233 have_vampy_plugins() {
234 local dir="$1"
235 local plugs=$(find_vampy_plugins_in "$dir")
236 if [ -z "$plugs" ]; then
237 return 1
238 else
239 return 0
240 fi
241 }
242
208 configure_maybe() { 243 configure_maybe() {
209 dir="$1" 244 local dir="$1"
210 if [ t"$do_rebuild" = t"yes" ]; then 245 if [ t"$do_rebuild" = t"yes" ]; then
211 configure "$dir" 246 configure "$dir"
212 else 247 else
213 mfile=$(find_makefile "$dir") 248 mfile=$(find_makefile "$dir")
214 if [ -z "$mfile" ]; then 249 if [ -z "$mfile" ]; then
215 configure "$dir" 250 configure "$dir"
216 fi 251 fi
217 fi 252 fi
218 } 253 }
219 254
220 target_for() {
221 dir="$1"
222 if grep -q "^$dir: " METADATA/maketarget.txt ; then
223 grep "^$dir: " METADATA/maketarget.txt | head -1 | sed 's/^[^:]*: //'
224 fi
225 }
226
227 plugin_dir_for() {
228 dir="$1"
229 if grep -q "^$dir: " METADATA/plugindir.txt ; then
230 echo "$dir"/$(grep "^$dir: " METADATA/plugindir.txt | head -1 | sed 's/^[^:]*: //')
231 fi
232 }
233
234 logfile_for() { 255 logfile_for() {
235 activity="$1" 256 local activity="$1"
236 dir="$2" 257 local dir="$2"
237 echo "$reportdir/$dir.$activity.txt" 258 echo "$reportdir/$dir.$activity.txt"
238 } 259 }
239 260
240 build() { 261 build() {
241 dir="$1" 262 local dir="$1"
242 log=$(logfile_for build "$dir") 263 local log=$(logfile_for build "$dir")
243 if configure_maybe "$dir"; then 264 if configure_maybe "$dir"; then
244 mfile=$(find_makefile "$dir") 265 mfile=$(find_makefile "$dir")
245 if [ -n "$mfile" ]; then 266 if [ -n "$mfile" ]; then
246 target=$(target_for "$dir") 267 target=$(target_for "$dir")
247 TOOLPREFIX="$toolprefix" \ 268 TOOLPREFIX="$toolprefix" \
249 LDFLAGS="-L${deplibdir} -L../vamp-plugin-sdk" \ 270 LDFLAGS="-L${deplibdir} -L../vamp-plugin-sdk" \
250 ARCHFLAGS="$archflags" \ 271 ARCHFLAGS="$archflags" \
251 make -C "$dir" -f "$mfile" $target 2>&1 | \ 272 make -C "$dir" -f "$mfile" $target 2>&1 | \
252 tee "$log" 273 tee "$log"
253 return ${PIPESTATUS[0]} 274 return ${PIPESTATUS[0]}
275 elif have_vampy_plugins "$dir"; then
276 return 0
254 else 277 else
255 echo "Failed to find a Makefile in $dir!" | tee "$log" 278 echo "Failed to find a Makefile in $dir!" | tee "$log"
256 return 1 279 return 1
257 fi 280 fi
258 fi 281 fi
259 } 282 }
260 283
261 rebuild() { 284 rebuild() {
262 dir="$1" 285 local dir="$1"
263 log=$(logfile_for build "$dir") 286 local log=$(logfile_for build "$dir")
264 if configure_maybe "$dir"; then 287 if configure_maybe "$dir"; then
265 mfile=$(find_makefile "$dir") 288 mfile=$(find_makefile "$dir")
266 if [ -n "$mfile" ]; then 289 if [ -n "$mfile" ]; then
267 if make -C "$dir" -f "$mfile" distclean; then 290 if make -C "$dir" -f "$mfile" distclean; then
268 build "$dir" 291 build "$dir"
270 build "$dir" 293 build "$dir"
271 else 294 else
272 echo "Failed to 'make clean' in $dir!" | tee "$log" 295 echo "Failed to 'make clean' in $dir!" | tee "$log"
273 return 1 296 return 1
274 fi 297 fi
298 elif have_vampy_plugins "$dir"; then
299 return 0
275 else 300 else
276 echo "Failed to find a Makefile in $dir!" | tee "$log" 301 echo "Failed to find a Makefile in $dir!" | tee "$log"
277 return 1 302 return 1
278 fi 303 fi
279 fi 304 fi
280 } 305 }
281 306
282 build_or_rebuild() { 307 build_or_rebuild() {
283 dir="$1" 308 local dir="$1"
284 if [ -n "$do_rebuild" ]; then 309 if [ -n "$do_rebuild" ]; then
285 rebuild "$dir" 310 rebuild "$dir"
286 else 311 else
287 build "$dir" 312 build "$dir"
288 fi 313 fi
289 } 314 }
290 315
291 have_plugin() { 316 have_plugin() {
292 dir="$1" 317 local dir="$1"
293 log=$(logfile_for build "$dir") 318 local log=$(logfile_for build "$dir")
294 for x in "$dir/"*"$pluginext"; do 319 for x in "$dir/"*"$pluginext"; do
295 if [ -f "$x" ]; then 320 if [ -f "$x" ]; then
296 if file "$x" | grep -q "$identpattern" ; then 321 if file "$x" | grep -q "$identpattern" ; then
297 return 0 322 return 0
298 else 323 else
299 echo "Plugin $x exists, but fails to match file type for correct platform (file type is: `file $x`, expected pattern is: $identpattern)" | tee "$log" 324 echo "Plugin $x exists, but fails to match file type for correct platform (file type is: `file $x`, expected pattern is: $identpattern)" | tee "$log"
300 return 1 325 return 1
301 fi 326 fi
302 fi 327 fi
303 done 328 done
304 return 1 329 have_vampy_plugins "$dir"
305 } 330 }
306 331
307 is_nondeterministic() { 332 is_nondeterministic() {
308 plugin_id="$1" 333 plugin_id="$1"
309 grep -q "^$id\$" METADATA/nondeterministic.txt 334 grep -q "^$id\$" METADATA/nondeterministic.txt
310 } 335 }
311 336
312 plugin_ids_in() { 337 plugin_ids_in() {
313 dir="$1" 338 local dir="$1"
314 pdir=$(plugin_dir_for "$dir") 339 local pdir=$(plugin_dir_for "$dir")
340 local vampydir=""
341 if have_vampy_plugins "$pdir"; then
342 vampydir="./vampy"
343 fi
315 # can't use sed to remove \r from DOS line endings -- BSD and GNU 344 # can't use sed to remove \r from DOS line endings -- BSD and GNU
316 # vary in how they interpret \r escape -- so we use perl for that... 345 # vary in how they interpret \r escape -- so we use perl for that...
317 VAMP_PATH="$dir:$pdir" $hostwrapper \ 346 VAMP_PATH="$dir:$pdir:$vampydir" $hostwrapper \
318 vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids | \ 347 vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids | \
319 grep '^vamp:' | \ 348 grep '^vamp:' | \
320 sed 's/^vamp://' | \ 349 sed 's/^vamp://' | \
321 perl -p -e 's/\r//g' 350 perl -p -e 's/\r//g'
322 } 351 }
323 352
324 run_tester() { 353 run_tester() {
325 ##!!! todo: timeout if the plugin takes too long and report as failure 354 ##!!! todo: timeout if the plugin takes too long and report as failure
326 dir="$1" 355 local dir="$1"
327 log=$(logfile_for test "$dir") 356 local log=$(logfile_for test "$dir")
328 ids=$(plugin_ids_in "$dir") 357 local ids=$(plugin_ids_in "$dir")
329 pdir=$(plugin_dir_for "$dir") 358 local pdir=$(plugin_dir_for "$dir")
330 cat /dev/null > "$log" 359 cat /dev/null > "$log"
331 if [ -z "$ids" ]; then 360 if [ -z "$ids" ]; then
332 echo 361 echo
333 echo "No plugins reported to test in $dir" | tee -a "$log" 362 echo "No plugins reported to test in $dir" | tee -a "$log"
334 echo "$dir" >> "$testfailed" 363 echo "$dir" >> "$testfailed"
339 extra="" 368 extra=""
340 if is_nondeterministic "$id"; then 369 if is_nondeterministic "$id"; then
341 extra="-n" 370 extra="-n"
342 fi 371 fi
343 echo "Running command: VAMP_PATH=\"$dir:$pdir\" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext \"$extra\" \"$id\"" | tee -a "$log" 372 echo "Running command: VAMP_PATH=\"$dir:$pdir\" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext \"$extra\" \"$id\"" | tee -a "$log"
344 if ( VAMP_PATH="$dir:$pdir" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext "$extra" "$id" 2>&1 | tee -a "$log" ; exit ${PIPESTATUS[0]} ) ; then 373 if ( VAMP_PATH="$dir:$pdir:./vampy" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext "$extra" "$id" 2>&1 | tee -a "$log" ; exit ${PIPESTATUS[0]} ) ; then
345 echo "OK" | tee -a "$log" 374 echo "OK" | tee -a "$log"
346 else 375 else
347 echo | tee -a "$log" 376 if have_vampy_plugins "$pdir"; then # (don't attempt vampy+valgrind)
348 echo "Tester failed for id $id: running again with valgrind (if available) and verbose for a report..." | tee -a "$log" 377 echo | tee -a "$log"
349 VAMP_PATH="$dir:$pdir" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" "$id" 2>&1 | tee -a "$log" 378 echo "Tester failed for id $id (not restarting with valgrind, as this is a VamPy plugin)" | tee -a "$log"
379 else
380 echo | tee -a "$log"
381 echo "Tester failed for id $id: running again with valgrind (if available) and verbose for a report..." | tee -a "$log"
382 VAMP_PATH="$dir:$pdir:./vampy" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" "$id" 2>&1 | tee -a "$log"
383 fi
350 good=no 384 good=no
351 fi 385 fi
352 done 386 done
353 if [ "$good" != "yes" ]; then 387 if [ "$good" != "yes" ]; then
354 echo "$dir" >> "$testfailed" 388 echo "$dir" >> "$testfailed"
367 # grepping out the undefineds: 401 # grepping out the undefineds:
368 "$toolprefix"nm -g "$lib" | grep -v ' U ' | awk '{ print $3; }' 402 "$toolprefix"nm -g "$lib" | grep -v ' U ' | awk '{ print $3; }'
369 } 403 }
370 404
371 env_test_exports() { 405 env_test_exports() {
372 dir="$1" 406 local dir="$1"
373 log=$(logfile_for envtest "$dir") 407 local log=$(logfile_for envtest "$dir")
374 good=yes 408 local good=yes
375 for lib in "$dir"/*"$pluginext"; do 409 for lib in "$dir"/*"$pluginext"; do
376 if [ ! -f "$lib" ]; then 410 if [ ! -f "$lib" ]; then
377 # This should only happen if the glob was not expanded at all 411 # This should only happen if the glob was not expanded at all
378 echo "NOTE: no library found in $dir?" | tee -a "$log" 412 echo "NOTE: no library found in $dir?" | tee -a "$log"
379 good=no 413 good=no
396 done 430 done
397 [ "$good" = "yes" ] 431 [ "$good" = "yes" ]
398 } 432 }
399 433
400 env_test_stdout() { 434 env_test_stdout() {
401 dir="$1" 435 local dir="$1"
402 log=$(logfile_for envtest "$dir") 436 local log=$(logfile_for envtest "$dir")
403 pdir=$(plugin_dir_for "$dir") 437 local pdir=$(plugin_dir_for "$dir")
404 good=yes 438 local good=yes
405 ids=$(VAMP_PATH="$dir:$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids); 439 local ids=$(VAMP_PATH="$dir:$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids);
406 echo 440 echo
407 echo "Testing for any unwanted output to stdout..." 441 echo "Testing for any unwanted output to stdout..."
408 for id in $ids; do 442 for id in $ids; do
409 case "$id" in 443 case "$id" in
410 vamp:*) ;; 444 vamp:*) ;;
416 done 450 done
417 [ "$good" = "yes" ] 451 [ "$good" = "yes" ]
418 } 452 }
419 453
420 env_test_cat() { 454 env_test_cat() {
421 dir="$1" 455 local dir="$1"
422 log=$(logfile_for envtest "$dir") 456 local log=$(logfile_for envtest "$dir")
423 pdir=$(plugin_dir_for "$dir") 457 local pdir=$(plugin_dir_for "$dir")
424 cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi) 458 local cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
425 good=yes 459 local good=yes
426 first=yes 460 local first=yes
427 echo 461 echo
428 echo "Testing some details of .cat files..." 462 echo "Testing some details of .cat files..."
429 for catfile in "$cdir"/*".cat"; do 463 for catfile in "$cdir"/*".cat"; do
430 if [ ! -f "$catfile" ]; then 464 if [ ! -f "$catfile" ]; then
431 # This should only happen if the glob was not expanded at all 465 # This should only happen if the glob was not expanded at all
454 fi 488 fi
455 [ "$good" = "yes" ] 489 [ "$good" = "yes" ]
456 } 490 }
457 491
458 env_test_ttl() { 492 env_test_ttl() {
459 dir="$1" 493 local dir="$1"
460 log=$(logfile_for envtest "$dir") 494 local log=$(logfile_for envtest "$dir")
461 pdir=$(plugin_dir_for "$dir") 495 local pdir=$(plugin_dir_for "$dir")
462 rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi) 496 local rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
463 good=yes 497 local good=yes
464 first=yes 498 local first=yes
465 echo 499 echo
466 echo "Testing existence of RDF files..." 500 echo "Testing existence of RDF files..."
467 for ttlfile in "$rdir"/*.{n3,ttl}; do 501 for ttlfile in "$rdir"/*.{n3,ttl}; do
468 if [ ! -f "$ttlfile" ]; then 502 if [ ! -f "$ttlfile" ]; then
469 # Because we have two different extensions, this isn't an 503 # Because we have two different extensions, this isn't an
486 fi 520 fi
487 [ "$good" = "yes" ] 521 [ "$good" = "yes" ]
488 } 522 }
489 523
490 env_test_accompaniments() { 524 env_test_accompaniments() {
491 dir="$1" 525 local dir="$1"
492 log=$(logfile_for envtest "$dir") 526 local log=$(logfile_for envtest "$dir")
493 good=yes 527 local good=yes
494 echo 528 echo
495 echo "Testing existence of README and accompanying files..." 529 echo "Testing existence of README and accompanying files..."
496 if ! ls -1 "$dir" | egrep -qi "^readme(.txt)?$"; then 530 if ! ls -1 "$dir" | egrep -qi "^readme(.txt)?$"; then
497 echo "ERROR: no README file found" | tee -a "$log" 531 echo "ERROR: no README file found" | tee -a "$log"
498 good=no 532 good=no
506 fi 540 fi
507 [ "$good" = "yes" ] 541 [ "$good" = "yes" ]
508 } 542 }
509 543
510 run_environmental_tests() { 544 run_environmental_tests() {
511 dir="$1" 545 local dir="$1"
512 log=$(logfile_for envtest "$dir") 546 local log=$(logfile_for envtest "$dir")
513 allgood=yes 547 local allgood=yes
514 cat /dev/null > "$log" 548 cat /dev/null > "$log"
515 for test in exports stdout cat ttl accompaniments; do 549 for test in exports stdout cat ttl accompaniments; do
516 "env_test_$test" "$dir" || allgood=no 550 "env_test_$test" "$dir" || allgood=no
517 done 551 done
518 if [ "$allgood" != "yes" ]; then 552 if [ "$allgood" != "yes" ]; then
522 return 0 556 return 0
523 fi 557 fi
524 } 558 }
525 559
526 package() { 560 package() {
527 dir="$1" 561 local dir="$1"
528 id=$(vcs_id "$dir") 562 local id=$(vcs_id "$dir")
529 pstub="$dir-$platform$bits-$id" 563 local pstub="$dir-$platform$bits-$id"
530 pdir="$packagedir/$pstub" 564 local pdir="$packagedir/$pstub"
531 mkdir -p "$pdir" 565 mkdir -p "$pdir"
532 ( cd "$dir" ; 566 ( cd "$dir" ;
533 cp -av \ 567 cp -av \
534 *"$pluginext" \ 568 *"$pluginext" \
535 *.cat \ 569 *.cat \
538 [Rr][Ee][Aa][Dd][Mm][Ee]* \ 572 [Rr][Ee][Aa][Dd][Mm][Ee]* \
539 [Cc][Oo][Pp][Yy][Ii][Nn][Gg]* \ 573 [Cc][Oo][Pp][Yy][Ii][Nn][Gg]* \
540 [Ll][Ii][Cc][Ee][Nn][CcSs][Ee]* \ 574 [Ll][Ii][Cc][Ee][Nn][CcSs][Ee]* \
541 [Cc][Ii][Tt][Aa][Tt][Ii][Oo][Nn]* \ 575 [Cc][Ii][Tt][Aa][Tt][Ii][Oo][Nn]* \
542 [Cc][Hh][Aa][Nn][Gg][Ee][Ll][Oo][Gg]* \ 576 [Cc][Hh][Aa][Nn][Gg][Ee][Ll][Oo][Gg]* \
543 ../"$pdir"/ 577 ../"$pdir"/ || /bin/true
578 if have_vampy_plugins "$dir"; then
579 find_vampy_plugins_in "$dir" | while read p; do
580 cp -av "$p" ../"$pdir"/
581 done
582 fi
544 ) 583 )
545 ( cd "$packagedir"; 584 ( cd "$packagedir";
546 if [ "$platform" = "mingw" ]; then 585 if [ "$platform" = "mingw" ]; then
547 zip -r "$pstub".zip "$pstub" 586 zip -r "$pstub".zip "$pstub"
548 else 587 else
578 echo "Directory $dir not found!" 617 echo "Directory $dir not found!"
579 echo "$dir" >> "$notbuilt" 618 echo "$dir" >> "$notbuilt"
580 elif build_or_rebuild "$dir"; then 619 elif build_or_rebuild "$dir"; then
581 if have_plugin "$dir" ; then 620 if have_plugin "$dir" ; then
582 echo "$dir" >> "$built" 621 echo "$dir" >> "$built"
583 run_tester "$dir" 622 if ! run_tester "$dir"; then
584 run_environmental_tests "$dir" 623 echo "Tester failed for $dir"
624 fi
625 if ! run_environmental_tests "$dir"; then
626 echo "Environmental tests failed for $dir"
627 fi
585 else 628 else
586 log=$(logfile_for build "$dir") 629 log=$(logfile_for build "$dir")
587 echo "Build apparently succeeded, but no resulting plugin(s) found, or plugin(s) have wrong file type or platform" | tee -a "$log" 630 echo "Build apparently succeeded, but no resulting plugin(s) found, or plugin(s) have wrong file type or platform" | tee -a "$log"
588 echo "$dir" >> "$notbuilt" 631 echo "$dir" >> "$notbuilt"
589 fi 632 fi
590 else 633 else
591 echo "$dir" >> "$notbuilt" 634 echo "$dir" >> "$notbuilt"
592 fi 635 fi
593 slog=$(logfile_for summary "$dir") 636 slog=$(logfile_for summary "$dir")
637 echo "initialising logfile $slog for $dir"
594 cat /dev/null > "$slog" 638 cat /dev/null > "$slog"
595 done 639 done
596 640
597 cat "$built" | while read dir; do 641 cat "$built" | while read dir; do
598 package "$dir" 642 package "$dir"