forked from lojban/cll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cll_build
executable file
·121 lines (94 loc) · 2.65 KB
/
cll_build
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
usage() {
echo "
Usage: $0 [-c] [-s] [-t] [-T target] [chapters]
-s: Replaces external xrefs in each chapter, so each chapter works standalone.
-t: Does what -s does, but also prevents most glossary processing so the glossary building goes much faster.
-c: Coverage mode. Instead of using the normal chapter data, runs a special small file that is designed to do everything we ever do, but runs very quickly. In this case, the 'chapters' argument is one or more coverage types to run. Possible coverage types:
$(ls $(pwd)/coverage/*.xml | xargs -n 1 basename | sed 's/^coverage_//' | sed 's/\.xml$//')
-T target: Specifies the make target. Most of them are obvious. The _web targets copy stuff into your ~/public_html/ web space. Complete list:
$(grep '^[a-z][a-z_]*:' scripts/Makefile | sed 's/:.*//' | sed 's/^/ /')
[chapters]: defaults to all chapters; if you specify less than all chapters, you must use -s or -t
"
exit 1
}
optlist=""
run_chapters=""
coverage=""
builddir="$(pwd)/build"
target="all"
while getopts "csthT:" opt
do
case "$opt" in
c) coverage="true"
run_chapters="true"
;;
s) optlist="$optlist -s"
run_chapters="true"
;;
t) optlist="$optlist -t"
run_chapters="true"
;;
T) target="$OPTARG";;
[?h]) usage;;
esac
done
if [ $OPTIND -gt 1 ]
then
shift $(expr $OPTIND - 1)
fi
chapters="$*"
if [ "$target" = "coverage" -a "$optlist" ]
then
echo "
Coverage is special; give no other options.
"
usage
fi
if [ "$chapters" -a ! "$run_chapters" ]
then
echo "
Since you specified chapters, you need to specify -s or -t. -t is faster.
"
usage
fi
# Set up defaults
if [ ! "$chapters" ]
then
chapters="$(ls chapters/* | tr '\012' ' ')"
fi
if [ "$coverage" ]
then
target="coverage"
test=""
new_chapters=""
for chapter in $chapters
do
chap="coverage/coverage_$chapter.xml"
if [ -f "$chap" ]
then
new_chapters="$new_chapters $chap"
else
echo "$chapter is not a valid coverage type"
exit 1
fi
done
chapters=$new_chapters
builddir="$(pwd)/coverage/build"
fi
echo "chapters: $chapters"
echo "optlist: $optlist"
echo "target: $target"
# See if we need to delete the cll.xml before we run make
echo "$optlist $chapters" >build/chapter-list.new
if [ ! -f build/chapter-list ]
then
touch build/chapter-list
fi
if [ "$(diff -q build/chapter-list build/chapter-list.new)" ]
then
cp build/chapter-list.new build/chapter-list
echo -e "\nChapter list differences found; forcing a re-merge.\n"
rm -f cll.xml
fi
make -f scripts/Makefile builddir="$builddir" test="$optlist" chapters="$chapters" $target