ds = LaTeX(name = "PDFLaTeXScanner",
suffixes = '$LATEXSUFFIXES',
# in the search order, see below in LaTeX class docstring
- graphics_extensions = ['.png', '.pdf', '.jpg', '.tif'],
+ graphics_extensions = ['.pdf', '.png', '.jpg', '.gif', '.tif'],
recursive = 0)
return ds
Another difference is that the search path is determined by the type
of the file being searched:
env['TEXINPUTS'] for "input" and "include" keywords
- env['TEXPICTS'] for "includegraphics" keyword
+ env['TEXINPUTS'] for "includegraphics" keyword
env['BIBINPUTS'] for "bibliography" keyword
env['BSTINPUTS'] for "bibliographystyle" keyword
def __init__(self, name, suffixes, graphics_extensions, *args, **kw):
- regex = '\\\\(include|includegraphics(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}'
+ regex = '^[^%]*\\\\(include|includegraphics(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}'
self.cre = re.compile(regex, re.M)
self.graphics_extensions = graphics_extensions
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.
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'
import SCons.Action
import SCons.Builder
+import SCons.Tool.dvipdf
import SCons.Util
+def DviPsFunction(target = None, source= None, env=None):
+ result = SCons.Tool.dvipdf.DviPdfPsFunction(PSAction,target,source,env)
+ return result
+
+def DviPsStrFunction(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('$PSCOM',0,target,source)
+ else:
+ result = ''
+ return result
+
PSAction = None
+DVIPSAction = None
PSBuilder = None
def generate(env):
if PSAction is None:
PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR')
+ global DVIPSAction
+ if DVIPSAction is None:
+ DVIPSAction = SCons.Action.Action(DviPsFunction, strfunction = DviPsStrFunction)
+
global PSBuilder
if PSBuilder is None:
PSBuilder = SCons.Builder.Builder(action = PSAction,
for var in SCons.Scanner.LaTeX.LaTeX.env_variables:
saved_env[var] = modify_env_var(env, var, abspath)
- # Create base file names with the target directory since the auxiliary files
+ # Create a base file names with the target directory since the auxiliary files
# will be made there. That's because the *COM variables have the cd
# command in the prolog. We check
# for the existence of files before opening them--even ones like the
targetbase = SCons.Util.splitext(str(target[0]))[0]
basename = SCons.Util.splitext(str(source[0]))[0]
basefile = os.path.split(str(basename))[1]
+
+ basedir = os.path.split(str(source[0]))[0]
+ abspath = os.path.abspath(basedir)
+ target[0].attributes.path = abspath
#
# file names we will make use of in searching the sources and log file