summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool/dvipdf.py
diff options
context:
space:
mode:
authorRobert Managan <managan1@llnl.gov>2008-09-30 22:54:35 (GMT)
committerRobert Managan <managan1@llnl.gov>2008-09-30 22:54:35 (GMT)
commitc0e7371604c74acdb3e6e941f3356328d240ca3d (patch)
treebf3423151d461ca7fb77b1bf4e0910ac4daf443c /src/engine/SCons/Tool/dvipdf.py
parente86a0c1c6d7cb02ddca28ffd6fc1a945e5446d22 (diff)
downloadSCons-c0e7371604c74acdb3e6e941f3356328d240ca3d.zip
SCons-c0e7371604c74acdb3e6e941f3356328d240ca3d.tar.gz
SCons-c0e7371604c74acdb3e6e941f3356328d240ca3d.tar.bz2
This patch removes setting the variable TEXPICTS in the tex tools and
sets it in tee dvi2ps and dvipdf tools where it is needed. This means that we can reset it to the original value at the end of the tool. This is done by storing the .tex source file's path in the .dvi file's Node .attribute slot and retrieving it in the dvi2ps and dvipdf tools from the source. I also updated the list of graphics extensions in the Latex scanner I set up one function that gets called to run either dvi2ps or dvipdf after setting TEXPICTS.
Diffstat (limited to 'src/engine/SCons/Tool/dvipdf.py')
-rw-r--r--src/engine/SCons/Tool/dvipdf.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py
index 179159e..05c9251 100644
--- a/src/engine/SCons/Tool/dvipdf.py
+++ b/src/engine/SCons/Tool/dvipdf.py
@@ -36,9 +36,50 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Action
import SCons.Defaults
import SCons.Tool.pdf
+import SCons.Tool.tex
import SCons.Util
+_null = SCons.Tool.tex._Null
+
+def DviPdfPsFunction(XXXDviAction, target = None, source= None, env=None):
+ """A builder for DVI files that sets the TEXPICTS environment
+ variable before running dvi2ps or dvipdf."""
+
+ try:
+ abspath = source[0].attributes.path
+ except AttributeError :
+ abspath = ''
+
+ saved_env = {}
+ saved_env['TEXPICTS'] = SCons.Tool.tex.modify_env_var(env, 'TEXPICTS', abspath)
+
+ result = XXXDviAction(target, source, env)
+
+ if saved_env['TEXPICTS'] is _null:
+ try:
+ env['ENV'].pop('TEXPICTS')
+ except KeyError:
+ pass # was never set
+ else:
+ env['ENV']['TEXPICTS'] = saved_env['TEXPICTS']
+
+ return result
+
+def DviPdfFunction(target = None, source= None, env=None):
+ result = DviPdfPsFunction(PDFAction,target,source,env)
+ return result
+
+def DviPdfStrFunction(target = None, source= None, env=None):
+ """A strfunction for dvipdf that returns the appropriate
+ command string for the no_exec options."""
+ if env.GetOption("no_exec"):
+ result = env.subst('$DVIPDFCOM',0,target,source)
+ else:
+ result = ''
+ return result
+
PDFAction = None
+DVIPDFAction = None
def PDFEmitter(target, source, env):
"""Strips any .aux or .log files from the input source list.
@@ -57,11 +98,15 @@ def generate(env):
if PDFAction is None:
PDFAction = SCons.Action.Action('$DVIPDFCOM', '$DVIPDFCOMSTR')
+ global DVIPDFAction
+ if DVIPDFAction is None:
+ DVIPDFAction = SCons.Action.Action(DviPdfFunction, strfunction = DviPdfStrFunction)
+
import pdf
pdf.generate(env)
bld = env['BUILDERS']['PDF']
- bld.add_action('.dvi', PDFAction)
+ bld.add_action('.dvi', DVIPDFAction)
bld.add_emitter('.dvi', PDFEmitter)
env['DVIPDF'] = 'dvipdf'