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>
This commit is contained in:
Dominik Riebeling 2012-05-29 20:58:57 +02:00
parent 3d0c787a48
commit f8eb8c8679
2 changed files with 72 additions and 2 deletions

View file

@ -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

62
manual/latexfilter.pl Executable file
View file

@ -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;
}