To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / SCRIPTS / process.sh @ 125:34e428693f5d

History | View | Annotate | Download (20.2 KB)

1
#!/bin/bash
2

    
3
# Run this from the top-level vamp-build-and-test directory
4

    
5
## Things to test:
6
##   the plugin builds!
7
##   plugin loads
8
##   passes vamp-plugin-tester tests
9
##   does not export any unnecessary symbols
10
##   has valid .cat and .n3
11

    
12
set -e
13

    
14
mydir=$(dirname "$0")
15
case "$mydir" in /*);; *) mydir=$(pwd)/"$mydir";; esac
16

    
17
. "$mydir"/include.sh
18

    
19
have_all=true
20
for program in make perl git svn hg zip tar ; do
21
    if ! $program --version >/dev/null 2>&1; then
22
	if ! $program -v 2>&1 | grep -q version; then
23
	    echo " ** $program program not found"
24
	    have_all=false
25
	fi
26
    fi
27
done
28
if [ "$have_all" != "true" ]; then
29
    echo "Not all dependencies found, exiting"
30
    exit 1
31
fi
32

    
33
# Get errors from Repoint about SML implementation early
34
( cd "$mydir/.." ; ./repoint version >/dev/null )
35

    
36
do_rebuild=""
37
do_speedy=""
38

    
39
speedy_test_pattern="^[ABE]"
40

    
41
usage() {
42
    echo 
43
    echo "Usage: $0 <platform> [-c] [-s] [<dir> ...]"
44
    echo 
45
    echo " <platform>  one of native, linux32, linux64, mingw32, mingw64, osx32, osx64"
46
    echo " -c          build from clean"
47
    echo " -s          speedy build: skip the slower tests"
48
    echo " <dir>       directory to build (default is all of them)"
49
    echo
50
    echo "Platform usually should match the platform you are running this"
51
    echo "script on, unless you have a cross-compile toolset installed and"
52
    echo "this script knows how to run it. The special platform 'native'"
53
    echo "tries to guess the currently running platform."
54
    echo
55
    exit 2
56
}
57

    
58
platform_arg="$1"
59
platform_native="unknown"
60
case `uname -a` in
61
    Linux*x86_64*) platform_native=linux64;;
62
    Linux*) platform_native=linux32;;
63
    Darwin*) platform_native=osx64;;
64
    CYG*) platform_native=mingw32;;
65
    MINGW*) platform_native=mingw32;;
66
esac
67

    
68
if [ "$platform_arg" = "native" ]; then
69
    platform_arg="$platform_native"
70
fi
71

    
72
platform=
73
platform_defines=("UNUSED_=")   # Avoid passing empty arg to make as if target
74
pubtag=
75
bits=32
76
altbits=
77
toolprefix=
78
pluginext=
79
hostwrapper=
80
hostext=
81
valgrind=
82
archflags=
83
identpattern=
84
sep=":"
85

    
86
case "$platform_arg" in
87
    linux32)
88
	platform=linux
89
	pubtag=linux32
90
	if [ "$platform_native" = "linux64" ]; then
91
	    toolprefix=x86_64-unknown-linux-gnu-
92
	    platform_defines=("CXX=${toolprefix}g++ -m32" "CC=${toolprefix}gcc -m32" "LD=${toolprefix}g++ -m32")
93
	fi
94
	pluginext=.so
95
	valgrind=valgrind
96
	identpattern='ELF 32'
97
	;;
98
    linux64)
99
	platform=linux
100
	bits=64
101
	pubtag=linux64
102
	pluginext=.so
103
	valgrind=valgrind
104
	identpattern='ELF 64'
105
	;;
106
    mingw32)
107
	platform=mingw
108
	pubtag=win32
109
	toolprefix=i686-w64-mingw32- 
110
	pluginext=.dll
111
	hostwrapper=wine
112
	hostext=.exe
113
	identpattern='PE32.*386.*Windows'
114
	sep=";"
115
	;;
116
    mingw64)
117
	platform=mingw
118
	bits=64
119
	pubtag=win64
120
	altbits=32 # We can usually use a mingw32 Makefile if toolprefix is OK
121
	toolprefix=x86_64-w64-mingw32- 
122
	pluginext=.dll
123
	hostwrapper=wine
124
	hostext=.exe
125
	identpattern='PE32.*x86-64.*Windows'
126
	sep=";"
127
	;;
128
    osx32)
129
	platform=osx
130
	pubtag=osx32
131
	pluginext=.dylib
132
	archflags="-arch i386"
133
	identpattern='Mach-O .*i386'
134
	;;
135
    osx64)
136
	platform=osx
137
	bits=64
138
	pubtag=osx
139
	pluginext=.dylib
140
	# This is a difficult choice for various reasons... have to ponder
141
	archflags="-mmacosx-version-min=10.7 -arch x86_64 -arch i386 -stdlib=libc++"
142
	identpattern='Mach-O 64-bit .*x86_64'
143
	;;
144
    *)
145
	usage
146
	;;
147
esac;
148

    
149
shift
150

    
151
if [ -z "$platform" ]; then
152
    usage
153
else
154
    echo "(Platform is $platform, $bits bits, package platform tag $pubtag)"
155
fi
156

    
157
if [ -z "$pluginext" ]; then
158
    echo "Internal error: pluginext not set for platform $platform" 1>&2
159
    exit 2
160
fi
161

    
162
if [ -z "$identpattern" ]; then
163
    echo "Internal error: identpattern not set for platform $platform" 1>&2
164
    exit 2
165
fi
166

    
167
while true; do
168
    case "t$1" in
169
        t-c)
170
            echo "(Building from clean)"
171
            do_rebuild=yes
172
            shift ;;
173
        t-s)
174
            echo "(Speedy build)"
175
            do_speedy=yes
176
            shift ;;
177
        *)
178
            break;;
179
    esac
180
done
181

    
182
metadir="$mydir"/../METADATA
183

    
184
depincdir="$mydir"/../DEPENDENCIES/$platform$bits/include
185
deplibdir="$mydir"/../DEPENDENCIES/$platform$bits/lib
186
depincdir_generic="$mydir"/../DEPENDENCIES/generic/include
187

    
188
pyver=27
189
pyincdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/include
190
numpyincdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/Lib/site-packages/numpy/core/include
191
pylibdir="$mydir"/../DEPENDENCIES/$platform$bits/Python$pyver/libs
192

    
193
repodir="$mydir/../REPOS"
194

    
195
( cd "$mydir/.." ; ./repoint install )
196

    
197
cd "$repodir"
198

    
199
plugindirs="$@"
200
if [ -z "$plugindirs" ]; then
201
    plugindirs=$(ls -1 "$repodir" | grep -v vamp-plugin-sdk | grep -v vamp-plugin-tester | awk '{ print $1; }')
202
    if [ -z "$plugindirs" ]; then
203
        echo "ERROR: No plugin directories found!?"
204
        exit 1
205
    fi
206
else 
207
    for dir in $plugindirs ; do
208
	if [ ! -d "$dir" ]; then
209
	    echo "ERROR: Directory $dir not found"
210
	    usage
211
	fi
212
    done
213
fi
214

    
215
set -u
216

    
217
reportdir="$mydir/../REPORTS/$platform$bits"
218
packagedir="$mydir/../PACKAGES/$platform$bits"
219

    
220
mkdir -p "$reportdir" "$packagedir" || exit 1
221

    
222
built="/tmp/built.$$.txt"
223
testfailed="/tmp/testfailed.$$.txt"
224
envcheckfailed="/tmp/envcheckfailed.$$.txt"
225
notbuilt="/tmp/notbuilt.$$.txt"
226

    
227
trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0
228
touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt"
229

    
230
target_for() {
231
    local dir="$1"
232
    if grep -q "^$dir: " ${metadir}/maketarget.txt ; then
233
	grep "^$dir: " ${metadir}/maketarget.txt | head -1 | sed 's/^[^:]*: //'
234
    fi
235
}
236

    
237
custom_plugin_dir_for() {
238
    local dir="$1"
239
    if grep -q "^$dir: " ${metadir}/plugindir.txt ; then
240
	echo "${repodir}/${dir}"/$(grep "^$dir: " ${metadir}/plugindir.txt | head -1 | sed 's/^[^:]*: //')
241
    fi
242
}
243

    
244
plugin_dir_for() {
245
    local dir="$1"
246
    local pdir=$(custom_plugin_dir_for "$dir")
247
    if [ -z "$pdir" ]; then
248
	case "$dir" in
249
	    /*) pdir="$dir" ;;
250
	    *) pdir="${repodir}/${dir}";;
251
	esac
252
    fi
253
    echo "$pdir"
254
}
255

    
256
configure() {
257
    local dir="$1"
258
    if [ -f "$dir/configure" ] ; then
259
	( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt"
260
    fi
261
}
262

    
263
find_makefile() {
264
    local dir="$1"
265
    for f in \
266
	build/$platform$bits/Makefile.$platform$bits \
267
	build/$platform/Makefile.$platform$bits \
268
	build/$platform$bits/Makefile.$platform \
269
	build/$platform$bits/Makefile \
270
	build/Makefile.$platform$bits \
271
	Makefile.$platform$bits \
272
	build/$platform/Makefile.$platform \
273
	build/$platform/Makefile \
274
	build/Makefile.$platform \
275
	Makefile.$platform \
276
	build/$platform$altbits/Makefile.$platform$altbits \
277
	build/$platform/Makefile.$platform$altbits \
278
	build/$platform$altbits/Makefile.$platform \
279
	build/$platform$altbits/Makefile \
280
	build/Makefile.$platform$altbits \
281
	Makefile.$platform$altbits \
282
	Makefile ; do
283
	if [ -f "$dir/$f" ]; then
284
	    echo $f
285
	    break
286
	fi
287
    done
288
}
289

    
290
find_vampy_plugins_in() {
291
    local dir="$1"
292
    local pdir=$(plugin_dir_for "$dir")
293
    find "$pdir" -name \*.py -print0 | xargs -0 grep -l 'import.*\bvampy\b'
294
}
295

    
296
have_vampy_plugins() {
297
    local dir="$1"
298
    local plugs=$(find_vampy_plugins_in "$dir")
299
    if [ -z "$plugs" ]; then
300
	return 1
301
    else
302
	return 0
303
    fi
304
}
305

    
306
configure_maybe() {
307
    local dir="$1"
308
    if [ t"$do_rebuild" = t"yes" ]; then
309
        configure "$dir"
310
    else
311
        mfile=$(find_makefile "$dir")
312
        if [ -z "$mfile" ]; then
313
	    configure "$dir"
314
        fi
315
    fi
316
}
317

    
318
logfile_for() {
319
    local activity="$1"
320
    local dir="$2"
321
    echo "$reportdir/$dir.$activity.txt"
322
}
323

    
324
build() {
325
    local dir="$1"
326
    local log=$(logfile_for build "$dir")
327
    if configure_maybe "$dir"; then
328
	mfile=$(find_makefile "$dir")
329
	if [ -n "$mfile" ]; then
330
	    target=$(target_for "$dir")
331
	    TOOLPREFIX="$toolprefix" \
332
		CXXFLAGS="-I${depincdir} -I${pyincdir} -I${numpyincdir} -I${depincdir_generic} -I${repodir}/vamp-plugin-sdk" \
333
		LDFLAGS="-L${deplibdir} -L${pylibdir} -L${repodir}/vamp-plugin-sdk" \
334
		ARCHFLAGS="$archflags" \
335
		make -C "$dir" -f "$mfile" $target "${platform_defines[@]}" 2>&1 | \
336
		tee "$log"
337
	    return ${PIPESTATUS[0]}
338
	elif have_vampy_plugins "$dir"; then
339
	    return 0
340
	else
341
	    echo "*** Failed to find a Makefile in $dir!" | tee "$log"
342
	    return 1
343
	fi
344
    fi
345
}
346

    
347
rebuild() {
348
    local dir="$1"
349
    local log=$(logfile_for build "$dir")
350
    if configure_maybe "$dir"; then
351
	mfile=$(find_makefile "$dir")
352
	if [ -n "$mfile" ]; then
353
	    if make -C "$dir" -f "$mfile" distclean; then
354
		build "$dir"
355
	    elif make -C "$dir" -f "$mfile" clean; then
356
		build "$dir"
357
	    else
358
		echo "*** Failed to 'make clean' in $dir!" | tee "$log"
359
		return 1
360
	    fi
361
	elif have_vampy_plugins "$dir"; then
362
	    return 0
363
	else
364
	    echo "*** Failed to find a Makefile in $dir!" | tee "$log"
365
	    return 1
366
	fi
367
    fi
368
}
369

    
370
build_or_rebuild() {
371
    local dir="$1"
372
    if [ -n "$do_rebuild" ]; then
373
	rebuild "$dir"
374
    else
375
	build "$dir"
376
    fi
377
}
378

    
379
have_plugin() {
380
    local dir="$1"
381
    local log=$(logfile_for build "$dir")
382
    for x in "$dir/"*"$pluginext"; do 
383
	if [ -f "$x" ]; then
384
	    if file "$x" | grep -q "$identpattern" ; then
385
		return 0
386
	    else
387
		echo "Plugin $x exists, but fails to match file type for correct platform (file type is: `file $x`, expected pattern is: $identpattern)" | tee "$log"
388
		return 1
389
	    fi
390
	fi
391
    done
392
    have_vampy_plugins "$dir"
393
}
394

    
395
is_nondeterministic() {
396
    plugin_id="$1"
397
    grep -q "^$id\$" ${metadir}/nondeterministic.txt
398
}
399

    
400
plugin_ids_in() {
401
    local dir="$1"
402
    local pdir=$(plugin_dir_for "$dir")
403
    local vampydir=""
404
    if have_vampy_plugins "$pdir"; then
405
	vampydir="./vampy"
406
    fi
407
    # can't use sed to remove \r from DOS line endings -- BSD and GNU
408
    # vary in how they interpret \r escape -- so we use perl for that...
409
    VAMP_PATH="$pdir$sep$vampydir" $hostwrapper \
410
	vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids | \
411
	grep '^vamp:' | \
412
	sed 's/^vamp://' | \
413
	perl -p -e 's/\r//g' 
414
}
415

    
416
run_tester() {
417
    ##!!! todo: timeout if the plugin takes too long and report as failure
418
    local dir="$1"
419
    local log=$(logfile_for test "$dir")
420
    local ids=$(plugin_ids_in "$dir")
421
    local pdir=$(plugin_dir_for "$dir")
422
    cat /dev/null > "$log"
423
    if [ -z "$ids" ]; then
424
	echo 
425
	echo "No plugins reported to test in $dir" | tee -a "$log"
426
	echo "$dir" >> "$testfailed"
427
	return 1
428
    fi
429
    good=yes
430
    for id in $ids; do
431
	extra=""
432
	if is_nondeterministic "$id"; then
433
	    extra="-n"
434
	fi
435
        tests=$($hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -l | tail -n +6 | sed 's/ *|.*$//' | fmt -1000)
436
        for test in $tests; do
437
            run_this_test=yes
438
            if [ -n "$do_speedy" ]; then
439
                if echo "$test" | grep -q "$speedy_test_pattern"; then
440
                    run_this_test=yes
441
                else
442
                    run_this_test=""
443
                fi
444
            fi
445
            if [ -z "$run_this_test" ]; then
446
                continue
447
            fi
448
#	    echo "Running command: VAMP_PATH=\"$pdir\" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext \"$extra\" -t \"$test\" \"$id\"" | tee -a "$log"
449
	    if ( VAMP_PATH="$pdir$sep./vampy" $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext "$extra" -t "$test" "$id" 2>&1 | tee -a "$log" ; exit ${PIPESTATUS[0]} ) ; then
450
                :
451
	    else
452
                if [ -n "$do_speedy" ]; then
453
		    echo | tee -a "$log"
454
		    echo "Tester failed for id $id and test $test (not restarting with valgrind, as speedy flag is set)" | tee -a "$log"
455
	        elif have_vampy_plugins "$pdir"; then # (don't attempt vampy+valgrind)
456
		    echo | tee -a "$log"
457
		    echo "Tester failed for id $id and test $test (not restarting with valgrind, as this is a VamPy plugin)" | tee -a "$log"
458
	        else
459
		    echo | tee -a "$log"
460
		    echo "Tester failed for id $id and test $test: running again with valgrind (if available) and verbose for a report..." | tee -a "$log"
461
		    VAMP_PATH="$pdir$sep./vampy" $valgrind $hostwrapper vamp-plugin-tester/vamp-plugin-tester$hostext -v "$extra" -t "$test" "$id" 2>&1 | tee -a "$log"
462
	        fi
463
	        good=no
464
	    fi
465
        done
466
    done
467
    if [ "$good" != "yes" ]; then
468
	echo "$dir" >> "$testfailed"
469
	return 1
470
    else
471
	return 0
472
    fi
473
}
474

    
475
public_symbols_in() {
476
    lib="$1"
477
    # nm -g prints global symbols in both OS/X and GNU tools, but
478
    # printing only global *defined* symbols is harder. In GNU it is
479
    # nm -g --defined-only; the OS/X docs suggest nm -gu should work,
480
    # but it doesn't. What I think will work with both is simply
481
    # grepping out the undefineds:
482
    nm="${toolprefix}nm"
483
    if ! type -path "$nm" >/dev/null; then nm=nm; fi
484
    "$nm" -g "$lib" | grep -v ' U ' | awk '{ print $3; }'
485
}
486

    
487
env_test_exports() {
488
    local dir="$1"
489
    local log=$(logfile_for envtest "$dir")
490
    local good=yes
491
    for lib in "$dir"/*"$pluginext"; do 
492
	if [ ! -f "$lib" ]; then
493
	    # This should only happen if the glob was not expanded at all
494
	    echo "NOTE: no library found in $dir?" | tee -a "$log"
495
	    good=no
496
	    break
497
	fi
498
	echo 
499
	echo "Testing for exported symbols in $lib..."
500
	if public_symbols_in "$lib" | grep -q vampGetPluginDescriptor; then
501
	    others=`public_symbols_in "$lib" | grep -v vampGetPluginDescriptor`
502
	    if [ -n "$others" ]; then
503
		count=`echo "$others" | wc -l`
504
		echo "ERROR: library $lib exports $count extra symbols in addition to vampGetPluginDescriptor" | tee -a "$log"
505
		good=no
506
	    else
507
		echo "GOOD: library $lib only exports vampGetPluginDescriptor" | tee -a "$log"
508
	    fi
509
	else
510
	    echo "NOTE: found library $lib that is not a Vamp plugin library" | tee -a "$log"
511
	fi
512
    done
513
    [ "$good" = "yes" ]
514
}
515

    
516
env_test_stdout() {
517
    local dir="$1"
518
    local log=$(logfile_for envtest "$dir")
519
    local pdir=$(plugin_dir_for "$dir")
520
    local good=yes
521
    local ids=$(VAMP_PATH="$pdir" $hostwrapper vamp-plugin-sdk/host/vamp-simple-host$hostext --list-ids);
522
    echo 
523
    echo "Testing for any unwanted output to stdout..."
524
    for id in $ids; do
525
	case "$id" in
526
	    vamp:*) ;;
527
	    *)
528
		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"
529
		good=no
530
		;;
531
	esac
532
    done
533
    [ "$good" = "yes" ]
534
}
535

    
536
env_test_cat() {
537
    local dir="$1"
538
    local log=$(logfile_for envtest "$dir")
539
    local pdir=$(custom_plugin_dir_for "$dir")
540
    local cdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
541
    local good=yes
542
    local first=yes
543
    echo 
544
    echo "Testing some details of .cat files..."
545
    for catfile in "$cdir"/*".cat"; do
546
	if [ ! -f "$catfile" ]; then
547
	    # This should only happen if the glob was not expanded at all
548
	    echo "ERROR: no .cat file found in $dir" | tee -a "$log"
549
	    good=no
550
	    break
551
	fi
552
	if [ "$first" = "yes" ]; then
553
	    first=no
554
	else
555
	    echo "NOTE: multiple .cat files found in $cdir" | tee -a "$log"
556
	fi
557
    done
558
    if [ "$good" = "yes" ]; then
559
	excess=$(plugin_ids_in "$dir" | sed 's/^/vamp:/' | \
560
	    cat - "$cdir"/*".cat" | \
561
	    sed 's/::.*//' | \
562
            sort | \
563
            uniq -u)
564
	if [ -n "$excess" ]; then
565
	    echo "ERROR: excess or missing definitions in .cat file? $excess" | tee -a "$log"
566
	    good=no
567
	else
568
	    echo "GOOD: no excess or missing definitions in .cat files" | tee -a "$log"
569
	fi
570
    fi
571
    [ "$good" = "yes" ]
572
}
573

    
574
env_test_ttl() {
575
    local dir="$1"
576
    local log=$(logfile_for envtest "$dir")
577
    local pdir=$(custom_plugin_dir_for "$dir")
578
    local rdir=$(if test -n "$pdir" ; then echo "$pdir" ; else echo "$dir" ; fi)
579
    local good=yes
580
    local first=yes
581
    echo 
582
    echo "Testing existence of RDF files..."
583
    for ttlfile in "$rdir"/*.{n3,ttl}; do
584
	if [ ! -f "$ttlfile" ]; then
585
	    # Because we have two different extensions, this isn't an
586
	    # error as it is with e.g. .cat (because one or the other
587
	    # of .n3 and .ttl almost certainly won't exist). But if we
588
	    # drop out the bottom and first is still true, then we
589
	    # know neither matched.
590
	    :
591
	elif [ "$first" = "yes" ]; then
592
	    first=no
593
	else
594
	    echo "NOTE: multiple .ttl or .n3 files found in $rdir" | tee -a "$log"
595
	fi
596
    done
597
    if [ "$first" = "yes" ]; then
598
	echo "ERROR: no .ttl or .n3 files found in $rdir" | tee -a "$log"
599
	good=no; 
600
    else
601
	echo "GOOD: found one or more .ttl or .n3 files (we don't actually test their validity or content here though)" | tee -a "$log"
602
    fi
603
    [ "$good" = "yes" ]
604
}
605

    
606
env_test_accompaniments() {
607
    local dir="$1"
608
    local log=$(logfile_for envtest "$dir")
609
    local good=yes
610
    echo 
611
    echo "Testing existence of README and accompanying files..."
612
    if ! ls -1 "$dir" | egrep -qi "^readme(.txt)?$"; then
613
	echo "ERROR: no README file found" | tee -a "$log"
614
	good=no
615
    fi
616
    if ! ls -1 "$dir" | egrep -qi "^(copying|licen[cs]e)(.txt)?$"; then
617
	echo "ERROR: no COPYING or LICEN[CS]E file found" | tee -a "$log"
618
	good=no
619
    fi
620
    if ! ls -1 "$dir" | egrep -qi "^citation(.txt)?$"; then
621
	echo "NOTE: no CITATION file found" | tee -a "$log"
622
    fi
623
    [ "$good" = "yes" ]
624
}
625

    
626
run_environmental_tests() {
627
    local dir="$1"
628
    local log=$(logfile_for envtest "$dir")
629
    local allgood=yes
630
    cat /dev/null > "$log"
631
    for test in exports stdout cat ttl accompaniments; do
632
	"env_test_$test" "$dir" || allgood=no
633
    done
634
    if [ "$allgood" != "yes" ]; then
635
	echo "$dir" >> "$envcheckfailed"
636
	return 1
637
    else
638
	return 0
639
    fi
640
}
641

    
642
package() {
643
    local dir="$1"
644
    local id=$(vcs_id "$dir")
645
    local pstub="$dir-$pubtag-$id"
646
    local pdir="$packagedir/$pstub"
647
    mkdir -p "$pdir"
648
    ( cd "$dir" ; 
649
	cp -av \
650
	    *"$pluginext" \
651
	    *.cat \
652
	    *.n3 \
653
	    *.ttl \
654
	    [Rr][Ee][Aa][Dd][Mm][Ee]* \
655
	    [Cc][Oo][Pp][Yy][Ii][Nn][Gg]* \
656
	    [Ll][Ii][Cc][Ee][Nn][CcSs][Ee]* \
657
	    [Cc][Ii][Tt][Aa][Tt][Ii][Oo][Nn]* \
658
	    [Cc][Hh][Aa][Nn][Gg][Ee][Ll][Oo][Gg]* \
659
	    "$pdir"/ || true
660
	if have_vampy_plugins "$dir"; then
661
	    find_vampy_plugins_in "$dir" | while read p; do
662
					       cp -av "$p" "$pdir"/
663
					   done
664
	fi
665
	)
666
    ( cd "$packagedir";
667
	if [ "$platform" = "mingw" ]; then
668
	    zip -r "$pstub".zip "$pstub"
669
	else
670
	    tar cvjf "$pstub".tar.bz2 "$pstub"
671
	fi;
672
	rm -rf "$pstub"
673
    )
674
}
675

    
676
if ! build_or_rebuild "vamp-plugin-sdk"; then 
677
    echo "*** Failed to build Vamp plugin SDK!"
678
    exit 1
679
fi
680

    
681
# Ensure we can only link statically against these
682
for x in vamp-hostsdk vamp-sdk; do 
683
    for y in dylib dll so; do
684
	rm -f "vamp-plugin-sdk/lib$x.$y"
685
	rm -f "vamp-plugin-sdk/$x.$y"
686
    done
687
done
688

    
689
if ! build_or_rebuild "vamp-plugin-tester"; then 
690
    echo "*** Failed to build Vamp plugin tester!"
691
    exit 1
692
fi
693

    
694
need_vampy=no
695
for dir in $plugindirs ; do
696
    if have_vampy_plugins "$dir"; then
697
	need_vampy=yes
698
	break
699
    fi
700
done
701
if [ "$need_vampy" = "yes" ] && [ "$plugindirs" != "vampy" ]; then
702
    if ! build_or_rebuild "vampy"; then 
703
	echo "*** Failed to build VamPy! (needed for other plugins)"
704
	exit 1
705
    fi
706
fi
707

    
708
for dir in $plugindirs ; do
709
    dir=${dir%/*}
710
    echo
711
    echo "Processing: $dir"
712
    if [ ! -d "$dir" ]; then
713
	echo "Directory $dir not found!"
714
	echo "$dir" >> "$notbuilt"
715
    elif build_or_rebuild "$dir"; then
716
	if have_plugin "$dir" ; then
717
	    echo "$dir" >> "$built"
718
	    if ! run_tester "$dir"; then
719
		echo "Tester failed for $dir"
720
	    fi
721
	    if ! run_environmental_tests "$dir"; then
722
		echo "Environmental tests failed for $dir"
723
	    fi
724
	else 
725
	    log=$(logfile_for build "$dir")
726
	    echo "Build apparently succeeded, but no resulting plugin(s) found, or plugin(s) have wrong file type or platform" | tee -a "$log"
727
	    echo "$dir" >> "$notbuilt"
728
	fi
729
    else
730
	echo "$dir" >> "$notbuilt"
731
    fi
732
    slog=$(logfile_for summary "$dir")
733
    echo "initialising logfile $slog for $dir"
734
    cat /dev/null > "$slog"
735
done
736

    
737
cat "$built" | while read dir; do
738
    package "$dir"
739
done
740

    
741
echo
742
echo "** Built, tested, checked, and packaged:"
743
cat "$built" | while read dir; do
744
    slog=$(logfile_for summary "$dir")
745
    if ! grep -q "^$dir\$" "$testfailed"; then
746
	if ! grep -q "^$dir\$" "$envcheckfailed"; then
747
	    echo "$dir"
748
	    echo "$dir: OK: Success" >> "$slog"
749
	fi
750
    fi
751
done | sort
752

    
753
echo
754
echo "** Failed tests:"
755
cat "$testfailed" | sort | uniq | while read dir; do
756
    slog=$(logfile_for summary "$dir")
757
    echo "$dir"
758
    echo "$dir: TEST_FAILED: Built successfully, but failed tests" >> "$slog"
759
done
760

    
761
echo
762
echo "** Failed environmental checks:"
763
cat "$envcheckfailed" | sort | uniq | while read dir; do
764
    slog=$(logfile_for summary "$dir")
765
    echo "$dir"
766
    echo "$dir: ENV_FAILED: Built successfully, but failed environmental checks" >> "$slog"
767
done
768

    
769
echo
770
echo "** Failed to build:"	    
771
cat "$notbuilt" | sort | while read dir; do
772
    slog=$(logfile_for summary "$dir")
773
    echo "$dir"
774
    echo "$dir: BUILD_FAILED: Failed to compile" >> "$slog"
775
done
776

    
777
echo