summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-11-06 17:03:25 (GMT)
committerSteven Knight <knight@baldmt.com>2005-11-06 17:03:25 (GMT)
commit6100e6fec11023b5ee239b097d240b1cbd32a739 (patch)
treeb4ad541bd0361ccea3b838aa3dc3fa4d71c8438c
parent0113b86def554ddcd54b3b9eace409e16bf8a5a7 (diff)
downloadSCons-6100e6fec11023b5ee239b097d240b1cbd32a739.zip
SCons-6100e6fec11023b5ee239b097d240b1cbd32a739.tar.gz
SCons-6100e6fec11023b5ee239b097d240b1cbd32a739.tar.bz2
Correct $SOURCES on TeX command lines. (Sanjoy Mahajan) Add scanning of LaTeX files for implicit dependencies. (August Hörandl) Add support for generating indices from .idx files. (August Hörandl)
-rw-r--r--doc/man/scons.142
-rw-r--r--src/CHANGES.txt11
-rw-r--r--src/engine/MANIFEST.in1
-rw-r--r--src/engine/SCons/Defaults.py4
-rw-r--r--src/engine/SCons/Defaults.xml19
-rw-r--r--src/engine/SCons/Scanner/LaTeX.py51
-rw-r--r--src/engine/SCons/Scanner/LaTeXTests.py134
-rw-r--r--src/engine/SCons/Tool/__init__.py7
-rw-r--r--src/engine/SCons/Tool/dvips.py2
-rw-r--r--src/engine/SCons/Tool/latex.py6
-rw-r--r--src/engine/SCons/Tool/latex.xml10
-rw-r--r--src/engine/SCons/Tool/pdflatex.py2
-rw-r--r--src/engine/SCons/Tool/pdftex.py2
-rw-r--r--src/engine/SCons/Tool/tex.py21
-rw-r--r--src/engine/SCons/Tool/tex.xml31
-rw-r--r--test/TEX/LATEX.py59
16 files changed, 385 insertions, 17 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index d2e69fd..5249f75 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -1572,11 +1572,14 @@ the
.B DVI
builder method will also examine the contents
of the
-.B .aux file
-and invoke the $BIBTEX command line
+.B .aux
+file and invoke the $BIBTEX command line
if the string
.B bibdata
is found,
+start $MAKEINDEX to generate an index if a
+.B .ind
+file is found
and will examine the contents
.B .log
file and re-run the $LATEXCOM command
@@ -6199,6 +6202,16 @@ env = Environment(LATEXCOMSTR = "Building $TARGET from LaTeX input $SOURCES")
.IP LATEXFLAGS
General options passed to the LaTeX structured formatter and typesetter.
+.IP LATEXSUFFIXES
+The list of suffixes of files that will be scanned
+for LaTeX implicit dependencies
+(\\include or \\import files).
+The default list is:
+
+.ES
+[".tex", ".ltx", ".latex"]
+.EE
+
.IP LDMODULE
The linker for building loadable modules.
By default, this is the same as $SHLINK.
@@ -6450,6 +6463,25 @@ The string displayed when
a file is passed through the M4 macro preprocessor.
If this is not set, then $M4COM (the command line) is displayed.
+.IP MAKEINDEX
+The makeindex generator for the TeX formatter and typesetter and the
+LaTeX structured formatter and typesetter.
+
+.IP MAKEINDEXCOM
+The command line used to call the makeindex generator for the
+TeX formatter and typesetter and the LaTeX structured formatter and
+typesetter.
+
+.IP MAKEINDEXCOMSTR
+The string displayed when calling the makeindex generator for the
+TeX formatter and typesetter
+and the LaTeX structured formatter and typesetter.
+If this is not set, then $MAKEINDEXCOM (the command line) is displayed.
+
+.IP MAKEINDEXFLAGS
+General options passed to the makeindex generator for the TeX formatter
+and typesetter and the LaTeX structured formatter and typesetter.
+
.IP MAXLINELENGTH
The maximum number of characters allowed on an external command line.
On Win32 systems,
@@ -7648,6 +7680,12 @@ env = Environment(TEXCOMSTR = "Building $TARGET from TeX input $SOURCES")
.IP TEXFLAGS
General options passed to the TeX formatter and typesetter.
+.IP TEXINPUTS
+List of directories that the LaTeX programm will search
+for include directories.
+The LaTeX implicit dependency scanner will search these
+directories for \include and \import files.
+
.IP TOOLS
A list of the names of the Tool specifications
that are part of this construction environment.
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index ff46247..8bf385f 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -99,6 +99,15 @@ RELEASE 0.97 - XXX
- Remove unneceesary (and incorrect) SCons.Util strings on some function
calls in SCons.Util.
+ From August Hörandl:
+
+ - Add a scanner for \include and \import files, with support for
+ searching a directory list in $TEXINPUTS (imported from the external
+ environment).
+
+ - Support $MAKEINDEX, $MAKEINDEXCOM, $MAKEINDEXCOMSTR and
+ $MAKEINDEXFLAGS for generating indices from .idx files.
+
From Stephen Kennedy:
- Speed up writing the .sconsign file at the end of a run by only
@@ -382,6 +391,8 @@ RELEASE 0.97 - XXX
From Sanjoy Mahajan:
+ - Correct TeX-related command lines to just $SOURCE, not $SOURCES
+
- Fix a bad use of Copy() in an example in the man page, and a
bad regular expression example in the man page and User's Guide.
diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in
index 17839ea..3f33b58 100644
--- a/src/engine/MANIFEST.in
+++ b/src/engine/MANIFEST.in
@@ -41,6 +41,7 @@ SCons/Scanner/D.py
SCons/Scanner/Dir.py
SCons/Scanner/Fortran.py
SCons/Scanner/IDL.py
+SCons/Scanner/LaTeX.py
SCons/Scanner/Prog.py
SCons/SConf.py
SCons/SConsign.py
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index b7453d6..b5e09b3 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -100,6 +100,7 @@ SharedCheck = SCons.Action.Action(SharedFlagChecker, None)
# transition period.
CScan = SCons.Tool.CScanner
DScan = SCons.Tool.DScanner
+LaTeXScan = SCons.Tool.LaTeXScanner
ObjSourceScan = SCons.Tool.SourceFileScanner
ProgScan = SCons.Tool.ProgramScanner
@@ -126,6 +127,7 @@ 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
@@ -135,6 +137,7 @@ def DVI():
def PDF():
"""A function for generating the PDF Builder."""
return SCons.Builder.Builder(action = { },
+ source_scanner = LaTeXScan,
prefix = '$PDFPREFIX',
suffix = '$PDFSUFFIX')
@@ -351,6 +354,7 @@ ConstructionEnvironment = {
'CPPSUFFIXES' : SCons.Tool.CSuffixes,
'DSUFFIXES' : SCons.Tool.DSuffixes,
'IDLSUFFIXES' : SCons.Tool.IDLSuffixes,
+ 'LATEXSUFFIXES' : SCons.Tool.LaTeXSuffixes,
'PDFPREFIX' : '',
'PDFSUFFIX' : '.pdf',
'PSPREFIX' : '',
diff --git a/src/engine/SCons/Defaults.xml b/src/engine/SCons/Defaults.xml
index 56957aa..1720aaa 100644
--- a/src/engine/SCons/Defaults.xml
+++ b/src/engine/SCons/Defaults.xml
@@ -20,11 +20,13 @@ the
builder method will also examine the contents
of the
<filename>.aux</filename>
-file
-and invoke the &cv-BIBTEX; command line
+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
@@ -352,6 +354,19 @@ in force for this file installation.
</summary>
</cvar>
+<cvar name="LATEXSUFFIXES">
+<summary>
+The list of suffixes of files that will be scanned
+for LaTeX implicit dependencies
+(<literal>\include</literal> or <literal>\import</literal> files).
+The default list is:
+
+<example>
+[".tex", ".ltx", ".latex"]
+</example>
+</summary>
+</cvar>
+
<cvar name="_LIBDIRFLAGS">
<summary>
An automatically-generated construction variable
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py
new file mode 100644
index 0000000..9451023
--- /dev/null
+++ b/src/engine/SCons/Scanner/LaTeX.py
@@ -0,0 +1,51 @@
+"""SCons.Scanner.LaTeX
+
+This module implements the dependency scanner for LaTeX code.
+
+"""
+
+#
+# Copyright (c) 2005 The SCons Foundation
+#
+# 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__ = ""
+
+
+import SCons.Scanner
+
+def LaTeXScanner(fs = SCons.Node.FS.default_fs):
+ """Return a prototype Scanner instance for scanning LaTeX source files"""
+ ds = LaTeX(name = "LaTeXScanner",
+ suffixes = '$LATEXSUFFIXES',
+ path_variable = 'TEXINPUTS',
+ regex = '\\\\(include|input){([^}]*)}',
+ recursive = 0)
+ return ds
+
+class LaTeX(SCons.Scanner.Classic):
+ def find_include(self, include, source_dir, path):
+ if callable(path): path=path()
+ # find (2nd result reg expr) + extension
+ # print 'looking for latex includes: ' + include[1]
+ i = SCons.Node.FS.find_file(include[1] + '.tex',
+ (source_dir,) + path)
+ return i, include
diff --git a/src/engine/SCons/Scanner/LaTeXTests.py b/src/engine/SCons/Scanner/LaTeXTests.py
new file mode 100644
index 0000000..3fc121c
--- /dev/null
+++ b/src/engine/SCons/Scanner/LaTeXTests.py
@@ -0,0 +1,134 @@
+#
+# Copyright (c) 2005 The SCons Foundation
+#
+# 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__ = ""
+
+import os.path
+import string
+import sys
+import types
+import unittest
+import UserDict
+
+import TestCmd
+import SCons.Node.FS
+import SCons.Scanner.LaTeX
+
+test = TestCmd.TestCmd(workdir = '')
+
+test.write('test1.latex',"""
+\include{inc1}
+\input{inc2}
+""")
+test.write('test2.latex',"""
+\include{inc1}
+\include{inc3}
+""")
+
+test.subdir('subdir')
+
+test.write('inc1.tex',"\n")
+test.write('inc2.tex',"\n")
+test.write([ 'subdir', 'inc3.tex'], "\n")
+
+# define some helpers:
+# copied from CTest.py
+class DummyEnvironment(UserDict.UserDict):
+ def __init__(self, **kw):
+ UserDict.UserDict.__init__(self)
+ self.data.update(kw)
+ self.fs = SCons.Node.FS.FS(test.workpath(''))
+
+ def Dictionary(self, *args):
+ return self.data
+
+ def subst(self, strSubst):
+ if strSubst[0] == '$':
+ return self.data[strSubst[1:]]
+ return strSubst
+
+ def subst_list(self, strSubst):
+ if strSubst[0] == '$':
+ return [self.data[strSubst[1:]]]
+ return [[strSubst]]
+
+ def subst_path(self, path, target=None, source=None):
+ if type(path) != type([]):
+ path = [path]
+ return map(self.subst, path)
+
+ def get_calculator(self):
+ return None
+
+ def get_factory(self, factory):
+ return factory or self.fs.File
+
+ def Dir(self, filename):
+ return self.fs.Dir(filename)
+
+ def File(self, filename):
+ return self.fs.File(filename)
+
+if os.path.normcase('foo') == os.path.normcase('FOO'):
+ my_normpath = os.path.normcase
+else:
+ my_normpath = os.path.normpath
+
+def deps_match(self, deps, headers):
+ global my_normpath
+ scanned = map(my_normpath, map(str, deps))
+ expect = map(my_normpath, headers)
+ self.failUnless(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
+
+
+class LaTeXScannerTestCase1(unittest.TestCase):
+ def runTest(self):
+ env = DummyEnvironment()
+ s = SCons.Scanner.LaTeX.LaTeXScanner()
+ path = s.path(env)
+ deps = s(env.File('test1.latex'), env, path)
+ headers = ['inc1.tex', 'inc2.tex']
+ deps_match(self, deps, headers)
+
+class LaTeXScannerTestCase2(unittest.TestCase):
+ def runTest(self):
+ env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")])
+ s = SCons.Scanner.LaTeX.LaTeXScanner()
+ path = s.path(env)
+ deps = s(env.File('test2.latex'), env, path)
+ headers = ['inc1.tex', 'subdir/inc3.tex']
+ deps_match(self, deps, headers)
+
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(LaTeXScannerTestCase1())
+ suite.addTest(LaTeXScannerTestCase2())
+ return suite
+
+if __name__ == "__main__":
+ runner = unittest.TextTestRunner()
+ result = runner.run(suite())
+ if not result.wasSuccessful():
+ sys.exit(1)
+
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 94fe121..528ee4d 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -45,10 +45,12 @@ import SCons.Errors
import SCons.Scanner
import SCons.Scanner.C
import SCons.Scanner.D
+import SCons.Scanner.LaTeX
import SCons.Scanner.Prog
CScanner = SCons.Scanner.C.CScanner()
DScanner = SCons.Scanner.D.DScanner()
+LaTeXScanner = SCons.Scanner.LaTeX.LaTeXScanner()
ProgramScanner = SCons.Scanner.Prog.ProgramScanner()
SourceFileScanner = SCons.Scanner.Scanner({}, name='SourceFileScanner')
@@ -62,12 +64,17 @@ DSuffixes = ['.d']
IDLSuffixes = [".idl", ".IDL"]
+LaTeXSuffixes = [".tex", ".ltx", ".latex"]
+
for suffix in CSuffixes:
SourceFileScanner.add_scanner(suffix, CScanner)
for suffix in DSuffixes:
SourceFileScanner.add_scanner(suffix, DScanner)
+for suffix in LaTeXSuffixes:
+ SourceFileScanner.add_scanner(suffix, LaTeXScanner)
+
class Tool:
def __init__(self, name, toolpath=[], **kw):
self.name = name
diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py
index d2debf0..02db5ca 100644
--- a/src/engine/SCons/Tool/dvips.py
+++ b/src/engine/SCons/Tool/dvips.py
@@ -52,7 +52,7 @@ def generate(env):
env['DVIPS'] = 'dvips'
env['DVIPSFLAGS'] = SCons.Util.CLVar('')
- env['PSCOM'] = '$DVIPS $DVIPSFLAGS -o $TARGET $SOURCES'
+ env['PSCOM'] = '$DVIPS $DVIPSFLAGS -o $TARGET $SOURCE'
def exists(env):
return env.Detect('dvips')
diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py
index f182b35..7f16681 100644
--- a/src/engine/SCons/Tool/latex.py
+++ b/src/engine/SCons/Tool/latex.py
@@ -35,7 +35,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Action
import SCons.Defaults
+import SCons.Scanner.LaTeX
import SCons.Util
+import SCons.Tool
LaTeXAction = SCons.Action.Action('$LATEXCOM', '$LATEXCOMSTR')
@@ -48,8 +50,8 @@ def generate(env):
bld = SCons.Defaults.DVI()
env['BUILDERS']['DVI'] = bld
- bld.add_action('.ltx', LaTeXAction)
- bld.add_action('.latex', LaTeXAction)
+ for suffix in SCons.Tool.LaTeXSuffixes:
+ bld.add_action(suffix, LaTeXAction)
env['LATEX'] = 'latex'
env['LATEXFLAGS'] = SCons.Util.CLVar('')
diff --git a/src/engine/SCons/Tool/latex.xml b/src/engine/SCons/Tool/latex.xml
index 6a415f7..58a4df5 100644
--- a/src/engine/SCons/Tool/latex.xml
+++ b/src/engine/SCons/Tool/latex.xml
@@ -34,3 +34,13 @@ env = Environment(LATEXCOMSTR = "Building $TARGET from LaTeX input $SOURCES")
General options passed to the LaTeX structured formatter and typesetter.
</summary>
</cvar>
+
+<cvar name="TEXINPUTS">
+<summary>
+List of directories that the LaTeX programm will search
+for include directories.
+The LaTeX implicit dependency scanner will search these
+directories for \include and \import files.
+</summary>
+</cvar>
+
diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py
index 57c6e2d..3af09ed 100644
--- a/src/engine/SCons/Tool/pdflatex.py
+++ b/src/engine/SCons/Tool/pdflatex.py
@@ -52,7 +52,7 @@ def generate(env):
env['PDFLATEX'] = 'pdflatex'
env['PDFLATEXFLAGS'] = SCons.Util.CLVar('')
- env['PDFLATEXCOM'] = '$PDFLATEX $PDFLATEXFLAGS $SOURCES $TARGET'
+ env['PDFLATEXCOM'] = '$PDFLATEX $PDFLATEXFLAGS $SOURCE'
def exists(env):
return env.Detect('pdflatex')
diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py
index 366151e..92a622a 100644
--- a/src/engine/SCons/Tool/pdftex.py
+++ b/src/engine/SCons/Tool/pdftex.py
@@ -51,7 +51,7 @@ def generate(env):
env['PDFTEX'] = 'pdftex'
env['PDFTEXFLAGS'] = SCons.Util.CLVar('')
- env['PDFTEXCOM'] = '$PDFTEX $PDFTEXFLAGS $SOURCES $TARGET'
+ env['PDFTEXCOM'] = '$PDFTEX $PDFTEXFLAGS $SOURCE'
def exists(env):
return env.Detect('pdftex')
diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py
index adb6c06..40a8211 100644
--- a/src/engine/SCons/Tool/tex.py
+++ b/src/engine/SCons/Tool/tex.py
@@ -54,6 +54,9 @@ LaTeXAction = SCons.Action.Action("$LATEXCOM", "$LATEXCOMSTR")
# Define an action to run BibTeX on a file.
BibTeXAction = SCons.Action.Action("$BIBTEXCOM", "$BIBTEXCOMSTR")
+# Define an action to run MakeIndex on a file.
+MakeIndexAction = SCons.Action.Action("$MAKEINDEXCOM", "$MAKEINDEXOMSTR")
+
def LaTeXAuxAction(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."""
@@ -66,6 +69,14 @@ def LaTeXAuxAction(target = None, source= None, env=None):
if string.find(content, "bibdata") != -1:
bibfile = env.fs.File(basename)
BibTeXAction(None,bibfile,env)
+ # Now if makeindex will need to be run.
+ idxfilename = basename + ".idx"
+ if os.path.exists(idxfilename):
+ idxfile = env.fs.File(basename)
+ # TODO: if ( idxfile has changed) ...
+ MakeIndexAction(None,idxfile,env)
+ LaTeXAction(target,source,env)
+
# Now check if latex needs to be run yet again.
for trial in range(3):
content = open(basename + ".log","rb").read()
@@ -109,17 +120,21 @@ def generate(env):
env['TEX'] = 'tex'
env['TEXFLAGS'] = SCons.Util.CLVar('')
- env['TEXCOM'] = '$TEX $TEXFLAGS $SOURCES'
+ env['TEXCOM'] = '$TEX $TEXFLAGS $SOURCE'
# Duplicate from latex.py. If latex.py goes away, then this is still OK.
env['LATEX'] = 'latex'
env['LATEXFLAGS'] = SCons.Util.CLVar('')
- env['LATEXCOM'] = '$LATEX $LATEXFLAGS $SOURCES'
+ env['LATEXCOM'] = '$LATEX $LATEXFLAGS $SOURCE'
env['BIBTEX'] = 'bibtex'
env['BIBTEXFLAGS'] = SCons.Util.CLVar('')
- env['BIBTEXCOM'] = '$BIBTEX $BIBTEXFLAGS $SOURCES'
+ env['BIBTEXCOM'] = '$BIBTEX $BIBTEXFLAGS $SOURCE'
+ env['MAKEINDEX'] = 'makeindex'
+ env['MAKEINDEXFLAGS'] = SCons.Util.CLVar('')
+ env['MAKEINDEXCOM'] = '$MAKEINDEX $MAKEINDEXFLAGS $SOURCES'
+
def exists(env):
return env.Detect('tex')
diff --git a/src/engine/SCons/Tool/tex.xml b/src/engine/SCons/Tool/tex.xml
index 4f69041..df7196e 100644
--- a/src/engine/SCons/Tool/tex.xml
+++ b/src/engine/SCons/Tool/tex.xml
@@ -39,6 +39,37 @@ and typesetter and the LaTeX structured formatter and typesetter.
</summary>
</cvar>
+<cvar name="MAKEINDEX">
+<summary>
+The makeindex generator for the TeX formatter and typesetter and the
+LaTeX structured formatter and typesetter.
+</summary>
+</cvar>
+
+<cvar name="MAKEINDEXCOM">
+<summary>
+The command line used to call the makeindex generator for the
+TeX formatter and typesetter and the LaTeX structured formatter and
+typesetter.
+</summary>
+</cvar>
+
+<cvar name="MAKEINDEXCOMSTR">
+<summary>
+The string displayed when calling the makeindex generator for the
+TeX formatter and typesetter
+and the LaTeX structured formatter and typesetter.
+If this is not set, then &cv-MAKEINDEXCOM; (the command line) is displayed.
+</summary>
+</cvar>
+
+<cvar name="MAKEINDEXFLAGS">
+<summary>
+General options passed to the makeindex generator for the TeX formatter
+and typesetter and the LaTeX structured formatter and typesetter.
+</summary>
+</cvar>
+
<cvar name="TEX">
<summary>
The TeX formatter and typesetter.
diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py
index 4f19bc1..a9530fc 100644
--- a/test/TEX/LATEX.py
+++ b/test/TEX/LATEX.py
@@ -83,12 +83,19 @@ os.system(string.join(sys.argv[1:], " "))
test.write('SConstruct', """
import os
-ENV = { 'PATH' : os.environ['PATH'] }
+ENV = { 'PATH' : os.environ['PATH'],
+ 'TEXINPUTS' : [ 'subdir', os.environ.get('TEXINPUTS', '') ] }
foo = Environment(ENV = ENV)
latex = foo.Dictionary('LATEX')
-bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex)
+makeindex = foo.Dictionary('MAKEINDEX')
+bar = Environment(ENV = ENV,
+ LATEX = r'%s wrapper.py ' + latex,
+ MAKEINDEX = r' wrapper.py ' + makeindex)
foo.DVI(target = 'foo.dvi', source = 'foo.ltx')
bar.DVI(target = 'bar', source = 'bar.latex')
+
+bar.DVI(target = 'makeindex', source = 'makeindex.tex')
+foo.DVI(target = 'latexi', source = 'latexi.tex')
""" % python)
latex = r"""
@@ -98,20 +105,62 @@ This is the %s LaTeX file.
\end{document}
"""
+ makeindex = r"""
+\documentclass{letter}
+\usepackage{makeidx}
+\makeindex
+\begin{document}
+\index{info}
+This is the %s LaTeX file.
+\printindex{}
+\end{document}
+"""
+
+ latex1 = r"""
+\documentclass{letter}
+\usepackage{makeidx}
+\makeindex
+\begin{document}
+\index{info}
+This is the %s LaTeX file.
+
+It has an Index and includes another file.
+\include{latexincludefile}
+\end{document}
+"""
+
+ latex2 = r"""
+\index{include}
+This is the include file.
+\printindex{}
+"""
+
test.write('foo.ltx', latex % 'foo.ltx')
test.write('bar.latex', latex % 'bar.latex')
- test.run(arguments = 'foo.dvi', stderr = None)
+ test.write('makeindex.tex', makeindex % 'makeindex.tex');
+ test.write('makeindex.idx', '');
- test.fail_test(os.path.exists(test.workpath('wrapper.out')))
+ test.subdir('subdir')
+ test.write('latexi.tex', latex1 % 'latexi.tex');
+ test.write([ 'subdir', 'latexincludefile.tex'], latex2)
+ test.run(arguments = 'foo.dvi', stderr = None)
+ test.fail_test(os.path.exists(test.workpath('wrapper.out')))
test.fail_test(not os.path.exists(test.workpath('foo.dvi')))
test.run(arguments = 'bar.dvi', stderr = None)
+ test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
+ test.fail_test(not os.path.exists(test.workpath('bar.dvi')))
+ test.run(arguments = 'makeindex.dvi', stderr = None)
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
- test.fail_test(not os.path.exists(test.workpath('bar.dvi')))
+ test.run(arguments = 'latexi.dvi', stderr = None)
+ test.fail_test(not os.path.exists(test.workpath('latexi.dvi')))
+ test.fail_test(not os.path.exists(test.workpath('latexi.ind')))
+
+
test.pass_test()