diff options
author | Robert Managan <managan1@llnl.gov> | 2008-09-30 22:54:35 (GMT) |
---|---|---|
committer | Robert Managan <managan1@llnl.gov> | 2008-09-30 22:54:35 (GMT) |
commit | c0e7371604c74acdb3e6e941f3356328d240ca3d (patch) | |
tree | bf3423151d461ca7fb77b1bf4e0910ac4daf443c /src/engine/SCons | |
parent | e86a0c1c6d7cb02ddca28ffd6fc1a945e5446d22 (diff) | |
download | SCons-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')
-rw-r--r-- | src/engine/SCons/Scanner/LaTeX.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvipdf.py | 47 | ||||
-rw-r--r-- | src/engine/SCons/Tool/dvips.py | 19 | ||||
-rw-r--r-- | src/engine/SCons/Tool/tex.py | 6 |
4 files changed, 73 insertions, 5 deletions
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py index 9fbbae5..9639841 100644 --- a/src/engine/SCons/Scanner/LaTeX.py +++ b/src/engine/SCons/Scanner/LaTeX.py @@ -53,7 +53,7 @@ def PDFLaTeXScanner(): 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 @@ -86,7 +86,7 @@ class LaTeX(SCons.Scanner.Base): 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 @@ -103,7 +103,7 @@ class LaTeX(SCons.Scanner.Base): 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 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' diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py index ec95f16..120a12a 100644 --- a/src/engine/SCons/Tool/dvips.py +++ b/src/engine/SCons/Tool/dvips.py @@ -35,9 +35,24 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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): @@ -46,6 +61,10 @@ 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, diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index 3e577fb..43df235 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -171,7 +171,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None 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 @@ -395,6 +395,10 @@ def tex_emitter(target, source, env): 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 |