From: stevenknight Date: Fri, 16 Dec 2005 12:16:00 +0000 (+0000) Subject: Fix DVIPDF tests, refactor various TeX Tool modules. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8e62806786ccf292e0e6f0998d9564ca0c3e4b2a;p=scons.git Fix DVIPDF tests, refactor various TeX Tool modules. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1403 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/MANIFEST-xml.in b/src/engine/MANIFEST-xml.in index e360a1af..c43f2109 100644 --- a/src/engine/MANIFEST-xml.in +++ b/src/engine/MANIFEST-xml.in @@ -21,6 +21,7 @@ SCons/Tool/CVS.xml SCons/Tool/c++.xml SCons/Tool/default.xml SCons/Tool/dmd.xml +SCons/Tool/dvi.xml SCons/Tool/dvipdf.xml SCons/Tool/dvips.xml SCons/Tool/f77.xml @@ -62,6 +63,7 @@ SCons/Tool/msvs.xml SCons/Tool/mwcc.xml SCons/Tool/mwld.xml SCons/Tool/nasm.xml +SCons/Tool/pdf.xml SCons/Tool/pdflatex.xml SCons/Tool/pdftex.xml SCons/Tool/Perforce.xml diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in index 3f33b58b..9d6c9721 100644 --- a/src/engine/MANIFEST.in +++ b/src/engine/MANIFEST.in @@ -70,6 +70,7 @@ SCons/Tool/cvf.py SCons/Tool/CVS.py SCons/Tool/dmd.py SCons/Tool/default.py +SCons/Tool/dvi.py SCons/Tool/dvipdf.py SCons/Tool/dvips.py SCons/Tool/f77.py @@ -111,6 +112,7 @@ SCons/Tool/msvs.py SCons/Tool/mwcc.py SCons/Tool/mwld.py SCons/Tool/nasm.py +SCons/Tool/pdf.py SCons/Tool/pdflatex.py SCons/Tool/pdftex.py SCons/Tool/Perforce.py diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index e51c8704..6b9b1150 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -124,25 +124,6 @@ ShLinkAction = SCons.Action.Action("$SHLINKCOM", "$SHLINKCOMSTR") LdModuleLinkAction = SCons.Action.Action("$LDMODULECOM", "$LDMODULECOMSTR") -def DVI(): - """Common function to generate a DVI file Builder.""" - return SCons.Builder.Builder(action = {}, - source_scanner = LaTeXScan, - # The suffix is not configurable via a - # construction variable like $DVISUFFIX - # because the output file name is - # hard-coded within TeX. - suffix = '.dvi', - emitter = {}) - -def PDF(): - """A function for generating the PDF Builder.""" - return SCons.Builder.Builder(action = { }, - source_scanner = LaTeXScan, - prefix = '$PDFPREFIX', - suffix = '$PDFSUFFIX', - emitter = {}) - # Common tasks that we allow users to perform in platform-independent # ways by creating ActionFactory instances. ActionFactory = SCons.Action.ActionFactory @@ -357,10 +338,6 @@ ConstructionEnvironment = { 'DSUFFIXES' : SCons.Tool.DSuffixes, 'IDLSUFFIXES' : SCons.Tool.IDLSuffixes, 'LATEXSUFFIXES' : SCons.Tool.LaTeXSuffixes, - 'PDFPREFIX' : '', - 'PDFSUFFIX' : '.pdf', - 'PSPREFIX' : '', - 'PSSUFFIX' : '.ps', 'ENV' : {}, 'INSTALL' : copyFunc, '_concat' : _concat, diff --git a/src/engine/SCons/Defaults.xml b/src/engine/SCons/Defaults.xml index 84dfe589..fea7c044 100644 --- a/src/engine/SCons/Defaults.xml +++ b/src/engine/SCons/Defaults.xml @@ -4,78 +4,6 @@ __COPYRIGHT__ This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. --> - - -Builds a .dvi file -from a .tex, -.ltx or .latex input file. -If the source file suffix is .tex, -&scons; -will examine the contents of the file; -if the string -\documentclass -or -\documentstyle -is found, the file is assumed to be a LaTeX file and -the target is built by invoking the &cv-LATEXCOM; command line; -otherwise, the &cv-TEXCOM; command line is used. -If the file is a LaTeX file, -the -&b-DVI; -builder method will also examine the contents -of the -.aux -file and invoke the &cv-BIBTEX; command line -if the string -bibdata -is found, -start &cv-MAKEINDEX; to generate an index if a -.ind -file is found -and will examine the contents -.log -file and re-run the &cv-LATEXCOM; command -if the log file says it is necessary. - -The suffix .dvi -(hard-coded within TeX itself) -is automatically added to the target -if it is not already present. -Examples: - - -# builds from aaa.tex -env.DVI(target = 'aaa.dvi', source = 'aaa.tex') -# builds bbb.dvi -env.DVI(target = 'bbb', source = 'bbb.ltx') -# builds from ccc.latex -env.DVI(target = 'ccc.dvi', source = 'ccc.latex') - - - - - - -Builds a .pdf file -from a .dvi input file -(or, by extension, a .tex, -.ltx, -or -.latex input file). -The suffix specified by the &cv-PDFSUFFIX; construction variable -(.pdf by default) -is added automatically to the target -if it is not already present. Example: - - -# builds from aaa.tex -env.PDF(target = 'aaa.pdf', source = 'aaa.tex') -# builds bbb.pdf from bbb.dvi -env.PDF(target = 'bbb', source = 'bbb.dvi') - - - - A function used to produce variables like &cv-_CPPINCFLAGS;. It takes @@ -536,18 +464,6 @@ all the libraries in this list. - - -The prefix used for PDF file names. - - - - - -The suffix used for PDF file names. - - - A function that converts a string into a list of Dir instances by diff --git a/src/engine/SCons/Tool/dvi.py b/src/engine/SCons/Tool/dvi.py new file mode 100644 index 00000000..1be710c1 --- /dev/null +++ b/src/engine/SCons/Tool/dvi.py @@ -0,0 +1,57 @@ +"""SCons.Tool.dvi + +Common DVI Builder definition for various other Tool modules that use it. + +""" + +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import SCons.Builder +import SCons.Tool + +DVIBuilder = None + +def generate(env): + try: + bld = env['BUILDERS']['DVI'] + except KeyError: + global DVIBuilder + + if DVIBuilder is None: + # The suffix is hard-coded to '.dvi', not configurable via a + # construction variable like $DVISUFFIX, because the output + # file name is hard-coded within TeX. + DVIBuilder = SCons.Builder.Builder(action = {}, + source_scanner = SCons.Tool.LaTeXScanner, + suffix = '.dvi', + emitter = {}) + + env['BUILDERS']['DVI'] = DVIBuilder + +def exists(env): + # This only puts a skeleton Builder in place, so if someone + # references this Tool directly, it's always "available." + return 1 diff --git a/src/engine/SCons/Tool/dvi.xml b/src/engine/SCons/Tool/dvi.xml new file mode 100644 index 00000000..9d3110e2 --- /dev/null +++ b/src/engine/SCons/Tool/dvi.xml @@ -0,0 +1,56 @@ + + + +Builds a .dvi file +from a .tex, +.ltx or .latex input file. +If the source file suffix is .tex, +&scons; +will examine the contents of the file; +if the string +\documentclass +or +\documentstyle +is found, the file is assumed to be a LaTeX file and +the target is built by invoking the &cv-LATEXCOM; command line; +otherwise, the &cv-TEXCOM; command line is used. +If the file is a LaTeX file, +the +&b-DVI; +builder method will also examine the contents +of the +.aux +file and invoke the &cv-BIBTEX; command line +if the string +bibdata +is found, +start &cv-MAKEINDEX; to generate an index if a +.ind +file is found +and will examine the contents +.log +file and re-run the &cv-LATEXCOM; command +if the log file says it is necessary. + +The suffix .dvi +(hard-coded within TeX itself) +is automatically added to the target +if it is not already present. +Examples: + + +# builds from aaa.tex +env.DVI(target = 'aaa.dvi', source = 'aaa.tex') +# builds bbb.dvi +env.DVI(target = 'bbb', source = 'bbb.ltx') +# builds from ccc.latex +env.DVI(target = 'ccc.dvi', source = 'ccc.latex') + + + + diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index 1ffb655c..bade8ff2 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -35,18 +35,34 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action import SCons.Defaults +import SCons.Tool.pdf import SCons.Util -PDFAction = SCons.Action.Action('$DVIPDFCOM', '$DVIPDFCOMSTR') +PDFAction = None + +def PDFEmitter(target, source, env): + """Strips any .aux or .log files from the input source list. + These are created by the TeX Builder that in all likelihood was + used to generate the .dvi file we're using as input, and we only + care about the .dvi file. + """ + def strip_suffixes(n): + return not SCons.Util.splitext(str(n))[1] in ['.aux', '.log'] + source = filter(strip_suffixes, source) + return (target, source) def generate(env): """Add Builders and construction variables for dvipdf to an Environment.""" - try: - bld = env['BUILDERS']['PDF'] - except KeyError: - bld = SCons.Defaults.PDF() - env['BUILDERS']['PDF'] = bld + global PDFAction + if PDFAction is None: + PDFAction = SCons.Action.Action('$DVIPDFCOM', '$DVIPDFCOMSTR') + + import pdf + pdf.generate(env) + + bld = env['BUILDERS']['PDF'] bld.add_action('.dvi', PDFAction) + bld.add_emitter('.dvi', PDFEmitter) env['DVIPDF'] = 'dvipdf' env['DVIPDFFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py index 02db5ca3..b987ea12 100644 --- a/src/engine/SCons/Tool/dvips.py +++ b/src/engine/SCons/Tool/dvips.py @@ -35,24 +35,32 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action import SCons.Builder -import SCons.Defaults import SCons.Util -PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') - -PostScript = SCons.Builder.Builder(action = PSAction, - prefix = '$PSPREFIX', - suffix = '$PSSUFFIX', - src_suffix = '.dvi', - src_builder = 'DVI') +PSAction = None +PSBuilder = None def generate(env): """Add Builders and construction variables for dvips to an Environment.""" - env['BUILDERS']['PostScript'] = PostScript + global PSAction + if PSAction is None: + PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') + + global PSBuilder + if PSBuilder is None: + PSBuilder = SCons.Builder.Builder(action = PSAction, + prefix = '$PSPREFIX', + suffix = '$PSSUFFIX', + src_suffix = '.dvi', + src_builder = 'DVI') + + env['BUILDERS']['PostScript'] = PSBuilder env['DVIPS'] = 'dvips' env['DVIPSFLAGS'] = SCons.Util.CLVar('') env['PSCOM'] = '$DVIPS $DVIPSFLAGS -o $TARGET $SOURCE' + env['PSPREFIX'] = '' + env['PSSUFFIX'] = '.ps' def exists(env): return env.Detect('dvips') diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index 7df110a7..b8e9c6f9 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -34,7 +34,6 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action -import SCons.Defaults import SCons.Platform import SCons.Util @@ -48,17 +47,20 @@ elif platform == 'win32': else: gs = 'gs' -GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') +GhostscriptAction = None def generate(env): """Add Builders and construction variables for Ghostscript to an Environment.""" - try: - bld = env['BUILDERS']['PDF'] - except KeyError: - bld = SCons.Defaults.PDF() - env['BUILDERS']['PDF'] = bld + global GhostscriptAction + if GhostscriptAction is None: + GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') + + import pdf + pdf.generate(env) + + bld = env['BUILDERS']['PDF'] bld.add_action('.ps', GhostscriptAction) env['GS'] = gs diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py index c77461b4..5bd21d9f 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -40,7 +40,7 @@ import SCons.Util import SCons.Tool import SCons.Tool.tex -LaTeXAction = SCons.Action.Action('$LATEXCOM', '$LATEXCOMSTR') +LaTeXAction = None def LaTeXAuxFunction(target = None, source= None, env=None): SCons.Tool.tex.InternalLaTeXAuxAction( LaTeXAction, target, source, env ) @@ -49,13 +49,14 @@ LaTeXAuxAction = SCons.Action.Action(LaTeXAuxFunction, strfunction=None) def generate(env): """Add Builders and construction variables for LaTeX to an Environment.""" + global LaTeXAction + if LaTeXAction is None: + LaTeXAction = SCons.Action.Action('$LATEXCOM', '$LATEXCOMSTR') - try: - bld = env['BUILDERS']['DVI'] - except KeyError: - bld = SCons.Defaults.DVI() - env['BUILDERS']['DVI'] = bld + import dvi + dvi.generate(env) + bld = env['BUILDERS']['DVI'] bld.add_action('.ltx', LaTeXAuxAction) bld.add_action('.latex', LaTeXAuxAction) bld.add_emitter('.ltx', SCons.Tool.tex.tex_emitter) diff --git a/src/engine/SCons/Tool/pdf.py b/src/engine/SCons/Tool/pdf.py new file mode 100644 index 00000000..b4bfc17b --- /dev/null +++ b/src/engine/SCons/Tool/pdf.py @@ -0,0 +1,56 @@ +"""SCons.Tool.pdf + +Common PDF Builder definition for various other Tool modules that use it. + +""" + +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import SCons.Builder +import SCons.Tool + +PDFBuilder = None + +def generate(env): + try: + bld = env['BUILDERS']['PDF'] + except KeyError: + global PDFBuilder + if PDFBuilder is None: + PDFBuilder = SCons.Builder.Builder(action = {}, + source_scanner = SCons.Tool.LaTeXScanner, + prefix = '$PDFPREFIX', + suffix = '$PDFSUFFIX', + emitter = {}) + env['BUILDERS']['PDF'] = PDFBuilder + + env['PDFPREFIX'] = '' + env['PDFSUFFIX'] = '.pdf' + +def exists(env): + # This only puts a skeleton Builder in place, so if someone + # references this Tool directly, it's always "available." + return 1 diff --git a/src/engine/SCons/Tool/pdf.xml b/src/engine/SCons/Tool/pdf.xml new file mode 100644 index 00000000..3d64be2d --- /dev/null +++ b/src/engine/SCons/Tool/pdf.xml @@ -0,0 +1,39 @@ + + + +Builds a .pdf file +from a .dvi input file +(or, by extension, a .tex, +.ltx, +or +.latex input file). +The suffix specified by the &cv-PDFSUFFIX; construction variable +(.pdf by default) +is added automatically to the target +if it is not already present. Example: + + +# builds from aaa.tex +env.PDF(target = 'aaa.pdf', source = 'aaa.tex') +# builds bbb.pdf from bbb.dvi +env.PDF(target = 'bbb', source = 'bbb.dvi') + + + + + + +The prefix used for PDF file names. + + + + + +The suffix used for PDF file names. + + diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index 3b7ac400..acf67b27 100644 --- a/src/engine/SCons/Tool/pdflatex.py +++ b/src/engine/SCons/Tool/pdflatex.py @@ -34,25 +34,32 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action -import SCons.Defaults import SCons.Util +import SCons.Tool.pdf import SCons.Tool.tex -PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM', '$PDFLATEXCOMSTR') +PDFLaTeXAction = None def PDFLaTeXAuxFunction(target = None, source= None, env=None): SCons.Tool.tex.InternalLaTeXAuxAction( PDFLaTeXAction, target, source, env ) -PDFLaTeXAuxAction = SCons.Action.Action(PDFLaTeXAuxFunction, strfunction=None) +PDFLaTeXAuxAction = None def generate(env): """Add Builders and construction variables for pdflatex to an Environment.""" - try: - bld = env['BUILDERS']['PDF'] - except KeyError: - bld = SCons.Defaults.PDF() - env['BUILDERS']['PDF'] = bld + global PDFLaTeXAction + if PDFLaTeXAction is None: + PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM', '$PDFLATEXCOMSTR') + global PDFLaTeXAuxAction + if PDFLaTeXAuxAction is None: + PDFLaTeXAuxAction = SCons.Action.Action(PDFLaTeXAuxFunction, + strfunction=None) + + import pdf + pdf.generate(env) + + bld = env['BUILDERS']['PDF'] bld.add_action('.ltx', PDFLaTeXAuxAction) bld.add_action('.latex', PDFLaTeXAuxAction) bld.add_emitter('.ltx', SCons.Tool.tex.tex_emitter) diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py index a25f08bb..075315d8 100644 --- a/src/engine/SCons/Tool/pdftex.py +++ b/src/engine/SCons/Tool/pdftex.py @@ -34,15 +34,14 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action -import SCons.Defaults import SCons.Util import SCons.Tool.tex -PDFTeXAction = SCons.Action.Action('$PDFTEXCOM', '$PDFTEXCOMSTR') +PDFTeXAction = None -# Define an action to build a latex file. This action might be needed more -# than once if we are dealing with labels and bibtex -PDFLaTeXAction = SCons.Action.Action("$PDFLATEXCOM", "$PDFLATEXCOMSTR") +# This action might be needed more than once if we are dealing with +# labels and bibtex. +PDFLaTeXAction = None def PDFLaTeXAuxAction(target = None, source= None, env=None): SCons.Tool.tex.InternalLaTeXAuxAction( PDFLaTeXAction, target, source, env ) @@ -57,17 +56,27 @@ def PDFTeXLaTeXFunction(target = None, source= None, env=None): PDFTeXAction(target,source,env) return 0 -PDFTeXLaTeXAction = SCons.Action.Action(PDFTeXLaTeXFunction, - strfunction=None) +PDFTeXLaTeXAction = None def generate(env): """Add Builders and construction variables for pdftex to an Environment.""" - try: - bld = env['BUILDERS']['PDF'] - except KeyError: - bld = SCons.Defaults.PDF() - env['BUILDERS']['PDF'] = bld + global PDFTeXAction + if PDFTeXAction is None: + PDFTeXAction = SCons.Action.Action('$PDFTEXCOM', '$PDFTEXCOMSTR') + global PDFLaTeXAction + if PDFLaTeXAction is None: + PDFLaTeXAction = SCons.Action.Action("$PDFLATEXCOM", "$PDFLATEXCOMSTR") + + global PDFTeXLaTeXAction + if PDFTeXLaTeXAction is None: + PDFTeXLaTeXAction = SCons.Action.Action(PDFTeXLaTeXFunction, + strfunction=None) + + import pdf + pdf.generate(env) + + bld = env['BUILDERS']['PDF'] bld.add_action('.tex', PDFTeXLaTeXAction) bld.add_emitter('.tex', SCons.Tool.tex.tex_emitter) diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 8b80a027..1ca40f20 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -38,30 +38,28 @@ import re import string import SCons.Action -import SCons.Defaults import SCons.Node import SCons.Node.FS import SCons.Util -# Define an action to build a generic tex file. This is sufficient for all -# tex files. -TeXAction = SCons.Action.Action("$TEXCOM", "$TEXCOMSTR") +# An Action sufficient to build any generic tex file. +TeXAction = None -# Define an action to build a latex file. This action might be needed more -# than once if we are dealing with labels and bibtex -LaTeXAction = SCons.Action.Action("$LATEXCOM", "$LATEXCOMSTR") +# An action to build a latex file. This action might be needed more +# than once if we are dealing with labels and bibtex. +LaTeXAction = None -# Define an action to run BibTeX on a file. -BibTeXAction = SCons.Action.Action("$BIBTEXCOM", "$BIBTEXCOMSTR") +# An action to run BibTeX on a file. +BibTeXAction = None -# Define an action to run MakeIndex on a file. -MakeIndexAction = SCons.Action.Action("$MAKEINDEXCOM", "$MAKEINDEXOMSTR") +# An action to run MakeIndex on a file. +MakeIndexAction = None def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None): """A builder for LaTeX files that checks the output in the aux file and decides how many times to use LaTeXAction, and BibTeXAction.""" - # Get the base name of the target - basename, ext = os.path.splitext(str(target[0])) + + basename, ext = SCons.Util.splitext(str(target[0])) # Run LaTeX once to generate a new aux file. XXXLaTeXAction(target,source,env) @@ -121,21 +119,46 @@ 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) +def tex_emitter(target, source, env): + base = SCons.Util.splitext(str(source[0]))[0] + target.append(base + '.aux') + target.append(base + '.log') + return (target, source) -TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction, strfunction=None) +TeXLaTeXAction = None def generate(env): """Add Builders and construction variables for TeX to an Environment.""" - try: - bld = env['BUILDERS']['DVI'] - except KeyError: - bld = SCons.Defaults.DVI() - env['BUILDERS']['DVI'] = bld + # A generic tex file Action, sufficient for all tex files. + global TeXAction + if TeXAction is None: + TeXAction = SCons.Action.Action("$TEXCOM", "$TEXCOMSTR") + + # An Action to build a latex file. This might be needed more + # than once if we are dealing with labels and bibtex. + global LaTeXAction + if LaTeXAction is None: + LaTeXAction = SCons.Action.Action("$LATEXCOM", "$LATEXCOMSTR") + + # Define an action to run BibTeX on a file. + global BibTeXAction + if BibTeXAction is None: + BibTeXAction = SCons.Action.Action("$BIBTEXCOM", "$BIBTEXCOMSTR") + + # Define an action to run MakeIndex on a file. + global MakeIndexAction + if MakeIndexAction is None: + MakeIndexAction = SCons.Action.Action("$MAKEINDEXCOM", "$MAKEINDEXOMSTR") + + global TeXLaTeXAction + if TeXLaTeXAction is None: + TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction, strfunction=None) + + import dvi + dvi.generate(env) + + bld = env['BUILDERS']['DVI'] bld.add_action('.tex', TeXLaTeXAction) bld.add_emitter('.tex', tex_emitter) diff --git a/test/import.py b/test/import.py index 7bcc0589..3663f535 100644 --- a/test/import.py +++ b/test/import.py @@ -70,6 +70,7 @@ tools = [ 'CVS', 'default', 'dmd', + 'dvi', 'dvipdf', 'dvips', 'f77', @@ -110,6 +111,7 @@ tools = [ 'mwcc', 'mwld', 'nasm', + 'pdf', 'pdflatex', 'pdftex', 'Perforce',