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 @ 133:4acb5d8d80b6

History | View | Annotate | Download (20.1 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
do_rebuild=""
34
do_speedy=""
35

    
36
speedy_test_pattern="^[ABE]"
37

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

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

    
65
if [ "$platform_arg" = "native" ]; then
66
    platform_arg="$platform_native"
67
fi
68

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

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

    
146
shift
147

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

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

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

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

    
179
metadir="$mydir"/../METADATA
180

    
181
depincdir="$mydir"/../DEPENDENCIES/$platform$bits/include
182
deplibdir="$mydir"/../DEPENDENCIES/$platform$bits/lib
183
depincdir_generic="$mydir"/../DEPENDENCIES/generic/include
184

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

    
190
plugindirs="$@"
191
if [ -z "$plugindirs" ]; then
192
    plugindirs=$(cat METADATA/repos.txt | grep -v vamp-plugin-sdk | grep -v vamp-plugin-tester | awk '{ print $1; }')
193
else 
194
    for dir in $plugindirs ; do
195
	if [ ! -d "$dir" ]; then
196
	    echo "ERROR: Directory $dir not found"
197
	    usage
198
	fi
199
    done
200
fi
201

    
202
set -u
203

    
204
reportdir="REPORTS/$platform$bits"
205
packagedir="PACKAGES/$platform$bits"
206

    
207
mkdir -p "$reportdir" "$packagedir" || exit 1
208

    
209
built="/tmp/built.$$.txt"
210
testfailed="/tmp/testfailed.$$.txt"
211
envcheckfailed="/tmp/envcheckfailed.$$.txt"
212
notbuilt="/tmp/notbuilt.$$.txt"
213

    
214
trap 'rm -f "$built" "$envcheckfailed" "$testfailed" "$notbuilt"' 0
215
touch "$built" "$envcheckfailed" "$testfailed" "$notbuilt"
216

    
217
target_for() {
218
    local dir="$1"
219
    if grep -q "^$dir: " ${metadir}/maketarget.txt ; then
220
	grep "^$dir: " ${metadir}/maketarget.txt | head -1 | sed 's/^[^:]*: //'
221
    fi
222
}
223

    
224
custom_plugin_dir_for() {
225
    local dir="$1"
226
    if grep -q "^$dir: " ${metadir}/plugindir.txt ; then
227
	echo "${mydir}/../${dir}"/$(grep "^$dir: " ${metadir}/plugindir.txt | head -1 | sed 's/^[^:]*: //')
228
    fi
229
}
230

    
231
plugin_dir_for() {
232
    local dir="$1"
233
    local pdir=$(custom_plugin_dir_for "$dir")
234
    if [ -z "$pdir" ]; then
235
	case "$dir" in
236
	    /*) pdir="$dir" ;;
237
	    *) pdir="${mydir}/../${dir}";;
238
	esac
239
    fi
240
    echo "$pdir"
241
}
242

    
243
configure() {
244
    local dir="$1"
245
    if [ -f "$dir/configure" ] ; then
246
	( cd "$dir" ; ./configure ) 2>&1 | tee "$reportdir/$dir.configure.txt"
247
    fi
248
}
249

    
250
repoint() {
251
    local dir="$1"
252
    if [ -f "$dir/repoint-project.json" ] ; then
253
	( cd "$dir" ; ./repoint install ) 2>&1 | tee "$reportdir/$dir.repoint.txt"
254
    fi
255
}
256

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

    
284
find_vampy_plugins_in() {
285
    local dir="$1"
286
    local pdir=$(plugin_dir_for "$dir")
287
    find "$pdir" -name \*.py -print0 | xargs -0 grep -l 'import.*\bvampy\b'
288
}
289

    
290
have_vampy_plugins() {
291
    local dir="$1"
292
    local plugs=$(find_vampy_plugins_in "$dir")
293
    if [ -z "$plugs" ]; then
294
	return 1
295
    else
296
	return 0
297
    fi
298
}
299

    
300
configure_maybe() {
301
    local dir="$1"
302
    if [ t"$do_rebuild" = t"yes" ]; then
303
        configure "$dir"
304
    else
305
        mfile=$(find_makefile "$dir")
306
        if [ -z "$mfile" ]; then
307
	    configure "$dir"
308
        fi
309
    fi
310
}
311

    
312
logfile_for() {
313
    local activity="$1"
314
    local dir="$2"
315
    echo "$reportdir/$dir.$activity.txt"
316
}
317

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

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

    
366
build_or_rebuild() {
367
    local dir="$1"
368
    if [ -n "$do_rebuild" ]; then
369
	rebuild "$dir"
370
    else
371
	build "$dir"
372
    fi
373
}
374

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

    
391
is_nondeterministic() {
392
    plugin_id="$1"
393
    grep -q "^$id\$" ${metadir}/nondeterministic.txt
394
}
395

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

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

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

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

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

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

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

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

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

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

    
672
if ! build_or_rebuild "vamp-plugin-sdk"; then 
673
    echo "*** Failed to build Vamp plugin SDK!"
674
    exit 1
675
fi
676

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

    
685
if ! build_or_rebuild "vamp-plugin-tester"; then 
686
    echo "*** Failed to build Vamp plugin tester!"
687
    exit 1
688
fi
689

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

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

    
733
cat "$built" | while read dir; do
734
    package "$dir"
735
done
736

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

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

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

    
765
echo
766
echo "** Failed to build:"	    
767
cat "$notbuilt" | sort | while read dir; do
768
    slog=$(logfile_for summary "$dir")
769
    echo "$dir"
770
    echo "$dir: BUILD_FAILED: Failed to compile" >> "$slog"
771
done
772

    
773
echo