From 9b2f5c45119e1bbd89e03dc00fff3e22e116eca6 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Mon, 28 Nov 2005 15:38:55 +0000 Subject: [PATCH] Add a TeX emitter to cover removal of .aux and .log files. (Joel B. Mohler) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1398 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 ++ src/engine/SCons/Defaults.py | 6 ++-- src/engine/SCons/Tool/latex.py | 2 ++ src/engine/SCons/Tool/pdflatex.py | 2 ++ src/engine/SCons/Tool/pdftex.py | 1 + src/engine/SCons/Tool/tex.py | 6 ++++ test/TEX/LATEX.py | 52 ++++++++++++++++++++++--------- test/TEX/PDFLATEX.py | 42 +++++++++++++++++++------ test/TEX/PDFTEX.py | 34 +++++++++++++++----- test/TEX/TEX.py | 38 ++++++++++++++++------ 10 files changed, 143 insertions(+), 43 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index eead5e92..9b0154ca 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -469,6 +469,9 @@ RELEASE 0.97 - XXX when it's necessary, to call $MAKEINDEX when it's necessary, and to call $TEX or $LATEX multiple times to handle undefined references. + - Add an emitter to the various TeX builders so that the generated + .aux and .log files also get deleted by the -c option. + From Elliot Murphy: - Enhance the tests to guarantee persistence of ListOption diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index b5e09b34..e51c8704 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -132,14 +132,16 @@ def DVI(): # construction variable like $DVISUFFIX # because the output file name is # hard-coded within TeX. - suffix = '.dvi') + suffix = '.dvi', + emitter = {}) def PDF(): """A function for generating the PDF Builder.""" return SCons.Builder.Builder(action = { }, source_scanner = LaTeXScan, prefix = '$PDFPREFIX', - suffix = '$PDFSUFFIX') + suffix = '$PDFSUFFIX', + emitter = {}) # Common tasks that we allow users to perform in platform-independent # ways by creating ActionFactory instances. diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py index 45150aa4..c77461b4 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -58,6 +58,8 @@ def generate(env): bld.add_action('.ltx', LaTeXAuxAction) bld.add_action('.latex', LaTeXAuxAction) + bld.add_emitter('.ltx', SCons.Tool.tex.tex_emitter) + bld.add_emitter('.latex', SCons.Tool.tex.tex_emitter) env['LATEX'] = 'latex' env['LATEXFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index ce3ba670..3b7ac400 100644 --- a/src/engine/SCons/Tool/pdflatex.py +++ b/src/engine/SCons/Tool/pdflatex.py @@ -55,6 +55,8 @@ def generate(env): bld.add_action('.ltx', PDFLaTeXAuxAction) bld.add_action('.latex', PDFLaTeXAuxAction) + bld.add_emitter('.ltx', SCons.Tool.tex.tex_emitter) + bld.add_emitter('.latex', SCons.Tool.tex.tex_emitter) env['PDFLATEX'] = 'pdflatex' env['PDFLATEXFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py index 6606f0d2..a25f08bb 100644 --- a/src/engine/SCons/Tool/pdftex.py +++ b/src/engine/SCons/Tool/pdftex.py @@ -69,6 +69,7 @@ def generate(env): env['BUILDERS']['PDF'] = bld bld.add_action('.tex', PDFTeXLaTeXAction) + bld.add_emitter('.tex', SCons.Tool.tex.tex_emitter) env['PDFTEX'] = 'pdftex' env['PDFTEXFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index b444f766..8b80a027 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -121,6 +121,11 @@ def TeXLaTeXFunction(target = None, source= None, env=None): TeXAction(target,source,env) return 0 +def tex_emitter( target, source, env ): + target.append( os.path.splitext( SCons.Util.to_String(source[0]) )[0] + ".aux" ) + target.append( os.path.splitext( SCons.Util.to_String(source[0]) )[0] + ".log" ) + return (target, source) + TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction, strfunction=None) def generate(env): @@ -132,6 +137,7 @@ def generate(env): env['BUILDERS']['DVI'] = bld bld.add_action('.tex', TeXLaTeXAction) + bld.add_emitter('.tex', tex_emitter) env['TEX'] = 'tex' env['TEXFLAGS'] = SCons.Util.CLVar('') diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py index a9530fc8..25446961 100644 --- a/test/TEX/LATEX.py +++ b/test/TEX/LATEX.py @@ -24,6 +24,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Validate that we can set the LATEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + import os import os.path import string @@ -41,10 +47,14 @@ import sys import os base_name = os.path.splitext(sys.argv[1])[0] infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') +dvi_file = open(base_name+'.dvi', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') for l in infile.readlines(): if l[0] != '\\': - out_file.write(l) + dvi_file.write(l) + aux_file.write(l) + log_file.write(l) sys.exit(0) """) @@ -62,11 +72,25 @@ test.write('test2.latex', r"""This is a .latex test. \end """) -test.run(arguments = '.', stderr = None) +test.run(arguments = '.') + +test.must_match('test1.dvi', "This is a .ltx test.\n") +test.must_match('test1.aux', "This is a .ltx test.\n") +test.must_match('test1.log', "This is a .ltx test.\n") + +test.must_match('test2.dvi', "This is a .latex test.\n") +test.must_match('test2.aux', "This is a .latex test.\n") +test.must_match('test2.log', "This is a .latex test.\n") + +test.run(arguments = '-c .') -test.fail_test(test.read('test1.dvi') != "This is a .ltx test.\n") +test.must_not_exist('test1.dvi') +test.must_not_exist('test1.aux') +test.must_not_exist('test1.log') -test.fail_test(test.read('test2.dvi') != "This is a .latex test.\n") +test.must_not_exist('test2.dvi') +test.must_not_exist('test2.aux') +test.must_not_exist('test2.log') @@ -139,27 +163,27 @@ This is the include file. test.write('bar.latex', latex % 'bar.latex') - test.write('makeindex.tex', makeindex % 'makeindex.tex'); - test.write('makeindex.idx', ''); + test.write('makeindex.tex', makeindex % 'makeindex.tex') + test.write('makeindex.idx', '') test.subdir('subdir') test.write('latexi.tex', latex1 % 'latexi.tex'); test.write([ 'subdir', 'latexincludefile.tex'], latex2) test.run(arguments = 'foo.dvi', stderr = None) - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - test.fail_test(not os.path.exists(test.workpath('foo.dvi'))) + test.must_not_exist('wrapper.out') + test.must_exist('foo.dvi') test.run(arguments = 'bar.dvi', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) + test.must_match('wrapper.out', "wrapper.py\n") + test.must_exist('bar.dvi') test.run(arguments = 'makeindex.dvi', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n") test.run(arguments = 'latexi.dvi', stderr = None) - test.fail_test(not os.path.exists(test.workpath('latexi.dvi'))) - test.fail_test(not os.path.exists(test.workpath('latexi.ind'))) + test.must_exist('latexi.dvi') + test.must_exist('latexi.ind') diff --git a/test/TEX/PDFLATEX.py b/test/TEX/PDFLATEX.py index 5dcfd0b6..015db568 100644 --- a/test/TEX/PDFLATEX.py +++ b/test/TEX/PDFLATEX.py @@ -24,6 +24,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Validate that we can set the PDFLATEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + import os import os.path import string @@ -41,10 +47,14 @@ import sys import os base_name = os.path.splitext(sys.argv[1])[0] infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.pdf', 'wb') +pdf_file = open(base_name+'.pdf', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') for l in infile.readlines(): if l[0] != '\\': - out_file.write(l) + pdf_file.write(l) + aux_file.write(l) + log_file.write(l) sys.exit(0) """) @@ -62,11 +72,25 @@ test.write('test2.latex', r"""This is a .latex test. \end """) -test.run(arguments = '.', stderr = None) +test.run(arguments = '.') + +test.must_exist('test1.pdf') +test.must_exist('test1.aux') +test.must_exist('test1.log') + +test.must_exist('test2.pdf') +test.must_exist('test2.aux') +test.must_exist('test2.log') + +test.run(arguments = '-c .') -test.fail_test(not os.path.exists(test.workpath('test1.pdf'))) +test.must_not_exist('test1.pdf') +test.must_not_exist('test1.aux') +test.must_not_exist('test1.log') -test.fail_test(not os.path.exists(test.workpath('test2.pdf'))) +test.must_not_exist('test2.pdf') +test.must_not_exist('test2.aux') +test.must_not_exist('test2.log') @@ -104,14 +128,14 @@ This is the %s LaTeX file. test.run(arguments = 'foo.pdf', stderr = None) - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + test.must_not_exist('wrapper.out') - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + test.must_exist('foo.pdf') test.run(arguments = 'bar.pdf', stderr = None) - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + test.must_match('wrapper.out', "wrapper.py\n") - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + test.must_exist('bar.pdf') test.pass_test() diff --git a/test/TEX/PDFTEX.py b/test/TEX/PDFTEX.py index fa0d839c..5b99c230 100644 --- a/test/TEX/PDFTEX.py +++ b/test/TEX/PDFTEX.py @@ -24,6 +24,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Validate that we can set the PDFTEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + import os import os.path import string @@ -41,10 +47,14 @@ import sys import os base_name = os.path.splitext(sys.argv[1])[0] infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.pdf', 'wb') +pdf_file = open(base_name+'.pdf', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') for l in infile.readlines(): if l[0] != '\\': - out_file.write(l) + pdf_file.write(l) + aux_file.write(l) + log_file.write(l) sys.exit(0) """) @@ -57,9 +67,17 @@ test.write('test.tex', r"""This is a test. \end """) -test.run(arguments = 'test.pdf', stderr = None) +test.run(arguments = 'test.pdf') + +test.must_exist('test.pdf') +test.must_exist('test.aux') +test.must_exist('test.log') + +test.run(arguments = '-c test.pdf') -test.fail_test(not os.path.exists(test.workpath('test.pdf'))) +test.must_not_exist('test.pdf') +test.must_not_exist('test.aux') +test.must_not_exist('test.log') @@ -95,14 +113,14 @@ This is the %s TeX file. test.run(arguments = 'foo.pdf', stderr = None) - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + test.must_not_exist('wrapper.out') - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + test.must_exist('foo.pdf') test.run(arguments = 'bar.pdf', stderr = None) - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) + test.must_exist('wrapper.out') - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + test.must_exist('bar.pdf') test.pass_test() diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index a9708222..4645c7c6 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -24,6 +24,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Validate that we can set the TEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + import os import os.path import string @@ -41,10 +47,14 @@ import sys import os base_name = os.path.splitext(sys.argv[1])[0] infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') +dvi_file = open(base_name+'.dvi', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') for l in infile.readlines(): if l[0] != '\\': - out_file.write(l) + dvi_file.write(l) + aux_file.write(l) + log_file.write(l) sys.exit(0) """) @@ -57,9 +67,17 @@ test.write('test.tex', r"""This is a test. \end """) -test.run(arguments = 'test.dvi', stderr = None) +test.run(arguments = 'test.dvi') + +test.must_match('test.dvi', "This is a test.\n") +test.must_match('test.aux', "This is a test.\n") +test.must_match('test.log', "This is a test.\n") + +test.run(arguments = '-c test.dvi') -test.fail_test(test.read('test.dvi') != "This is a test.\n") +test.must_not_exist('test.dvi') +test.must_not_exist('test.aux') +test.must_not_exist('test.log') @@ -145,14 +163,14 @@ Run \texttt{latex}, then \texttt{bibtex}, then \texttt{latex} twice again \cite{ test.write('test.bib', bib) test.run(arguments = 'foo.dvi foo-latex.dvi', stderr = None) - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - test.fail_test(not os.path.exists(test.workpath('foo.dvi'))) - test.fail_test(not os.path.exists(test.workpath('foo-latex.dvi'))) + test.must_not_exist('wrapper.out') + test.must_exist('foo.dvi') + test.must_exist('foo-latex.dvi') test.run(arguments = 'bar.dvi bar-latex.dvi', stderr = None) - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) - test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) - test.fail_test(not os.path.exists(test.workpath('bar-latex.dvi'))) + test.must_exist('wrapper.out') + test.must_exist('bar.dvi') + test.must_exist('bar-latex.dvi') test.run(stderr = None) output_lines = string.split(test.stdout(), '\n') -- 2.26.2