summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool/tex.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-12-16 12:16:00 (GMT)
committerSteven Knight <knight@baldmt.com>2005-12-16 12:16:00 (GMT)
commit1d015435c604590ce2047848fd534b9900423bb2 (patch)
treef4ae8889202019c9a5ed7315e33802e03c8705c7 /src/engine/SCons/Tool/tex.py
parent12c9ca505ccc4a4cf0a10100984913aa03b9f41f (diff)
downloadSCons-1d015435c604590ce2047848fd534b9900423bb2.zip
SCons-1d015435c604590ce2047848fd534b9900423bb2.tar.gz
SCons-1d015435c604590ce2047848fd534b9900423bb2.tar.bz2
Fix DVIPDF tests, refactor various TeX Tool modules.
Diffstat (limited to 'src/engine/SCons/Tool/tex.py')
-rw-r--r--src/engine/SCons/Tool/tex.py69
1 files changed, 46 insertions, 23 deletions
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)