-
Notifications
You must be signed in to change notification settings - Fork 20
/
check_plugouts.sh
executable file
·71 lines (60 loc) · 1.65 KB
/
check_plugouts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
#
# Ensure that configure enabled the plugouts as it was expected to.
#
# 2020-2022 (C) by Christian Garbs <mitch@cgarbs.de>
# Licensed under GNU GPL v1 or, at your option, any later version.
set -e
die()
{
echo "ERROR"
echo "$@"
echo
echo "dumping config.mk:"
cat config.mk
exit 1
}
is_contained_in()
{
local searched="$1" current
shift
for current in "$@"; do
if [ "$current" = "$searched" ]; then
return 0
fi
done
return 1
}
# these don't have dependencies and should always be built
declare -a expected_plugouts=( iodumper midi altmidi stdout vgm wav )
# additional plugouts are given as commandline parameters
expected_plugouts+=( $* )
# read configured plugouts
declare -a enabled_plugouts
while read -r prefixed_name _ state; do
name=${prefixed_name:8}
if [ "$state" = yes ]; then
enabled_plugouts+=( $name )
fi
done < <( grep ^plugout config.mk)
# dump status
echo "expected plugouts: ${expected_plugouts[@]}"
echo "checking config.mk"
# check that all expected plugouts are present
for expected in "${expected_plugouts[@]}"; do
printf 'check expected <%s> to be enabled .. ' "$expected"
if ! is_contained_in "$expected" "${enabled_plugouts[@]}"; then
die "expected plugout <$expected> has not been enabled by configure"
fi
echo "ok"
done
# check that no unexpected plugouts are present
for enabled in "${enabled_plugouts[@]}"; do
printf 'check enabled <%s> to be expected .. ' "$enabled"
if ! is_contained_in "$enabled" "${expected_plugouts[@]}" ; then
die "unexpected plugout <$enabled> has been enabled by configure"
fi
echo "ok"
done
# ok
echo "ok"