]> git.saurik.com Git - wxWidgets.git/blob - build/buildbot/tools/check.sh
Register multibutton editor class in frame ctor instead of CreateGrid() (this fixes...
[wxWidgets.git] / build / buildbot / tools / check.sh
1 #!/bin/sh
2 #############################################################################
3 # Name: check.sh
4 # Purpose: Offline checker for the buildbot configuration files
5 # Author: Mike Wetherell
6 # RCS-ID: $Id$
7 # Copyright: (c) 2007 Mike Wetherell
8 # Licence: wxWidgets licence
9 #############################################################################
10
11 usage() {
12 echo "Usage: $0 [options] FILE..."
13 echo "Offline checker for the buildbot configuration files"
14 echo
15 echo "Options:"
16 echo " -g generate xslt"
17 echo " -h show help"
18 echo " -l N output only line N"
19 echo " -p preprocess"
20 echo " -v validate"
21 exit 0
22 }
23
24 badopt() {
25 echo "try '$0 -h' for more information" >&2
26 exit 1
27 }
28
29 progcheck() {
30 prog="$1"
31 $prog --version >/dev/null 2>&1 || {
32 echo "$0: requires $prog, not found" >&2
33 exit 1
34 }
35 }
36
37 GENERATE=1
38 PREPROCESS=2
39 VALIDATE=3
40
41 MODE=$VALIDATE
42 FILTER=cat
43
44 while getopts ghl:pv opt; do
45 case "$opt" in
46 \?) badopt ;;
47 g) MODE=$GENERATE ;;
48 h) usage ;;
49 l) FILTER="sed -ne ${OPTARG}p" ;;
50 p) MODE=$PREPROCESS ;;
51 v) MODE=$VALIDATE ;;
52 esac
53 done
54
55 if [ $OPTIND -gt 1 ]; then
56 shift `expr $OPTIND - 1`
57 fi
58
59 if [ $# -eq 0 ]; then
60 usage
61 fi
62
63 XSLTPROC=xsltproc
64 XMLLINT=xmllint
65
66 progcheck $XSLTPROC
67 progcheck $XMLLINT
68
69 DIR="`dirname $0`"
70 WORKDIR="${TMPDIR:-/tmp}/wx.$$"
71 mkdir "$WORKDIR" || exit
72 trap 'rm -rf "$WORKDIR"' EXIT
73 WORKPAT=`echo "$WORKDIR" | sed 's|[^A-Za-z0-9]/|.|g'`
74 XSLT="$WORKDIR/XSLT"
75 PREP="$WORKDIR/PREP"
76 STDERR="$WORKDIR/STDERR"
77 ERR=0
78
79 # Filter to show lines of genertated XSLT when they are mentioned.
80 showxslt() {
81 awk '{
82 print;
83 if (sub(/.*generated XSLT line */, "") && sub(/[^0-9].*/, ""))
84 {
85 system("sed -ne "$0"p '$XSLT'");
86 }
87 }'
88 }
89
90 # Test it works as old version of awk don't have sub or system functions.
91 if showxslt </dev/null 2>/dev/null; then
92 SHOWXSLT=showxslt
93 else
94 SHOWXSLT=cat
95 fi
96
97 # Change the names of the temporary files in an error message to something
98 # to something more informative
99 errout()
100 {
101 NAME="$1"
102
103 if [ -s "$STDERR" ]; then
104 sed "s|file ${WORKPAT}|${WORKPAT}|g;\
105 s|${WORKPAT}/XSLT|generated XSLT|g;\
106 s|${WORKPAT}/PREP|$NAME (preprocessed)|g" "$STDERR" | $SHOWXSLT
107 fi
108 }
109
110 output()
111 {
112 $FILTER "$1"
113 }
114
115 generate()
116 {
117 INPUT="$1"
118
119 if $XSLTPROC --xinclude -o "$XSLT" $DIR/embedded.xsl "$INPUT" 2>"$STDERR" &&
120 test \! -s "$STDERR"
121 then
122 if [ $MODE -eq $GENERATE ]; then
123 output "$XSLT"
124 fi
125 else
126 return 1
127 fi
128 }
129
130 preprocess()
131 {
132 INPUT="$1"
133
134 if [ $MODE -lt $PREPROCESS ]; then
135 return 0
136 fi
137
138 if $XSLTPROC --xinclude -o "$PREP" "$XSLT" "$INPUT" 2>"$STDERR" &&
139 test \! -s "$STDERR"
140 then
141 if [ $MODE -eq $PREPROCESS ]; then
142 output "$PREP"
143 fi
144 else
145 return 1
146 fi
147 }
148
149 validate()
150 {
151 NAME="$1"
152
153 if [ $MODE -lt $VALIDATE ]; then
154 return 0
155 fi
156
157 if $XMLLINT --noout --schema $DIR/bot.xsd "$PREP" 2>"$STDERR"
158 then
159 errout "$NAME"
160 else
161 return 1
162 fi
163 }
164
165 while [ $# -gt 0 ]; do
166 INPUT="$1"
167 NAME="`echo \"$INPUT\" | sed 's/[|\]/\\\&/g'`"
168
169 {
170 generate "$INPUT" &&
171 preprocess "$INPUT" &&
172 validate "$NAME"
173 } || {
174 errout "$NAME" >&2
175 ERR=1
176 }
177
178 rm -f "$XSLT" "$PREP" "$STDERR"
179
180 shift
181 done
182
183 exit $ERR