diff options
author | Steven Knight <knight@baldmt.com> | 2005-12-16 12:16:00 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-12-16 12:16:00 (GMT) |
commit | b6eb3e9a8ba7604dd93220d876b1a78d41b5109f (patch) | |
tree | f4ae8889202019c9a5ed7315e33802e03c8705c7 /src/engine/SCons | |
parent | 5282b161bd006fff6f2942d21e4924769bd9cf7a (diff) | |
download | SCons-b6eb3e9a8ba7604dd93220d876b1a78d41b5109f.zip SCons-b6eb3e9a8ba7604dd93220d876b1a78d41b5109f.tar.gz SCons-b6eb3e9a8ba7604dd93220d876b1a78d41b5109f.tar.bz2 |
Fix DVIPDF tests, refactor various TeX Tool modules.
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/Defaults.py | 23 | ||||
-rw-r--r-- | src/engine/SCons/Defaults.xml | 84 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvi.py | 57 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvi.xml | 56 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvipdf.py | 28 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvips.py | 26 | ||||
-rw-r--r-- | src/engine/SCons/Tool/gs.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/Tool/latex.py | 13 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdf.py | 56 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdf.xml | 39 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdflatex.py | 23 | ||||
-rw-r--r-- | src/engine/SCons/Tool/pdftex.py | 33 | ||||
-rw-r--r-- | src/engine/SCons/Tool/tex.py | 69 |
13 files changed, 345 insertions, 178 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index e51c870..6b9b115 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 84dfe58..fea7c04 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. --> -<builder name="DVI"> -<summary> -Builds a <filename>.dvi</filename> file -from a <filename>.tex</filename>, -<filename>.ltx</filename> or <filename>.latex</filename> input file. -If the source file suffix is <filename>.tex</filename>, -&scons; -will examine the contents of the file; -if the string -<literal>\documentclass</literal> -or -<literal>\documentstyle</literal> -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 -<filename>.aux</filename> -file and invoke the &cv-BIBTEX; command line -if the string -<literal>bibdata</literal> -is found, -start &cv-MAKEINDEX; to generate an index if a -<filename>.ind</filename> -file is found -and will examine the contents -<filename>.log</filename> -file and re-run the &cv-LATEXCOM; command -if the log file says it is necessary. - -The suffix <filename>.dvi</filename> -(hard-coded within TeX itself) -is automatically added to the target -if it is not already present. -Examples: - -<example> -# 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') -</example> -</summary> -</builder> - -<builder name="PDF"> -<summary> -Builds a <filename>.pdf</filename> file -from a <filename>.dvi</filename> input file -(or, by extension, a <filename>.tex</filename>, -<filename>.ltx</filename>, -or -<filename>.latex</filename> input file). -The suffix specified by the &cv-PDFSUFFIX; construction variable -(<filename>.pdf</filename> by default) -is added automatically to the target -if it is not already present. Example: - -<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') -</example> -</summary> -</builder> - <cvar name ="_concat"> <summary> A function used to produce variables like &cv-_CPPINCFLAGS;. It takes @@ -536,18 +464,6 @@ all the libraries in this list. </summary> </cvar> -<cvar name="PDFPREFIX"> -<summary> -The prefix used for PDF file names. -</summary> -</cvar> - -<cvar name="PDFSUFFIX"> -<summary> -The suffix used for PDF file names. -</summary> -</cvar> - <cvar name="RDirs"> <summary> 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 0000000..1be710c --- /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 0000000..9d3110e --- /dev/null +++ b/src/engine/SCons/Tool/dvi.xml @@ -0,0 +1,56 @@ +<!-- +__COPYRIGHT__ + +This file is processed by the bin/SConsDoc.py module. +See its __doc__ string for a discussion of the format. +--> +<builder name="DVI"> +<summary> +Builds a <filename>.dvi</filename> file +from a <filename>.tex</filename>, +<filename>.ltx</filename> or <filename>.latex</filename> input file. +If the source file suffix is <filename>.tex</filename>, +&scons; +will examine the contents of the file; +if the string +<literal>\documentclass</literal> +or +<literal>\documentstyle</literal> +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 +<filename>.aux</filename> +file and invoke the &cv-BIBTEX; command line +if the string +<literal>bibdata</literal> +is found, +start &cv-MAKEINDEX; to generate an index if a +<filename>.ind</filename> +file is found +and will examine the contents +<filename>.log</filename> +file and re-run the &cv-LATEXCOM; command +if the log file says it is necessary. + +The suffix <filename>.dvi</filename> +(hard-coded within TeX itself) +is automatically added to the target +if it is not already present. +Examples: + +<example> +# 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') +</example> +</summary> +</builder> + diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index 1ffb655..bade8ff 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 02db5ca..b987ea1 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 7df110a..b8e9c6f 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 c77461b..5bd21d9 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 0000000..b4bfc17 --- /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 0000000..3d64be2 --- /dev/null +++ b/src/engine/SCons/Tool/pdf.xml @@ -0,0 +1,39 @@ +<!-- +__COPYRIGHT__ + +This file is processed by the bin/SConsDoc.py module. +See its __doc__ string for a discussion of the format. +--> +<builder name="PDF"> +<summary> +Builds a <filename>.pdf</filename> file +from a <filename>.dvi</filename> input file +(or, by extension, a <filename>.tex</filename>, +<filename>.ltx</filename>, +or +<filename>.latex</filename> input file). +The suffix specified by the &cv-PDFSUFFIX; construction variable +(<filename>.pdf</filename> by default) +is added automatically to the target +if it is not already present. Example: + +<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') +</example> +</summary> +</builder> + +<cvar name="PDFPREFIX"> +<summary> +The prefix used for PDF file names. +</summary> +</cvar> + +<cvar name="PDFSUFFIX"> +<summary> +The suffix used for PDF file names. +</summary> +</cvar> diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index 3b7ac40..acf67b2 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 a25f08b..075315d 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 8b80a02..1ca40f2 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) |