-
Notifications
You must be signed in to change notification settings - Fork 6
/
update-modules.sh
executable file
·85 lines (67 loc) · 1.83 KB
/
update-modules.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
EXTERNALDEPS_FILE=source/dentist/modules.d
#!/bin/bash
function main()
{
echo -n 'Updating `dentist.modules` ... '
get_updated_modules "$EXTERNALDEPS_FILE" > "$EXTERNALDEPS_FILE~"
if ! cmp -s "$EXTERNALDEPS_FILE" "$EXTERNALDEPS_FILE~";
then
mv "$EXTERNALDEPS_FILE~" "$EXTERNALDEPS_FILE"
echo 'done'
else
echo 'skipped'
fi
}
function get_updated_modules()
{
MODULES=($(
find source -name '*.d' |
xargs grep -hE '^module [^;]+;$' |
sed -E 's/^module\s+([^;]+);$/\1/' |
# NOTE: `app` module is excluded to fix linker error in unit tests;
# it is irrelevant anyway. :o)
grep -vE '^app$' |
LC_ALL=C sort
))
echo "/**"
echo " This module lists all modules in DENTIST. This is used to derive a list of"
echo " all external dependencies in DENTIST."
echo
echo " DO NOT EDIT! This file is generated by \`update-modules.sh\`."
echo
echo " See_also: \`dentist.common.external.externalDependencies\`"
echo " Copyright: © 2018 Arne Ludwig <[email protected]>"
echo " License: Subject to the terms of the MIT license, as written in the"
echo " included LICENSE file."
echo " Authors: Arne Ludwig <[email protected]>"
echo "*/"
echo "module dentist.modules;"
echo
echo
echo "import std.meta : AliasSeq;"
for MODULE in ${MODULES[*]};
do
echo "static import $MODULE;"
done
echo
echo
echo "alias modules = AliasSeq!("
for MODULE in ${MODULES[*]};
do
echo " $MODULE,"
done
echo ");"
}
function clean_up()
{
rm -f "$EXTERNALDEPS_FILE~"
}
function on_error()
{
echo failed
}
trap clean_up EXIT
trap on_error ERR
set -e # exit when any command fails
main