diff options
author | Robert Managan <managan1@llnl.gov> | 2009-07-22 04:56:52 (GMT) |
---|---|---|
committer | Robert Managan <managan1@llnl.gov> | 2009-07-22 04:56:52 (GMT) |
commit | 069ce5a194b250c09667606c2e926747f5f083aa (patch) | |
tree | e68c1126b8e261b55abe10e78067c59554330a8d /src | |
parent | 9915e5215af5dc08f58cfc91f08aabc1b8ae2cd5 (diff) | |
download | SCons-069ce5a194b250c09667606c2e926747f5f083aa.zip SCons-069ce5a194b250c09667606c2e926747f5f083aa.tar.gz SCons-069ce5a194b250c09667606c2e926747f5f083aa.tar.bz2 |
Update tex builder to use the -recorder option.
This was prompted because MikTeX, used on Windows,
does not put the same information on files opened
into the log file. The -recorder option gives a .fls
file that is the same on all platforms.
We still use the .log file contents to find warnings
and errors that mean we need to rerun latex...
Also add message about errors so user does not have
to scroll up through all the latex output to find
if there was an error.
Update all tests to handle the new command line option.
Add one more test on grpahics conversion.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Tool/latex.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdflatex.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdftex.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Tool/tex.py | 51 |
4 files changed, 50 insertions, 17 deletions
diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py index 234d3c0..36c4fd2 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -44,6 +44,8 @@ LaTeXAction = None def LaTeXAuxFunction(target = None, source= None, env=None): result = SCons.Tool.tex.InternalLaTeXAuxAction( LaTeXAction, target, source, env ) + if result != 0: + print env['LATEX']," returned an error, check the log file" return result LaTeXAuxAction = SCons.Action.Action(LaTeXAuxFunction, @@ -68,7 +70,7 @@ def generate(env): bld.add_emitter('.latex', SCons.Tool.tex.tex_eps_emitter) env['LATEX'] = 'latex' - env['LATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['LATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['LATEXCOM'] = 'cd ${TARGET.dir} && $LATEX $LATEXFLAGS ${SOURCE.file}' env['LATEXRETRIES'] = 3 diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index 6c37b46..81bdcd5 100644 --- a/src/engine/SCons/Tool/pdflatex.py +++ b/src/engine/SCons/Tool/pdflatex.py @@ -42,6 +42,8 @@ PDFLaTeXAction = None def PDFLaTeXAuxFunction(target = None, source= None, env=None): result = SCons.Tool.tex.InternalLaTeXAuxAction( PDFLaTeXAction, target, source, env ) + if result != 0: + print env['PDFLATEX']," returned an error, check the log file" return result PDFLaTeXAuxAction = None @@ -67,7 +69,7 @@ def generate(env): bld.add_emitter('.latex', SCons.Tool.tex.tex_pdf_emitter) env['PDFLATEX'] = 'pdflatex' - env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['PDFLATEXCOM'] = 'cd ${TARGET.dir} && $PDFLATEX $PDFLATEXFLAGS ${SOURCE.file}' env['LATEXRETRIES'] = 3 diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py index 308cb71..fc09bf4 100644 --- a/src/engine/SCons/Tool/pdftex.py +++ b/src/engine/SCons/Tool/pdftex.py @@ -53,8 +53,12 @@ def PDFTeXLaTeXFunction(target = None, source= None, env=None): program.""" if SCons.Tool.tex.is_LaTeX(source): result = PDFLaTeXAuxAction(target,source,env) + if result != 0: + print env['PDFLATEX']," returned an error, check the log file" else: result = PDFTeXAction(target,source,env) + if result != 0: + print env['PDFTEX']," returned an error, check the log file" return result PDFTeXLaTeXAction = None @@ -86,12 +90,12 @@ def generate(env): pdf.generate2(env) env['PDFTEX'] = 'pdftex' - env['PDFTEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['PDFTEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['PDFTEXCOM'] = 'cd ${TARGET.dir} && $PDFTEX $PDFTEXFLAGS ${SOURCE.file}' # Duplicate from latex.py. If latex.py goes away, then this is still OK. env['PDFLATEX'] = 'pdflatex' - env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['PDFLATEXCOM'] = 'cd ${TARGET.dir} && $PDFLATEX $PDFLATEXFLAGS ${SOURCE.file}' env['LATEXRETRIES'] = 3 diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 3473f8b..e1ecd81 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -58,8 +58,8 @@ all_suffixes = check_suffixes + ['.bbl', '.idx', '.nlo', '.glo'] # regular expressions used to search for Latex features # or outputs that require rerunning latex # -# search for all .aux files opened by latex (recorded in the .log file) -openout_aux_re = re.compile(r"\\openout.*`(.*\.aux)'") +# search for all .aux files opened by latex (recorded in the .fls file) +openout_aux_re = re.compile(r"INPUT *(.*\.aux)") #printindex_re = re.compile(r"^[^%]*\\printindex", re.MULTILINE) #printnomenclature_re = re.compile(r"^[^%]*\\printnomenclature", re.MULTILINE) @@ -96,7 +96,7 @@ include_re = re.compile(r'^[^%\n]*\\(?:include|input){([^}]*)}', re.MULTILINE) includegraphics_re = re.compile(r'^[^%\n]*\\(?:includegraphics(?:\[[^\]]+\])?){([^}]*)}', re.MULTILINE) # search to find all files opened by Latex (recorded in .log file) -openout_re = re.compile(r"\\openout.*`(.*)'") +openout_re = re.compile(r"OUTPUT *(.*)") # list of graphics file extensions for TeX and LaTeX TexGraphics = SCons.Scanner.LaTeX.TexGraphics @@ -256,13 +256,22 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None must_rerun_latex = False # Decide if various things need to be run, or run again. - # Read the log file to find all .aux files + # Read the log file to find warnings/errors logfilename = targetbase + '.log' logContent = '' - auxfiles = [] if os.path.exists(logfilename): logContent = open(logfilename, "rb").read() - auxfiles = openout_aux_re.findall(logContent) + + + # Read the fls file to find all .aux files + flsfilename = targetbase + '.fls' + flsContent = '' + auxfiles = [] + if os.path.exists(flsfilename): + flsContent = open(flsfilename, "rb").read() + auxfiles = openout_aux_re.findall(flsContent) + if Verbose: + print "auxfiles ",auxfiles # Now decide if bibtex will need to be run. # The information that bibtex reads from the .aux file is @@ -280,6 +289,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None bibfile = env.fs.File(targetbase) result = BibTeXAction(bibfile, bibfile, env) if result != 0: + print env['BIBTEX']," returned an error, check the blg file" return result must_rerun_latex = check_MD5(suffix_nodes['.bbl'],'.bbl') break @@ -292,6 +302,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None idxfile = suffix_nodes['.idx'] result = MakeIndexAction(idxfile, idxfile, env) if result != 0: + print env['MAKEINDEX']," returned an error, check the ilg file" return result # TO-DO: need to add a way for the user to extend this list for whatever @@ -309,6 +320,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None nclfile = suffix_nodes['.nlo'] result = MakeNclAction(nclfile, nclfile, env) if result != 0: + print env['MAKENCL']," (nomenclature) returned an error, check the nlg file" return result # Now decide if latex will need to be run again due to glossary. @@ -319,6 +331,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None glofile = suffix_nodes['.glo'] result = MakeGlossaryAction(glofile, glofile, env) if result != 0: + print env['MAKEGLOSSARY']," (glossary) returned an error, check the glg file" return result # Now decide if latex needs to be run yet again to resolve warnings. @@ -388,8 +401,12 @@ def TeXLaTeXFunction(target = None, source= None, env=None): program.""" if is_LaTeX(source): result = LaTeXAuxAction(target,source,env) + if result != 0: + print env['LATEX']," returned an error, check the log file" else: result = TeXAction(target,source,env) + if result != 0: + print env['TEX']," returned an error, check the log file" return result def TeXLaTeXStrFunction(target = None, source= None, env=None): @@ -456,7 +473,7 @@ def tex_emitter_core(target, source, env, graphics_extensions): are needed on subsequent runs of latex to finish tables of contents, bibliographies, indices, lists of figures, and hyperlink references. """ - targetbase = SCons.Util.splitext(str(target[0]))[0] + targetbase, targetext = SCons.Util.splitext(str(target[0])) basename = SCons.Util.splitext(str(source[0]))[0] basefile = os.path.split(str(basename))[1] @@ -471,11 +488,14 @@ def tex_emitter_core(target, source, env, graphics_extensions): emit_suffixes = ['.aux', '.log', '.ilg', '.blg', '.nls', '.nlg', '.gls', '.glg'] + all_suffixes auxfilename = targetbase + '.aux' logfilename = targetbase + '.log' + flsfilename = targetbase + '.fls' env.SideEffect(auxfilename,target[0]) env.SideEffect(logfilename,target[0]) + env.SideEffect(flsfilename,target[0]) env.Clean(target[0],auxfilename) env.Clean(target[0],logfilename) + env.Clean(target[0],flsfilename) content = source[0].get_text_contents() @@ -545,10 +565,15 @@ def tex_emitter_core(target, source, env, graphics_extensions): env.SideEffect(targetbase + suffix,target[0]) env.Clean(target[0],targetbase + suffix) - # read log file to get all other files that latex creates and will read on the next pass - if os.path.exists(logfilename): - content = open(logfilename, "rb").read() + # read fls file to get all other files that latex creates and will read on the next pass + if os.path.exists(flsfilename): + content = open(flsfilename, "rb").read() out_files = openout_re.findall(content) + mysuffixes = ['.log' , '.fls' , targetext] + for filename in out_files: + base,ext = SCons.Util.splitext(filename) + if ext in mysuffixes: + out_files.remove(filename) env.SideEffect(out_files,target[0]) env.Clean(target[0],out_files) @@ -604,12 +629,12 @@ def generate(env): bld.add_emitter('.tex', tex_eps_emitter) env['TEX'] = 'tex' - env['TEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['TEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['TEXCOM'] = 'cd ${TARGET.dir} && $TEX $TEXFLAGS ${SOURCE.file}' # Duplicate from latex.py. If latex.py goes away, then this is still OK. env['LATEX'] = 'latex' - env['LATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['LATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['LATEXCOM'] = 'cd ${TARGET.dir} && $LATEX $LATEXFLAGS ${SOURCE.file}' env['LATEXRETRIES'] = 3 @@ -633,7 +658,7 @@ def generate(env): # Duplicate from pdflatex.py. If latex.py goes away, then this is still OK. env['PDFLATEX'] = 'pdflatex' - env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode') + env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder') env['PDFLATEXCOM'] = 'cd ${TARGET.dir} && $PDFLATEX $PDFLATEXFLAGS ${SOURCE.file}' def exists(env): |