annotate SCRIPTS/process.sh @ 120:4729c8589274 emscripten-piper

Add piper builds
author Chris Cannam
date Fri, 11 Nov 2016 15:49:32 +0000
parents 4d3bba3c0fe7
children
rev   line source
Chris@1 1 #!/bin/bash
Chris@1 2
Chris@6 3 # Run this from the top-level vamp-build-and-test directory
Chris@6 4
Chris@1 5 ## Things to test:
Chris@1 6 ## the plugin builds!
Chris@1 7 ## plugin loads
Chris@1 8 ## passes vamp-plugin-tester tests
Chris@1 9 ## does not export any unnecessary symbols
Chris@1 10 ## has valid .cat and .n3
Chris@1 11
Chris@88 12 set -e
Chris@86 13
Chris@19 14 mydir=$(dirname "$0")
Chris@19 15 case "$mydir" in /*);; *) mydir=$(pwd)/"$mydir";; esac
Chris@19 16
Chris@75 17 . "$mydir"/include.sh
Chris@75 18
Chris@57 19 have_all=true
Chris@66 20 for program in make perl git svn hg zip tar ; do
Chris@57 21 if ! $program --version >/dev/null 2>&1; then
Chris@57 22 if ! $program -v 2>&1 | grep -q version; then
Chris@57 23 echo " ** $program program not found"
Chris@57 24 have_all=false
Chris@57 25 fi
Chris@57 26 fi
Chris@57 27 done
Chris@57 28 if [ "$have_all" != "true" ]; then
Chris@57 29 echo "Not all dependencies found, exiting"
Chris@57 30 exit 1
Chris@57 31 fi
Chris@57 32
Chris@22 33 do_rebuild=""
Chris@14 34
Chris@22 35 usage() {
Chris@22 36 echo
Chris@22 37 echo "Usage: $0 <platform> [-c] [<dir> ...]"
Chris@22 38 echo
Chris@120 39 echo " <platform> one of:"
Chris@120 40 echo " native, linux32, linux64, mingw32, mingw64, osx32, osx64, piper"
Chris@120 41 echo " -c build from clean"
Chris@120 42 echo " <dir> directory to build (default is all of them)"
Chris@22 43 echo
Chris@22 44 echo "Platform usually should match the platform you are running this"
Chris@22 45 echo "script on, unless you have a cross-compile toolset installed and"
Chris@120 46 echo "this script knows how to run it. The 'piper' platform builds a"
Chris@120 47 echo "portable Piper API Javascript module using Emscripten. The special"
Chris@120 48 echo "platform 'native' tries to guess the currently running platform."
Chris@22 49 echo
Chris@22 50 exit 2
Chris@22 51 }
Chris@21 52
Chris@31 53 platform_arg="$1"
Chris@109 54 platform_native="unknown"
Chris@109 55 case `uname -a` in
Chris@109 56 Linux*x86_64*) platform_native=linux64;;
Chris@109 57 Linux*) platform_native=linux32;;
Chris@109 58 Darwin*) platform_native=osx64;;
Chris@109 59 CYG*) platform_native=mingw32;;
Chris@109 60 MINGW*) platform_native=mingw32;;
Chris@109 61 esac
Chris@31 62
Chris@31 63 if [ "$platform_arg" = "native" ]; then
Chris@109 64 platform_arg="$platform_native"
Chris@31 65 fi
Chris@31 66
Chris@78 67 platform=
Chris@110 68 platform_defines=("UNUSED_=") # Avoid passing empty arg to make as if target
Chris@114 69 pubtag=
Chris@78 70 bits=32
Chris@78 71 altbits=
Chris@78 72 toolprefix=
Chris@78 73 pluginext=
Chris@78 74 hostwrapper=
Chris@78 75 hostext=
Chris@78 76 valgrind=
Chris@78 77 archflags=
Chris@78 78 identpattern=
Chris@96 79 sep=":"
Chris@78 80
Chris@31 81 case "$platform_arg" in
Chris@22 82 linux32)
Chris@22 83 platform=linux
Chris@114 84 pubtag=linux32
Chris@109 85 if [ "$platform_native" = "linux64" ]; then
Chris@109 86 toolprefix=x86_64-unknown-linux-gnu-
Chris@109 87 platform_defines=("CXX=${toolprefix}g++ -m32" "CC=${toolprefix}gcc -m32" "LD=${toolprefix}g++ -m32")
Chris@109 88 fi
Chris@22 89 pluginext=.so
Chris@38 90 valgrind=valgrind
Chris@42 91 identpattern='ELF 32'
Chris@22 92 ;;
Chris@22 93 linux64)
Chris@22 94 platform=linux
Chris@22 95 bits=64
Chris@114 96 pubtag=linux64
Chris@22 97 pluginext=.so
Chris@38 98 valgrind=valgrind
Chris@42 99 identpattern='ELF 64'
Chris@22 100 ;;
Chris@22 101 mingw32)
Chris@22 102 platform=mingw
Chris@114 103 pubtag=win32
Chris@22 104 toolprefix=i686-w64-mingw32-
Chris@22 105 pluginext=.dll
Chris@22 106 hostwrapper=wine
Chris@22 107 hostext=.exe
Chris@36 108 identpattern='PE32.*386.*Windows'
Chris@96 109 sep=";"
Chris@22 110 ;;
Chris@22 111 mingw64)
Chris@22 112 platform=mingw
Chris@22 113 bits=64
Chris@114 114 pubtag=win64
Chris@78 115 altbits=32 # We can usually use a mingw32 Makefile if toolprefix is OK
Chris@22 116 toolprefix=x86_64-w64-mingw32-
Chris@22 117 pluginext=.dll
Chris@22 118 hostwrapper=wine
Chris@22 119 hostext=.exe
Chris@78 120 identpattern='PE32.*x86-64.*Windows'
Chris@96 121 sep=";"
Chris@22 122 ;;
Chris@22 123 osx32)
Chris@22 124 platform=osx
Chris@114 125 pubtag=osx32
Chris@22 126 pluginext=.dylib
Chris@22 127 archflags="-arch i386"
Chris@40 128 identpattern='Mach-O .*i386'
Chris@22 129 ;;
Chris@22 130 osx64)
Chris@22 131 platform=osx
Chris@22 132 bits=64
Chris@114 133 pubtag=osx
Chris@22 134 pluginext=.dylib
Chris@26 135 # This is a difficult choice for various reasons... have to ponder
Chris@107 136 archflags="-mmacosx-version-min=10.7 -arch x86_64 -arch i386 -stdlib=libc++"
Chris@40 137 identpattern='Mach-O 64-bit .*x86_64'
Chris@22 138 ;;
Chris@120 139 piper)
Chris@120 140 shift
Chris@120 141 exec "$mydir"/process-piper.sh "$@"
Chris@120 142 ;;
Chris@88 143 *)
Chris@88 144 usage
Chris@88 145 ;;
Chris@22 146 esac;
Chris@22 147
Chris@22 148 shift
Chris@22 149
Chris@22 150 if [ -z "$platform" ]; then
Chris@22 151 usage
Chris@22 152 else
Chris@114 153 echo "(Platform is $platform, $bits bits, package platform tag $pubtag)"
Chris@22 154 fi
Chris@22 155
Chris@78 156 if [ -z "$pluginext" ]; then
Chris@78 157 echo "Internal error: pluginext not set for platform $platform" 1>&2
Chris@78 158 exit 2
Chris@78 159 fi
Chris@78 160
Chris@78 161 if [ -z "$identpattern" ]; then
Chris@78 162 echo "Internal error: identpattern not set for platform $platform" 1>&2
Chris@78 163 exit 2
Chris@78 164 fi
Chris@78 165
Chris@22 166 if [ t"$1" = t"-c" ]; then
Chris@22 167 echo "(Building from clean)"
Chris@22 168 do_rebuild=yes
Chris@22 169 shift
Chris@22 170 fi
Chris@15 171
Chris@91 172 metadir="$mydir"/../METADATA
Chris@91 173
Chris@19 174 depincdir="$mydir"/../DEPENDENCIES/$platform$bits/include
Chris@19 175 deplibdir="$mydir"/../DEPENDENCIES/$platform$bits/lib
Chris@88 176 depincdir_generic="$mydir"/../DEPENDENCIES/generic/include
Chris@19 177
Chris@88 178 pyver=27
Chris@88 179 pyincdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/include
Chris@88 180 numpyincdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/Lib/site-packages/numpy/core/include
Chris@88 181 pylibdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/libs
Chris@1 182
Chris@11 183 plugindirs="$@"
Chris@11 184 if [ -z "$plugindirs" ]; then
Chris@119 185 plugindirs=$(cat METADATA/repos.txt |
Chris@119 186 grep -v vamp-plugin-sdk |
Chris@119 187 grep -v vamp-plugin-tester |
Chris@119 188 grep -v '^piper' |
Chris@119 189 awk '{ print $1; }')
Chris@61 190 else
Chris@61 191 for dir in $plugindirs ; do
Chris@61 192 if [ ! -d "$dir" ]; then
Chris@61 193 echo "ERROR: Directory $dir not found"
Chris@61 194 usage
Chris@61 195 fi
Chris@61 196 done
Chris@11 197 fi
Chris@11 198
Chris@88 199 set -u
Chris@88 200
Chris@6 201 reportdir="REPORTS/$platform$bits"
Chris@49 202 packagedir="PACKAGES/$platform$bits"
Chris@49 203
Chris@49 204 mkdir -p "$reportdir" "$packagedir" || exit 1
Chris@6 205
Chris@9 206 built="/tmp/built.$$.txt"
Chris@9 207 testfailed="/tmp/testfailed.$$.txt"
Chris@19 208 envcheckfailed="/tmp/envcheckfailed.$$.txt"
Chris@9 209 notbuilt="/tmp/notbuilt.$$.txt"
Chris@49 210
Chris@19 211 trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0
Chris@19 212 touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt"
Chris@9 213
Chris@86 214 target_for() {
Chris@86 215 local dir="$1"
Chris@91 216 if grep -q "^$dir: " ${metadir}/maketarget.txt ; then
Chris@91 217 grep "^$dir: " ${metadir}/maketarget.txt | head -1 | sed 's/^[^:]*: //'
Chris@86 218 fi
Chris@86 219 }
Chris@86 220
Chris@109 221 custom_plugin_dir_for() {
Chris@86 222 local dir="$1"
Chris@91 223 if grep -q "^$dir: " ${metadir}/plugindir.txt ; then
Chris@91 224 echo "${mydir}/../${dir}"/$(grep "^$dir: " ${metadir}/plugindir.txt | head -1 | sed 's/^[^:]*: //')
Chris@86 225 fi
Chris@86 226 }
Chris@86 227
Chris@109 228 plugin_dir_for() {
Chris@109 229 local dir="$1"
Chris@109 230 local pdir=$(custom_plugin_dir_for "$dir")
Chris@109 231 if [ -z "$pdir" ]; then
Chris@109 232 case "$dir" in
Chris@109 233 /*) pdir="$dir" ;;
Chris@109 234 *) pdir="${mydir}/../${dir}";;
Chris@109 235 esac
Chris@109 236 fi
Chris@109 237 echo "$pdir"
Chris@109 238 }
Chris@109 239
Chris@4 240 configure() {
Chris@86 241 local dir="$1"
Chris@4 242 if [ -f "$dir/configure" ] ; then
Chris@6 243 ( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt"
Chris@4 244 fi
Chris@4 245 }
Chris@4 246
Chris@1 247 find_makefile() {
Chris@86 248 local dir="$1"
Chris@9 249 for f in \
Chris@19 250 build/$platform$bits/Makefile.$platform$bits \
Chris@13 251 build/$platform/Makefile.$platform$bits \
Chris@19 252 build/$platform$bits/Makefile.$platform \
Chris@19 253 build/$platform$bits/Makefile \
Chris@19 254 build/Makefile.$platform$bits \
Chris@19 255 Makefile.$platform$bits \
Chris@13 256 build/$platform/Makefile.$platform \
Chris@13 257 build/$platform/Makefile \
Chris@13 258 build/Makefile.$platform \
Chris@9 259 Makefile.$platform \
Chris@78 260 build/$platform$altbits/Makefile.$platform$altbits \
Chris@78 261 build/$platform/Makefile.$platform$altbits \
Chris@78 262 build/$platform$altbits/Makefile.$platform \
Chris@78 263 build/$platform$altbits/Makefile \
Chris@78 264 build/Makefile.$platform$altbits \
Chris@78 265 Makefile.$platform$altbits \
Chris@13 266 Makefile ; do
Chris@1 267 if [ -f "$dir/$f" ]; then
Chris@1 268 echo $f
Chris@1 269 break
Chris@1 270 fi
Chris@1 271 done
Chris@1 272 }
Chris@1 273
Chris@86 274 find_vampy_plugins_in() {
Chris@86 275 local dir="$1"
Chris@86 276 local pdir=$(plugin_dir_for "$dir")
Chris@86 277 find "$pdir" -name \*.py -print0 | xargs -0 grep -l 'import.*\bvampy\b'
Chris@86 278 }
Chris@86 279
Chris@86 280 have_vampy_plugins() {
Chris@86 281 local dir="$1"
Chris@86 282 local plugs=$(find_vampy_plugins_in "$dir")
Chris@86 283 if [ -z "$plugs" ]; then
Chris@86 284 return 1
Chris@86 285 else
Chris@86 286 return 0
Chris@86 287 fi
Chris@86 288 }
Chris@86 289
Chris@13 290 configure_maybe() {
Chris@86 291 local dir="$1"
Chris@43 292 if [ t"$do_rebuild" = t"yes" ]; then
Chris@43 293 configure "$dir"
Chris@43 294 else
Chris@43 295 mfile=$(find_makefile "$dir")
Chris@43 296 if [ -z "$mfile" ]; then
Chris@43 297 configure "$dir"
Chris@43 298 fi
Chris@13 299 fi
Chris@13 300 }
Chris@13 301
Chris@44 302 logfile_for() {
Chris@86 303 local activity="$1"
Chris@86 304 local dir="$2"
Chris@44 305 echo "$reportdir/$dir.$activity.txt"
Chris@44 306 }
Chris@44 307
Chris@4 308 build() {
Chris@86 309 local dir="$1"
Chris@86 310 local log=$(logfile_for build "$dir")
Chris@1 311 if configure_maybe "$dir"; then
Chris@1 312 mfile=$(find_makefile "$dir")
Chris@1 313 if [ -n "$mfile" ]; then
Chris@19 314 target=$(target_for "$dir")
Chris@19 315 TOOLPREFIX="$toolprefix" \
Chris@90 316 CXXFLAGS="-I${depincdir} -I${pyincdir} -I${numpyincdir} -I${depincdir_generic} -I${mydir}/../vamp-plugin-sdk" \
Chris@90 317 LDFLAGS="-L${deplibdir} -L${pylibdir} -L${mydir}/../vamp-plugin-sdk" \
Chris@21 318 ARCHFLAGS="$archflags" \
Chris@109 319 make -C "$dir" -f "$mfile" $target "${platform_defines[@]}" 2>&1 | \
Chris@44 320 tee "$log"
Chris@9 321 return ${PIPESTATUS[0]}
Chris@86 322 elif have_vampy_plugins "$dir"; then
Chris@86 323 return 0
Chris@1 324 else
Chris@88 325 echo "*** Failed to find a Makefile in $dir!" | tee "$log"
Chris@4 326 return 1
Chris@1 327 fi
Chris@1 328 fi
Chris@4 329 }
Chris@4 330
Chris@4 331 rebuild() {
Chris@86 332 local dir="$1"
Chris@86 333 local log=$(logfile_for build "$dir")
Chris@13 334 if configure_maybe "$dir"; then
Chris@4 335 mfile=$(find_makefile "$dir")
Chris@4 336 if [ -n "$mfile" ]; then
Chris@77 337 if make -C "$dir" -f "$mfile" distclean; then
Chris@77 338 build "$dir"
Chris@77 339 elif make -C "$dir" -f "$mfile" clean; then
Chris@32 340 build "$dir"
Chris@32 341 else
Chris@88 342 echo "*** Failed to 'make clean' in $dir!" | tee "$log"
Chris@32 343 return 1
Chris@32 344 fi
Chris@86 345 elif have_vampy_plugins "$dir"; then
Chris@86 346 return 0
Chris@4 347 else
Chris@88 348 echo "*** Failed to find a Makefile in $dir!" | tee "$log"
Chris@4 349 return 1
Chris@4 350 fi
Chris@4 351 fi
Chris@4 352 }
Chris@4 353
Chris@22 354 build_or_rebuild() {
Chris@86 355 local dir="$1"
Chris@22 356 if [ -n "$do_rebuild" ]; then
Chris@22 357 rebuild "$dir"
Chris@22 358 else
Chris@22 359 build "$dir"
Chris@22 360 fi
Chris@22 361 }
Chris@22 362
Chris@19 363 have_plugin() {
Chris@86 364 local dir="$1"
Chris@86 365 local log=$(logfile_for build "$dir")
Chris@19 366 for x in "$dir/"*"$pluginext"; do
Chris@19 367 if [ -f "$x" ]; then
Chris@36 368 if file "$x" | grep -q "$identpattern" ; then
Chris@36 369 return 0
Chris@36 370 else
Chris@44 371 echo "Plugin $x exists, but fails to match file type for correct platform (file type is: `file $x`, expected pattern is: $identpattern)" | tee "$log"
Chris@36 372 return 1
Chris@36 373 fi
Chris@19 374 fi
Chris@19 375 done
Chris@86 376 have_vampy_plugins "$dir"
Chris@19 377 }
Chris@19 378
Chris@19 379 is_nondeterministic() {
Chris@19 380 plugin_id="$1"
Chris@91 381 grep -q "^$id\$" ${metadir}/nondeterministic.txt
Chris@19 382 }
Chris@19 383
Chris@44 384 plugin_ids_in() {
Chris@86 385 local dir="$1"
Chris@86 386 local pdir=$(plugin_dir_for "$dir")
Chris@86 387 local vampydir=""
Chris@86 388 if have_vampy_plugins "$pdir"; then
Chris@86 389 vampydir="./vampy"
Chris@86 390 fi
Chris@40 391 # can't use sed to remove \r from DOS line endings -- BSD and GNU
Chris@44 392 # vary in how they interpret \r escape -- so we use perl for that...
Chris@109 393 VAMP_PATH="$pdir$sep$vampydir" $hostwrapper \
Chris@44 394 vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids | \
Chris@44 395 grep '^vamp:' | \
Chris@44 396 sed 's/^vamp://' | \
Chris@44 397 perl -p -e 's/\r//g'
Chris@44 398 }
Chris@44 399
Chris@44 400 run_tester() {
Chris@44 401 ##!!! todo: timeout if the plugin takes too long and report as failure
Chris@86 402 local dir="$1"
Chris@86 403 local log=$(logfile_for test "$dir")
Chris@86 404 local ids=$(plugin_ids_in "$dir")
Chris@86 405 local pdir=$(plugin_dir_for "$dir")
Chris@44 406 cat /dev/null > "$log"
Chris@6 407 if [ -z "$ids" ]; then
Chris@6 408 echo
Chris@44 409 echo "No plugins reported to test in $dir" | tee -a "$log"
Chris@44 410 echo "$dir" >> "$testfailed"
Chris@44 411 return 1
Chris@44 412 fi
Chris@44 413 good=yes
Chris@44 414 for id in $ids; do
Chris@44 415 extra=""
Chris@44 416 if is_nondeterministic "$id"; then
Chris@44 417 extra="-n"
Chris@44 418 fi
Chris@109 419 echo "Running command: VAMP_PATH=\"$pdir\" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext \"$extra\" \"$id\"" | tee -a "$log"
Chris@109 420 if ( VAMP_PATH="$pdir$sep./vampy" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext "$extra" "$id" 2>&1 | tee -a "$log" ; exit ${PIPESTATUS[0]} ) ; then
Chris@62 421 echo "OK" | tee -a "$log"
Chris@44 422 else
Chris@86 423 if have_vampy_plugins "$pdir"; then # (don't attempt vampy+valgrind)
Chris@86 424 echo | tee -a "$log"
Chris@86 425 echo "Tester failed for id $id (not restarting with valgrind, as this is a VamPy plugin)" | tee -a "$log"
Chris@86 426 else
Chris@86 427 echo | tee -a "$log"
Chris@86 428 echo "Tester failed for id $id: running again with valgrind (if available) and verbose for a report..." | tee -a "$log"
Chris@109 429 VAMP_PATH="$pdir$sep./vampy" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" "$id" 2>&1 | tee -a "$log"
Chris@86 430 fi
Chris@44 431 good=no
Chris@44 432 fi
Chris@44 433 done
Chris@44 434 if [ "$good" != "yes" ]; then
Chris@23 435 echo "$dir" >> "$testfailed"
Chris@6 436 return 1
Chris@5 437 else
Chris@44 438 return 0
Chris@5 439 fi
Chris@5 440 }
Chris@5 441
Chris@44 442 public_symbols_in() {
Chris@9 443 lib="$1"
Chris@23 444 # nm -g prints global symbols in both OS/X and GNU tools, but
Chris@23 445 # printing only global *defined* symbols is harder. In GNU it is
Chris@23 446 # nm -g --defined-only; the OS/X docs suggest nm -gu should work,
Chris@23 447 # but it doesn't. What I think will work with both is simply
Chris@23 448 # grepping out the undefineds:
Chris@109 449 nm="${toolprefix}nm"
Chris@109 450 if ! type -path "$nm" >/dev/null; then nm=nm; fi
Chris@109 451 "$nm" -g "$lib" | grep -v ' U ' | awk '{ print $3; }'
Chris@9 452 }
Chris@9 453
Chris@44 454 env_test_exports() {
Chris@86 455 local dir="$1"
Chris@86 456 local log=$(logfile_for envtest "$dir")
Chris@86 457 local good=yes
Chris@44 458 for lib in "$dir"/*"$pluginext"; do
Chris@44 459 if [ ! -f "$lib" ]; then
Chris@44 460 # This should only happen if the glob was not expanded at all
Chris@44 461 echo "NOTE: no library found in $dir?" | tee -a "$log"
Chris@44 462 good=no
Chris@44 463 break
Chris@44 464 fi
Chris@44 465 echo
Chris@44 466 echo "Testing for exported symbols in $lib..."
Chris@44 467 if public_symbols_in "$lib" | grep -q vampGetPluginDescriptor; then
Chris@44 468 others=`public_symbols_in "$lib" | grep -v vampGetPluginDescriptor`
Chris@44 469 if [ -n "$others" ]; then
Chris@44 470 count=`echo "$others" | wc -l`
Chris@44 471 echo "ERROR: library $lib exports $count extra symbols in addition to vampGetPluginDescriptor" | tee -a "$log"
Chris@44 472 good=no
Chris@44 473 else
Chris@44 474 echo "GOOD: library $lib only exports vampGetPluginDescriptor" | tee -a "$log"
Chris@44 475 fi
Chris@44 476 else
Chris@44 477 echo "NOTE: found library $lib that is not a Vamp plugin library" | tee -a "$log"
Chris@44 478 fi
Chris@44 479 done
Chris@44 480 [ "$good" = "yes" ]
Chris@44 481 }
Chris@44 482
Chris@44 483 env_test_stdout() {
Chris@86 484 local dir="$1"
Chris@86 485 local log=$(logfile_for envtest "$dir")
Chris@86 486 local pdir=$(plugin_dir_for "$dir")
Chris@86 487 local good=yes
Chris@109 488 local ids=$(VAMP_PATH="$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids);
Chris@44 489 echo
Chris@44 490 echo "Testing for any unwanted output to stdout..."
Chris@44 491 for id in $ids; do
Chris@44 492 case "$id" in
Chris@44 493 vamp:*) ;;
Chris@44 494 *)
Chris@44 495 echo "ERROR: plugin in $dir prints to stdout as it runs: found text $id (should use stderr for debug logging to avoid mixing with batch output stream)" | tee -a "$log"
Chris@44 496 good=no
Chris@44 497 ;;
Chris@44 498 esac
Chris@44 499 done
Chris@44 500 [ "$good" = "yes" ]
Chris@44 501 }
Chris@44 502
Chris@44 503 env_test_cat() {
Chris@86 504 local dir="$1"
Chris@86 505 local log=$(logfile_for envtest "$dir")
Chris@109 506 local pdir=$(custom_plugin_dir_for "$dir")
Chris@86 507 local cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
Chris@86 508 local good=yes
Chris@86 509 local first=yes
Chris@44 510 echo
Chris@44 511 echo "Testing some details of .cat files..."
Chris@80 512 for catfile in "$cdir"/*".cat"; do
Chris@44 513 if [ ! -f "$catfile" ]; then
Chris@44 514 # This should only happen if the glob was not expanded at all
Chris@44 515 echo "ERROR: no .cat file found in $dir" | tee -a "$log"
Chris@44 516 good=no
Chris@44 517 break
Chris@44 518 fi
Chris@44 519 if [ "$first" = "yes" ]; then
Chris@44 520 first=no
Chris@44 521 else
Chris@80 522 echo "NOTE: multiple .cat files found in $cdir" | tee -a "$log"
Chris@44 523 fi
Chris@44 524 done
Chris@44 525 if [ "$good" = "yes" ]; then
Chris@46 526 excess=$(plugin_ids_in "$dir" | sed 's/^/vamp:/' | \
Chris@85 527 cat - "$cdir"/*".cat" | \
Chris@47 528 sed 's/::.*//' | \
Chris@47 529 sort | \
Chris@47 530 uniq -u)
Chris@44 531 if [ -n "$excess" ]; then
Chris@47 532 echo "ERROR: excess or missing definitions in .cat file? $excess" | tee -a "$log"
Chris@44 533 good=no
Chris@44 534 else
Chris@47 535 echo "GOOD: no excess or missing definitions in .cat files" | tee -a "$log"
Chris@44 536 fi
Chris@44 537 fi
Chris@44 538 [ "$good" = "yes" ]
Chris@44 539 }
Chris@44 540
Chris@44 541 env_test_ttl() {
Chris@86 542 local dir="$1"
Chris@86 543 local log=$(logfile_for envtest "$dir")
Chris@109 544 local pdir=$(custom_plugin_dir_for "$dir")
Chris@86 545 local rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
Chris@86 546 local good=yes
Chris@86 547 local first=yes
Chris@44 548 echo
Chris@44 549 echo "Testing existence of RDF files..."
Chris@80 550 for ttlfile in "$rdir"/*.{n3,ttl}; do
Chris@44 551 if [ ! -f "$ttlfile" ]; then
Chris@44 552 # Because we have two different extensions, this isn't an
Chris@44 553 # error as it is with e.g. .cat (because one or the other
Chris@44 554 # of .n3 and .ttl almost certainly won't exist). But if we
Chris@44 555 # drop out the bottom and first is still true, then we
Chris@44 556 # know neither matched.
Chris@44 557 :
Chris@44 558 elif [ "$first" = "yes" ]; then
Chris@44 559 first=no
Chris@44 560 else
Chris@80 561 echo "NOTE: multiple .ttl or .n3 files found in $rdir" | tee -a "$log"
Chris@44 562 fi
Chris@44 563 done
Chris@80 564 if [ "$first" = "yes" ]; then
Chris@80 565 echo "ERROR: no .ttl or .n3 files found in $rdir" | tee -a "$log"
Chris@45 566 good=no;
Chris@45 567 else
Chris@45 568 echo "GOOD: found one or more .ttl or .n3 files (we don't actually test their validity or content here though)" | tee -a "$log"
Chris@45 569 fi
Chris@45 570 [ "$good" = "yes" ]
Chris@45 571 }
Chris@45 572
Chris@45 573 env_test_accompaniments() {
Chris@86 574 local dir="$1"
Chris@86 575 local log=$(logfile_for envtest "$dir")
Chris@86 576 local good=yes
Chris@46 577 echo
Chris@46 578 echo "Testing existence of README and accompanying files..."
Chris@66 579 if ! ls -1 "$dir" | egrep -qi "^readme(.txt)?$"; then
Chris@45 580 echo "ERROR: no README file found" | tee -a "$log"
Chris@45 581 good=no
Chris@45 582 fi
Chris@53 583 if ! ls -1 "$dir" | egrep -qi "^(copying|licen[cs]e)(.txt)?$"; then
Chris@45 584 echo "ERROR: no COPYING or LICEN[CS]E file found" | tee -a "$log"
Chris@45 585 good=no
Chris@45 586 fi
Chris@53 587 if ! ls -1 "$dir" | egrep -qi "^citation(.txt)?$"; then
Chris@45 588 echo "NOTE: no CITATION file found" | tee -a "$log"
Chris@45 589 fi
Chris@44 590 [ "$good" = "yes" ]
Chris@44 591 }
Chris@44 592
Chris@9 593 run_environmental_tests() {
Chris@86 594 local dir="$1"
Chris@86 595 local log=$(logfile_for envtest "$dir")
Chris@86 596 local allgood=yes
Chris@44 597 cat /dev/null > "$log"
Chris@45 598 for test in exports stdout cat ttl accompaniments; do
Chris@44 599 "env_test_$test" "$dir" || allgood=no
Chris@9 600 done
Chris@44 601 if [ "$allgood" != "yes" ]; then
Chris@19 602 echo "$dir" >> "$envcheckfailed"
Chris@44 603 return 1
Chris@44 604 else
Chris@44 605 return 0
Chris@19 606 fi
Chris@9 607 }
Chris@4 608
Chris@49 609 package() {
Chris@86 610 local dir="$1"
Chris@86 611 local id=$(vcs_id "$dir")
Chris@114 612 local pstub="$dir-$pubtag-$id"
Chris@86 613 local pdir="$packagedir/$pstub"
Chris@49 614 mkdir -p "$pdir"
Chris@49 615 ( cd "$dir" ;
Chris@49 616 cp -av \
Chris@49 617 *"$pluginext" \
Chris@49 618 *.cat \
Chris@49 619 *.n3 \
Chris@49 620 *.ttl \
Chris@49 621 [Rr][Ee][Aa][Dd][Mm][Ee]* \
Chris@49 622 [Cc][Oo][Pp][Yy][Ii][Nn][Gg]* \
Chris@49 623 [Ll][Ii][Cc][Ee][Nn][CcSs][Ee]* \
Chris@49 624 [Cc][Ii][Tt][Aa][Tt][Ii][Oo][Nn]* \
Chris@49 625 [Cc][Hh][Aa][Nn][Gg][Ee][Ll][Oo][Gg]* \
Chris@105 626 ../"$pdir"/ || true
Chris@86 627 if have_vampy_plugins "$dir"; then
Chris@86 628 find_vampy_plugins_in "$dir" | while read p; do
Chris@86 629 cp -av "$p" ../"$pdir"/
Chris@86 630 done
Chris@86 631 fi
Chris@49 632 )
Chris@49 633 ( cd "$packagedir";
Chris@49 634 if [ "$platform" = "mingw" ]; then
Chris@54 635 zip -r "$pstub".zip "$pstub"
Chris@49 636 else
Chris@53 637 tar cvjf "$pstub".tar.bz2 "$pstub"
Chris@49 638 fi;
Chris@53 639 rm -rf "$pstub"
Chris@49 640 )
Chris@49 641 }
Chris@49 642
Chris@22 643 if ! build_or_rebuild "vamp-plugin-sdk"; then
Chris@88 644 echo "*** Failed to build Vamp plugin SDK!"
Chris@5 645 exit 1
Chris@5 646 fi
Chris@5 647
Chris@26 648 # Ensure we can only link statically against these
Chris@26 649 for x in vamp-hostsdk vamp-sdk; do
Chris@26 650 for y in dylib dll so; do
Chris@26 651 rm -f "vamp-plugin-sdk/lib$x.$y"
Chris@26 652 rm -f "vamp-plugin-sdk/$x.$y"
Chris@26 653 done
Chris@26 654 done
Chris@26 655
Chris@22 656 if ! build_or_rebuild "vamp-plugin-tester"; then
Chris@88 657 echo "*** Failed to build Vamp plugin tester!"
Chris@5 658 exit 1
Chris@5 659 fi
Chris@5 660
Chris@88 661 need_vampy=no
Chris@88 662 for dir in $plugindirs ; do
Chris@88 663 if have_vampy_plugins "$dir"; then
Chris@88 664 need_vampy=yes
Chris@88 665 break
Chris@88 666 fi
Chris@88 667 done
Chris@88 668 if [ "$need_vampy" = "yes" ] && [ "$plugindirs" != "vampy" ]; then
Chris@88 669 if ! build_or_rebuild "vampy"; then
Chris@88 670 echo "*** Failed to build VamPy! (needed for other plugins)"
Chris@88 671 exit 1
Chris@88 672 fi
Chris@88 673 fi
Chris@88 674
Chris@11 675 for dir in $plugindirs ; do
Chris@31 676 dir=${dir%/*}
Chris@4 677 echo
Chris@4 678 echo "Processing: $dir"
Chris@31 679 if [ ! -d "$dir" ]; then
Chris@31 680 echo "Directory $dir not found!"
Chris@31 681 echo "$dir" >> "$notbuilt"
Chris@31 682 elif build_or_rebuild "$dir"; then
Chris@19 683 if have_plugin "$dir" ; then
Chris@19 684 echo "$dir" >> "$built"
Chris@86 685 if ! run_tester "$dir"; then
Chris@86 686 echo "Tester failed for $dir"
Chris@86 687 fi
Chris@86 688 if ! run_environmental_tests "$dir"; then
Chris@86 689 echo "Environmental tests failed for $dir"
Chris@86 690 fi
Chris@19 691 else
Chris@44 692 log=$(logfile_for build "$dir")
Chris@44 693 echo "Build apparently succeeded, but no resulting plugin(s) found, or plugin(s) have wrong file type or platform" | tee -a "$log"
Chris@19 694 echo "$dir" >> "$notbuilt"
Chris@19 695 fi
Chris@4 696 else
Chris@6 697 echo "$dir" >> "$notbuilt"
Chris@4 698 fi
Chris@44 699 slog=$(logfile_for summary "$dir")
Chris@86 700 echo "initialising logfile $slog for $dir"
Chris@44 701 cat /dev/null > "$slog"
Chris@1 702 done
Chris@1 703
Chris@49 704 cat "$built" | while read dir; do
Chris@49 705 package "$dir"
Chris@49 706 done
Chris@49 707
Chris@4 708 echo
Chris@49 709 echo "** Built, tested, checked, and packaged:"
Chris@44 710 cat "$built" | while read dir; do
Chris@44 711 slog=$(logfile_for summary "$dir")
Chris@44 712 if ! grep -q "^$dir\$" "$testfailed"; then
Chris@44 713 if ! grep -q "^$dir\$" "$envcheckfailed"; then
Chris@44 714 echo "$dir"
Chris@59 715 echo "$dir: OK: Success" >> "$slog"
Chris@32 716 fi
Chris@6 717 fi
Chris@6 718 done | sort
Chris@4 719
Chris@4 720 echo
Chris@19 721 echo "** Failed tests:"
Chris@44 722 cat "$testfailed" | sort | uniq | while read dir; do
Chris@44 723 slog=$(logfile_for summary "$dir")
Chris@44 724 echo "$dir"
Chris@59 725 echo "$dir: TEST_FAILED: Built successfully, but failed tests" >> "$slog"
Chris@6 726 done
Chris@5 727
Chris@5 728 echo
Chris@19 729 echo "** Failed environmental checks:"
Chris@44 730 cat "$envcheckfailed" | sort | uniq | while read dir; do
Chris@44 731 slog=$(logfile_for summary "$dir")
Chris@44 732 echo "$dir"
Chris@59 733 echo "$dir: ENV_FAILED: Built successfully, but failed environmental checks" >> "$slog"
Chris@19 734 done
Chris@19 735
Chris@19 736 echo
Chris@4 737 echo "** Failed to build:"
Chris@44 738 cat "$notbuilt" | sort | while read dir; do
Chris@44 739 slog=$(logfile_for summary "$dir")
Chris@44 740 echo "$dir"
Chris@59 741 echo "$dir: BUILD_FAILED: Failed to compile" >> "$slog"
Chris@6 742 done
Chris@4 743
Chris@4 744 echo