summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-05-29 20:58:57 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-19 21:32:10 +0200
commitf8eb8c8679633d43e3c1e0d95feb2dab2d5cee8a (patch)
tree657adbd496f5d189d13be9fb3ae4fd9b60b7351e
parent3d0c787a48ff0d26fa5a1e93a4ca237df8999acf (diff)
downloadrockbox-f8eb8c8.tar.gz
rockbox-f8eb8c8.tar.bz2
rockbox-f8eb8c8.zip
Filter LaTeX output for errors.
Pipe the output of LaTeX through a Perl script and filter out information that is irrelevant in deciding if building the manual actually worked. Format errors in a similar way to gcc output to allow existing scripts catching it. Enabling verbose output during the make run will not remove parts of the output but only do some reflowing. The full log is always available in the manual subfolder. Change-Id: I15d35b4d3c73fafe2a4357168ca8ada51355f221 Reviewed-on: http://gerrit.rockbox.org/247 Reviewed-by: Dominik Riebeling <Dominik.Riebeling@gmail.com> Tested-by: Dominik Riebeling <Dominik.Riebeling@gmail.com>
-rw-r--r--manual/LaTeX.Rules12
-rwxr-xr-xmanual/latexfilter.pl62
2 files changed, 72 insertions, 2 deletions
diff --git a/manual/LaTeX.Rules b/manual/LaTeX.Rules
index 5a1e58589a..cfe43b055c 100644
--- a/manual/LaTeX.Rules
+++ b/manual/LaTeX.Rules
@@ -119,6 +119,14 @@ OTHER_FILES := $(DOCUMENT).blg $(DOCUMENT).log $(DOCUMENT).out
INDEX_ARGS := -s mkidx.ist
LATEXOPTS := -interaction=nonstopmode
+# program to pipe stdout through. Note: this needs to start with a pipe symbol
+# to not make the command fail if no filter is defined.
+ifndef V
+LATEXFILTER := | ./latexfilter.pl
+else
+LATEXFILTER := | ./latexfilter.pl -v
+endif
+
# grab the contents of \bibliograph{} commands
ifeq ($(BIB_FILES),)
BIB_FILES := $(shell for source in $(TEX_FILES) ; do sed -e '{' -e 'y/,/ /' -e 's?.*\\bibliography[{]\(.*\)[}].*?\1?' -e 't' -e 'd' -e '}' <$$source ; done)
@@ -222,7 +230,7 @@ define run-latex
makeobsolete() { touch -r $$(ls *.old | tail -n 1) $${1} ; true ; } ; \
nochange() { for file ; do [ ! -f $${1} ] || cmp $${1} $${1}.old >/dev/null || return ; done ; true ; } ; \
saveold $(MONITOR_FILES) ; \
- if $(LATEX) $(LATEXOPTS) $* ; then \
+ if $(LATEX) $(LATEXOPTS) $* $(LATEXFILTER) ; then \
if nochange $(MONITOR_FILES) ; then \
echo "$(MAKE): LaTeX auxiliary files did not change (processing is complete)" ; \
restoreold $(MONITOR_FILES) ; \
@@ -267,7 +275,7 @@ $(PDF_FILE) : %.pdf : $(TEX_FILES) $(MONITOR_FILES) $(GRAPHIC_FILES) $(XFIG_TEX)
#
%.aux %.idx : $(XFIG_TEX)
- $(LATEX) $(LATEXOPTS) $*
+ $(LATEX) $(LATEXOPTS) $* $(LATEXFILTER)
#
# Distill xfig .fig files into .fig.tex and either .fig.pdf or .fig.ps
diff --git a/manual/latexfilter.pl b/manual/latexfilter.pl
new file mode 100755
index 0000000000..45d7cedbdc
--- /dev/null
+++ b/manual/latexfilter.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/perl -s
+#
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+#
+
+my $verbose = $v;
+my $reflowed = "";
+my $last = "";
+my $currentfile;
+while(<STDIN>) {
+ chomp $_;
+ $reflowed .= $_;
+ if(/^.{79,}$/) {
+ # collapse all "full" lines
+ }
+ elsif(/^!/) {
+ # collapse lines indicating an error with next one and append a space.
+ $reflowed .= " ";
+ }
+ else {
+ # skip empty lines
+ if(length($reflowed) > 0) {
+ # collapse with previous line if it continues some "area".
+ if($reflowed =~ /^\s*(\]|\[|\\|\)|<)/) {
+ $last .= $reflowed;
+ }
+ else {
+ # find current input file
+ my @inputfile = $last =~ /\(([a-zA-Z_\-\/\.]+\.tex)/g;
+ foreach(@inputfile) {
+ if($verbose) {
+ print "\n";
+ }
+ print "LaTeX processing $_\n";
+ $currentfile = $_;
+ }
+ if($verbose) {
+ print $last;
+ }
+ # check for error
+ if($reflowed =~ /^!\s*(.*)/) {
+ my $l = $reflowed;
+ $l =~ s/^!\s*(.*)l.(\d+) /$2: $1/;
+ print "$currentfile:$l\n";
+ }
+ # restart for next reflowed line
+ $last = $reflowed;
+ }
+ }
+ # restart reflowing.
+ $reflowed = "";
+ }
+}
+if($verbose) {
+ print $last;
+}
+