X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8ab43d1ba8ac134b4b077261e68f1051d089c67d..7505b72ead138a4c33c67479bc0db51500b63576:/build/buildbot/tools/check.sh?ds=sidebyside diff --git a/build/buildbot/tools/check.sh b/build/buildbot/tools/check.sh index 0a734558d1..4dd91096b1 100755 --- a/build/buildbot/tools/check.sh +++ b/build/buildbot/tools/check.sh @@ -1,7 +1,7 @@ #!/bin/sh ############################################################################# # Name: check.sh -# Purpose: Check embedded xslt +# Purpose: Offline checker for the buildbot configuration files # Author: Mike Wetherell # RCS-ID: $Id$ # Copyright: (c) 2007 Mike Wetherell @@ -10,7 +10,7 @@ usage() { echo "Usage: $0 [options] FILE..." - echo "Check embedded xslt" + echo "Offline checker for the buildbot configuration files" echo echo "Options:" echo " -g generate xslt" @@ -26,6 +26,14 @@ badopt() { exit 1 } +progcheck() { + prog="$1" + $prog --version >/dev/null 2>&1 || { + echo "$0: requires $prog, not found" >&2 + exit 1 + } +} + GENERATE=1 PREPROCESS=2 VALIDATE=3 @@ -52,6 +60,12 @@ if [ $# -eq 0 ]; then usage fi +XSLTPROC=xsltproc +XMLLINT=xmllint + +progcheck $XSLTPROC +progcheck $XMLLINT + DIR="`dirname $0`" WORKDIR="${TMPDIR:-/tmp}/wx.$$" mkdir "$WORKDIR" || exit @@ -62,6 +76,24 @@ PREP="$WORKDIR/PREP" STDERR="$WORKDIR/STDERR" ERR=0 +# Filter to show lines of genertated XSLT when they are mentioned. +showxslt() { + awk '{ + print; + if (sub(/.*generated XSLT line */, "") && sub(/[^0-9].*/, "")) + { + system("sed -ne "$0"p '$XSLT'"); + } + }' +} + +# Test it works as old version of awk don't have sub or system functions. +if showxslt /dev/null; then + SHOWXSLT=showxslt +else + SHOWXSLT=cat +fi + # Change the names of the temporary files in an error message to something # to something more informative errout() @@ -71,14 +103,7 @@ errout() if [ -s "$STDERR" ]; then sed "s|file ${WORKPAT}|${WORKPAT}|g;\ s|${WORKPAT}/XSLT|generated XSLT|g;\ - s|${WORKPAT}/PREP|$NAME (preprocessed)|g" "$STDERR" | - awk '{ - print; - if (sub(/.*generated XSLT line */, "") && sub(/[^0-9].*/, "")) - { - system("sed -ne "$0"p '$XSLT'"); - } - }' + s|${WORKPAT}/PREP|$NAME (preprocessed)|g" "$STDERR" | $SHOWXSLT fi } @@ -91,7 +116,7 @@ generate() { INPUT="$1" - if xsltproc --xinclude -o "$XSLT" $DIR/embedded.xsl "$INPUT" 2>"$STDERR" && + if $XSLTPROC --xinclude -o "$XSLT" $DIR/embedded.xsl "$INPUT" 2>"$STDERR" && test \! -s "$STDERR" then if [ $MODE -eq $GENERATE ]; then @@ -110,7 +135,7 @@ preprocess() return 0 fi - if xsltproc --xinclude -o "$PREP" "$XSLT" "$INPUT" 2>"$STDERR" && + if $XSLTPROC --xinclude -o "$PREP" "$XSLT" "$INPUT" 2>"$STDERR" && test \! -s "$STDERR" then if [ $MODE -eq $PREPROCESS ]; then @@ -120,7 +145,7 @@ preprocess() return 1 fi } - + validate() { NAME="$1" @@ -129,7 +154,7 @@ validate() return 0 fi - if xmllint --noout --schema $DIR/bot.xsd "$PREP" 2>"$STDERR" + if $XMLLINT --noout --schema $DIR/bot.xsd "$PREP" 2>"$STDERR" then errout "$NAME" else @@ -149,7 +174,7 @@ while [ $# -gt 0 ]; do errout "$NAME" >&2 ERR=1 } - + rm -f "$XSLT" "$PREP" "$STDERR" shift