changeset 86:413a9d26189e

Handle VamPy plugins
author Chris Cannam
date Tue, 24 Feb 2015 18:00:31 +0000
parents 5936362b8a40
children 2a2c65a20a8b
files .hgsubstate METADATA/plugindir.txt SCRIPTS/process.sh
diffstat 3 files changed, 124 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Wed Jan 07 09:59:33 2015 +0000
+++ b/.hgsubstate	Tue Feb 24 18:00:31 2015 +0000
@@ -1,21 +1,21 @@
 29936292cec05fe06756baa9e51f43f04481175c cepstral-pitchtracker
-cb98263b30f47d003b5f53c5f6ab63037d377e29 constant-q-cpp
+9106fb546452ef75de41a1ab8d97cc54ab763b5c constant-q-cpp
 a68204b9a529352a0042a9343f99b0d2b64c9ffc match-vamp
 ca32a96c123a2c3f7548e37a8d5f4205632bdd9d mazurka-plugins
-e00437a2821b707830b4a112160fcddecd3c86c7 miredu
-9d706d314e080b8a075e635b4821ec883fab327a nnls-chroma
+96c11ea1deeb1c00c5c9429663a5c9ec95a8f3b3 miredu
+c585c95f2d860a96c6a66c8cd1a51a1292a2358b nnls-chroma
 e83e6bb1367a5524db9c6f41cec3445eccad1a5f predomino
-585fdda4d7f92c249b2f15b1ec21d50d9b4644aa pyin
+effea38d5a6dd566f34e721a316e3b422348725d pyin
 6c9ab70d23861140f918024c875b7dd92bd6a04d qm-vamp-plugins
 11a826034a9d67fc3ba36ceea052ccd4554f82f2 segmenter-vamp-plugin
-04a3c152e59070491adee566234229bfdcf02b32 silvet
+07ee4ebea57c9135fef5b127df3ed6ac0a1712dc silvet
 f6597489acf5f93163214874c0cd346d6e65ed95 tempest
-b835875739968beb870e7e09132aa361656a8a30 vamp-aubio-plugins
+3aee7fc5c39cd1b856030ea452de7abfe62f033e vamp-aubio-plugins
 81146373f024be1c82371f04262cf2ae1680cb61 vamp-libxtract-plugins
 8bc4ec815b6b695371dc9dda500191892ca5d2a7 vamp-onsetsds-plugin
-632d90c185ecc8655f7a85ba58dc568351449dfd vamp-plugin-sdk
+e0697515163f85c8edf039c5de71b4c2968ffc07 vamp-plugin-sdk
 314eea778b805e9308494e0d9eea6516624f7ee1 vamp-plugin-tester
 f021dc97da29d9c92cfec37b0a100723b6921f3e vamp-simple-cepstrum
 02721bb9c4f07dadfe5fd32e2ac9d6f6958749a5 vamp-tempogram
-534b001d8e8fc91d980b983c733c5b6bfccb6c24 vamp-test-plugin
+42e71acaba8eb051b46009459ddd1e99f2176270 vamp-test-plugin
 d8eaa10e153e8c7a2731ea99e932cc7308a6c967 vampy
--- a/METADATA/plugindir.txt	Wed Jan 07 09:59:33 2015 +0000
+++ b/METADATA/plugindir.txt	Tue Feb 24 18:00:31 2015 +0000
@@ -1,1 +1,2 @@
 vampy: Example VamPy plugins
+tempest: plugin
--- a/SCRIPTS/process.sh	Wed Jan 07 09:59:33 2015 +0000
+++ b/SCRIPTS/process.sh	Tue Feb 24 18:00:31 2015 +0000
@@ -9,6 +9,8 @@
 ##   does not export any unnecessary symbols
 ##   has valid .cat and .n3
 
+set -eu
+
 mydir=$(dirname "$0")
 case "$mydir" in /*);; *) mydir=$(pwd)/"$mydir";; esac
 
@@ -171,15 +173,29 @@
 trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0
 touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt"
 
+target_for() {
+    local dir="$1"
+    if grep -q "^$dir: " METADATA/maketarget.txt ; then
+	grep "^$dir: " METADATA/maketarget.txt | head -1 | sed 's/^[^:]*: //'
+    fi
+}
+
+plugin_dir_for() {
+    local dir="$1"
+    if grep -q "^$dir: " METADATA/plugindir.txt ; then
+	echo "$dir"/$(grep "^$dir: " METADATA/plugindir.txt | head -1 | sed 's/^[^:]*: //')
+    fi
+}
+
 configure() {
-    dir="$1"
+    local dir="$1"
     if [ -f "$dir/configure" ] ; then
 	( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt"
     fi
 }
 
 find_makefile() {
-    dir="$1"
+    local dir="$1"
     for f in \
 	build/$platform$bits/Makefile.$platform$bits \
 	build/$platform/Makefile.$platform$bits \
@@ -205,8 +221,27 @@
     done
 }
 
+find_vampy_plugins_in() {
+    local dir="$1"
+    local pdir=$(plugin_dir_for "$dir")
+    if [ -z "$pdir" ]; then
+	pdir="$dir"
+    fi
+    find "$pdir" -name \*.py -print0 | xargs -0 grep -l 'import.*\bvampy\b'
+}
+
+have_vampy_plugins() {
+    local dir="$1"
+    local plugs=$(find_vampy_plugins_in "$dir")
+    if [ -z "$plugs" ]; then
+	return 1
+    else
+	return 0
+    fi
+}
+
 configure_maybe() {
-    dir="$1"
+    local dir="$1"
     if [ t"$do_rebuild" = t"yes" ]; then
         configure "$dir"
     else
@@ -217,29 +252,15 @@
     fi
 }
 
-target_for() {
-    dir="$1"
-    if grep -q "^$dir: " METADATA/maketarget.txt ; then
-	grep "^$dir: " METADATA/maketarget.txt | head -1 | sed 's/^[^:]*: //'
-    fi
-}
-
-plugin_dir_for() {
-    dir="$1"
-    if grep -q "^$dir: " METADATA/plugindir.txt ; then
-	echo "$dir"/$(grep "^$dir: " METADATA/plugindir.txt | head -1 | sed 's/^[^:]*: //')
-    fi
-}
-
 logfile_for() {
-    activity="$1"
-    dir="$2"
+    local activity="$1"
+    local dir="$2"
     echo "$reportdir/$dir.$activity.txt"
 }
 
 build() {
-    dir="$1"
-    log=$(logfile_for build "$dir")
+    local dir="$1"
+    local log=$(logfile_for build "$dir")
     if configure_maybe "$dir"; then
 	mfile=$(find_makefile "$dir")
 	if [ -n "$mfile" ]; then
@@ -251,6 +272,8 @@
 		make -C "$dir" -f "$mfile" $target 2>&1 | \
 		tee "$log"
 	    return ${PIPESTATUS[0]}
+	elif have_vampy_plugins "$dir"; then
+	    return 0
 	else
 	    echo "Failed to find a Makefile in $dir!" | tee "$log"
 	    return 1
@@ -259,8 +282,8 @@
 }
 
 rebuild() {
-    dir="$1"
-    log=$(logfile_for build "$dir")
+    local dir="$1"
+    local log=$(logfile_for build "$dir")
     if configure_maybe "$dir"; then
 	mfile=$(find_makefile "$dir")
 	if [ -n "$mfile" ]; then
@@ -272,6 +295,8 @@
 		echo "Failed to 'make clean' in $dir!" | tee "$log"
 		return 1
 	    fi
+	elif have_vampy_plugins "$dir"; then
+	    return 0
 	else
 	    echo "Failed to find a Makefile in $dir!" | tee "$log"
 	    return 1
@@ -280,7 +305,7 @@
 }
 
 build_or_rebuild() {
-    dir="$1"
+    local dir="$1"
     if [ -n "$do_rebuild" ]; then
 	rebuild "$dir"
     else
@@ -289,8 +314,8 @@
 }
 
 have_plugin() {
-    dir="$1"
-    log=$(logfile_for build "$dir")
+    local dir="$1"
+    local log=$(logfile_for build "$dir")
     for x in "$dir/"*"$pluginext"; do 
 	if [ -f "$x" ]; then
 	    if file "$x" | grep -q "$identpattern" ; then
@@ -301,7 +326,7 @@
 	    fi
 	fi
     done
-    return 1
+    have_vampy_plugins "$dir"
 }
 
 is_nondeterministic() {
@@ -310,11 +335,15 @@
 }
 
 plugin_ids_in() {
-    dir="$1"
-    pdir=$(plugin_dir_for "$dir")
+    local dir="$1"
+    local pdir=$(plugin_dir_for "$dir")
+    local vampydir=""
+    if have_vampy_plugins "$pdir"; then
+	vampydir="./vampy"
+    fi
     # can't use sed to remove \r from DOS line endings -- BSD and GNU
     # vary in how they interpret \r escape -- so we use perl for that...
-    VAMP_PATH="$dir:$pdir" $hostwrapper \
+    VAMP_PATH="$dir:$pdir:$vampydir" $hostwrapper \
 	vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids | \
 	grep '^vamp:' | \
 	sed 's/^vamp://' | \
@@ -323,10 +352,10 @@
 
 run_tester() {
     ##!!! todo: timeout if the plugin takes too long and report as failure
-    dir="$1"
-    log=$(logfile_for test "$dir")
-    ids=$(plugin_ids_in "$dir")
-    pdir=$(plugin_dir_for "$dir")
+    local dir="$1"
+    local log=$(logfile_for test "$dir")
+    local ids=$(plugin_ids_in "$dir")
+    local pdir=$(plugin_dir_for "$dir")
     cat /dev/null > "$log"
     if [ -z "$ids" ]; then
 	echo 
@@ -341,12 +370,17 @@
 	    extra="-n"
 	fi
 	echo "Running command: VAMP_PATH=\"$dir:$pdir\" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext \"$extra\" \"$id\"" | tee -a "$log"
-	if ( VAMP_PATH="$dir:$pdir" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext "$extra" "$id" 2>&1 | tee -a "$log" ; exit ${PIPESTATUS[0]} ) ; then
+	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
 	    echo "OK" | tee -a "$log"
 	else
-	    echo | tee -a "$log"
-	    echo "Tester failed for id $id: running again with valgrind (if available) and verbose for a report..." | tee -a "$log"
-	    VAMP_PATH="$dir:$pdir" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" "$id" 2>&1 | tee -a "$log"
+	    if have_vampy_plugins "$pdir"; then # (don't attempt vampy+valgrind)
+		echo | tee -a "$log"
+		echo "Tester failed for id $id (not restarting with valgrind, as this is a VamPy plugin)" | tee -a "$log"
+	    else
+		echo | tee -a "$log"
+		echo "Tester failed for id $id: running again with valgrind (if available) and verbose for a report..." | tee -a "$log"
+		VAMP_PATH="$dir:$pdir:./vampy" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" "$id" 2>&1 | tee -a "$log"
+	    fi
 	    good=no
 	fi
     done
@@ -369,9 +403,9 @@
 }
 
 env_test_exports() {
-    dir="$1"
-    log=$(logfile_for envtest "$dir")
-    good=yes
+    local dir="$1"
+    local log=$(logfile_for envtest "$dir")
+    local good=yes
     for lib in "$dir"/*"$pluginext"; do 
 	if [ ! -f "$lib" ]; then
 	    # This should only happen if the glob was not expanded at all
@@ -398,11 +432,11 @@
 }
 
 env_test_stdout() {
-    dir="$1"
-    log=$(logfile_for envtest "$dir")
-    pdir=$(plugin_dir_for "$dir")
-    good=yes
-    ids=$(VAMP_PATH="$dir:$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids);
+    local dir="$1"
+    local log=$(logfile_for envtest "$dir")
+    local pdir=$(plugin_dir_for "$dir")
+    local good=yes
+    local ids=$(VAMP_PATH="$dir:$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids);
     echo 
     echo "Testing for any unwanted output to stdout..."
     for id in $ids; do
@@ -418,12 +452,12 @@
 }
 
 env_test_cat() {
-    dir="$1"
-    log=$(logfile_for envtest "$dir")
-    pdir=$(plugin_dir_for "$dir")
-    cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
-    good=yes
-    first=yes
+    local dir="$1"
+    local log=$(logfile_for envtest "$dir")
+    local pdir=$(plugin_dir_for "$dir")
+    local cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
+    local good=yes
+    local first=yes
     echo 
     echo "Testing some details of .cat files..."
     for catfile in "$cdir"/*".cat"; do
@@ -456,12 +490,12 @@
 }
 
 env_test_ttl() {
-    dir="$1"
-    log=$(logfile_for envtest "$dir")
-    pdir=$(plugin_dir_for "$dir")
-    rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
-    good=yes
-    first=yes
+    local dir="$1"
+    local log=$(logfile_for envtest "$dir")
+    local pdir=$(plugin_dir_for "$dir")
+    local rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
+    local good=yes
+    local first=yes
     echo 
     echo "Testing existence of RDF files..."
     for ttlfile in "$rdir"/*.{n3,ttl}; do
@@ -488,9 +522,9 @@
 }
 
 env_test_accompaniments() {
-    dir="$1"
-    log=$(logfile_for envtest "$dir")
-    good=yes
+    local dir="$1"
+    local log=$(logfile_for envtest "$dir")
+    local good=yes
     echo 
     echo "Testing existence of README and accompanying files..."
     if ! ls -1 "$dir" | egrep -qi "^readme(.txt)?$"; then
@@ -508,9 +542,9 @@
 }
 
 run_environmental_tests() {
-    dir="$1"
-    log=$(logfile_for envtest "$dir")
-    allgood=yes
+    local dir="$1"
+    local log=$(logfile_for envtest "$dir")
+    local allgood=yes
     cat /dev/null > "$log"
     for test in exports stdout cat ttl accompaniments; do
 	"env_test_$test" "$dir" || allgood=no
@@ -524,10 +558,10 @@
 }
 
 package() {
-    dir="$1"
-    id=$(vcs_id "$dir")
-    pstub="$dir-$platform$bits-$id"
-    pdir="$packagedir/$pstub"
+    local dir="$1"
+    local id=$(vcs_id "$dir")
+    local pstub="$dir-$platform$bits-$id"
+    local pdir="$packagedir/$pstub"
     mkdir -p "$pdir"
     ( cd "$dir" ; 
 	cp -av \
@@ -540,7 +574,12 @@
 	    [Ll][Ii][Cc][Ee][Nn][CcSs][Ee]* \
 	    [Cc][Ii][Tt][Aa][Tt][Ii][Oo][Nn]* \
 	    [Cc][Hh][Aa][Nn][Gg][Ee][Ll][Oo][Gg]* \
-	    ../"$pdir"/
+	    ../"$pdir"/ || /bin/true
+	if have_vampy_plugins "$dir"; then
+	    find_vampy_plugins_in "$dir" | while read p; do
+					       cp -av "$p" ../"$pdir"/
+					   done
+	fi
 	)
     ( cd "$packagedir";
 	if [ "$platform" = "mingw" ]; then
@@ -580,8 +619,12 @@
     elif build_or_rebuild "$dir"; then
 	if have_plugin "$dir" ; then
 	    echo "$dir" >> "$built"
-	    run_tester "$dir"
-	    run_environmental_tests "$dir"
+	    if ! run_tester "$dir"; then
+		echo "Tester failed for $dir"
+	    fi
+	    if ! run_environmental_tests "$dir"; then
+		echo "Environmental tests failed for $dir"
+	    fi
 	else 
 	    log=$(logfile_for build "$dir")
 	    echo "Build apparently succeeded, but no resulting plugin(s) found, or plugin(s) have wrong file type or platform" | tee -a "$log"
@@ -591,6 +634,7 @@
 	echo "$dir" >> "$notbuilt"
     fi
     slog=$(logfile_for summary "$dir")
+    echo "initialising logfile $slog for $dir"
     cat /dev/null > "$slog"
 done