summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2010-06-15 17:01:27 (GMT)
committerSteven Knight <knight@baldmt.com>2010-06-15 17:01:27 (GMT)
commit894e7eb8ee6f062f076bec3b33d13d19c475faaa (patch)
tree64467db0c059aa39aaf6f44dfa207394865947b1 /src/engine
parenta571ee0bb24bcaf976cd8b313688a7287c4edbeb (diff)
downloadSCons-894e7eb8ee6f062f076bec3b33d13d19c475faaa.zip
SCons-894e7eb8ee6f062f076bec3b33d13d19c475faaa.tar.gz
SCons-894e7eb8ee6f062f076bec3b33d13d19c475faaa.tar.bz2
Merged revisions 4727-4729,4731-4938,4940-5028 via svnmerge from
http://scons.tigris.org/svn/scons/branches/pending ........ r4942 | stevenknight | 2010-06-03 12:41:20 -0700 (Thu, 03 Jun 2010) | 13 lines Isseu 2641: Latest drop of the TestCmd infrastructure, v. 1.3, including: * Support for test timeouts. * Ability to set separate match_stdout and match_stderr functions. * Ability to set separate diff_stdout and diff_stderr functions. * Static methods for the various underlying match* and diff* functionality. * Ability to get at the various match* and diff* functions by attribute name. * Got rid of checks for difflib now that Python 2.3 is the floor (for this infrastructure, anyway). Ripple effects in two test scripts. Added upstream unit test modules (QMTest/Test{Cmd,Common}Tests.py). Added a README.txt file. ........ r4943 | stevenknight | 2010-06-03 13:00:31 -0700 (Thu, 03 Jun 2010) | 2 lines Grab the correct TestCmd files with the updated version number. ........ r4946 | managan | 2010-06-04 09:39:20 -0700 (Fri, 04 Jun 2010) | 4 lines On Windows add a '/D' to the command line so it recognizes drive letters in the source or target file paths ........ r4947 | managan | 2010-06-04 09:51:48 -0700 (Fri, 04 Jun 2010) | 5 lines The scanner was not parsing the dependencies in \includegraphics commands when there was whitespace (including carriage returns) in the command. While we need a better long term fix this covers this concern. ........ r4948 | managan | 2010-06-04 11:13:12 -0700 (Fri, 04 Jun 2010) | 3 lines Dropped an import line that is needed by the last commit of mine for Windows depenedant option on latex command lines ........ r4949 | managan | 2010-06-04 12:27:48 -0700 (Fri, 04 Jun 2010) | 7 lines Some latex packages break up commands where you normally could not by using a comment character at the end of the first line. Our current scanner broke on this and lost some dependecies. While we need general fix, this patch solves this problem ........ r4950 | managan | 2010-06-04 15:51:36 -0700 (Fri, 04 Jun 2010) | 5 lines Tweak how we handle comments within Latex source files when scanning and looking for dependencies. We were adding a space when a comment broke a line and we should not have. ........ r4984 | managan | 2010-06-07 09:37:40 -0700 (Mon, 07 Jun 2010) | 6 lines The multi-line_include-options test failed to check for the existence of latex. Added that so this test is skipped on systems without latex. ........
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Scanner/LaTeX.py28
-rw-r--r--src/engine/SCons/Tool/tex.py24
2 files changed, 40 insertions, 12 deletions
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py
index d3c5c9a..b8d48b1 100644
--- a/src/engine/SCons/Scanner/LaTeX.py
+++ b/src/engine/SCons/Scanner/LaTeX.py
@@ -168,8 +168,11 @@ class LaTeX(SCons.Scanner.Base):
# Without the \n, the ^ could match the beginning of a *previous*
# line followed by one or more newline characters (i.e. blank
# lines), interfering with a match on the next line.
- regex = r'^[^%\n]*\\(include|includegraphics(?:\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|usepackage){([^}]*)}'
+ # add option for whitespace before the '[options]' or the '{filename}'
+ regex = r'^[^%\n]*\\(include|includegraphics(?:\s*\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|usepackage)\s*{([^}]*)}'
self.cre = re.compile(regex, re.M)
+ self.comment_re = re.compile(r'^((?:(?:\\%)|[^%\n])*)(.*)$', re.M)
+
self.graphics_extensions = graphics_extensions
def _scan(node, env, path=(), self=self):
@@ -274,6 +277,23 @@ class LaTeX(SCons.Scanner.Base):
return i, include
return i, include
+ def canonical_text(self, text):
+ """Standardize an input TeX-file contents.
+
+ Currently:
+ * removes comments, unwrapping comment-wrapped lines.
+ """
+ out = []
+ line_continues_a_comment = False
+ for line in text.splitlines():
+ line,comment = self.comment_re.findall(line)[0]
+ if line_continues_a_comment == True:
+ out[-1] = out[-1] + line.lstrip()
+ else:
+ out.append(line)
+ line_continues_a_comment = len(comment) > 0
+ return '\n'.join(out).rstrip()+'\n'
+
def scan(self, node):
# Modify the default scan function to allow for the regular
# expression to return a comma separated list of file names
@@ -281,11 +301,13 @@ class LaTeX(SCons.Scanner.Base):
# Cache the includes list in node so we only scan it once:
# path_dict = dict(list(path))
- noopt_cre = re.compile('\[.*$')
+ # add option for whitespace (\s) before the '['
+ noopt_cre = re.compile('\s*\[.*$')
if node.includes != None:
includes = node.includes
else:
- includes = self.cre.findall(node.get_text_contents())
+ text = self.canonical_text(node.get_text_contents())
+ includes = self.cre.findall(text)
# 1. Split comma-separated lines, e.g.
# ('bibliography', 'phys,comp')
# should become two entries
diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py
index a2870b5..37881bb 100644
--- a/src/engine/SCons/Tool/tex.py
+++ b/src/engine/SCons/Tool/tex.py
@@ -38,6 +38,7 @@ import os.path
import re
import shutil
import sys
+import platform
import SCons.Action
import SCons.Node
@@ -757,45 +758,50 @@ def generate_common(env):
if MakeAcronymsAction is None:
MakeAcronymsAction = SCons.Action.Action("$MAKEACRONYMSCOM", "$MAKEACRONYMSCOMSTR")
+ CDCOM = 'cd '
+ if platform.system() == 'Windows':
+ # allow cd command to change drives on Windows
+ CDCOM = 'cd /D '
+
env['TEX'] = 'tex'
env['TEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder')
- env['TEXCOM'] = 'cd ${TARGET.dir} && $TEX $TEXFLAGS ${SOURCE.file}'
+ env['TEXCOM'] = CDCOM + '${TARGET.dir} && $TEX $TEXFLAGS ${SOURCE.file}'
env['PDFTEX'] = 'pdftex'
env['PDFTEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder')
- env['PDFTEXCOM'] = 'cd ${TARGET.dir} && $PDFTEX $PDFTEXFLAGS ${SOURCE.file}'
+ env['PDFTEXCOM'] = CDCOM + '${TARGET.dir} && $PDFTEX $PDFTEXFLAGS ${SOURCE.file}'
env['LATEX'] = 'latex'
env['LATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder')
- env['LATEXCOM'] = 'cd ${TARGET.dir} && $LATEX $LATEXFLAGS ${SOURCE.file}'
+ env['LATEXCOM'] = CDCOM + '${TARGET.dir} && $LATEX $LATEXFLAGS ${SOURCE.file}'
env['LATEXRETRIES'] = 3
env['PDFLATEX'] = 'pdflatex'
env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode -recorder')
- env['PDFLATEXCOM'] = 'cd ${TARGET.dir} && $PDFLATEX $PDFLATEXFLAGS ${SOURCE.file}'
+ env['PDFLATEXCOM'] = CDCOM + '${TARGET.dir} && $PDFLATEX $PDFLATEXFLAGS ${SOURCE.file}'
env['BIBTEX'] = 'bibtex'
env['BIBTEXFLAGS'] = SCons.Util.CLVar('')
- env['BIBTEXCOM'] = 'cd ${TARGET.dir} && $BIBTEX $BIBTEXFLAGS ${SOURCE.filebase}'
+ env['BIBTEXCOM'] = CDCOM + '${TARGET.dir} && $BIBTEX $BIBTEXFLAGS ${SOURCE.filebase}'
env['MAKEINDEX'] = 'makeindex'
env['MAKEINDEXFLAGS'] = SCons.Util.CLVar('')
- env['MAKEINDEXCOM'] = 'cd ${TARGET.dir} && $MAKEINDEX $MAKEINDEXFLAGS ${SOURCE.file}'
+ env['MAKEINDEXCOM'] = CDCOM + '${TARGET.dir} && $MAKEINDEX $MAKEINDEXFLAGS ${SOURCE.file}'
env['MAKEGLOSSARY'] = 'makeindex'
env['MAKEGLOSSARYSTYLE'] = '${SOURCE.filebase}.ist'
env['MAKEGLOSSARYFLAGS'] = SCons.Util.CLVar('-s ${MAKEGLOSSARYSTYLE} -t ${SOURCE.filebase}.glg')
- env['MAKEGLOSSARYCOM'] = 'cd ${TARGET.dir} && $MAKEGLOSSARY ${SOURCE.filebase}.glo $MAKEGLOSSARYFLAGS -o ${SOURCE.filebase}.gls'
+ env['MAKEGLOSSARYCOM'] = CDCOM + '${TARGET.dir} && $MAKEGLOSSARY ${SOURCE.filebase}.glo $MAKEGLOSSARYFLAGS -o ${SOURCE.filebase}.gls'
env['MAKEACRONYMS'] = 'makeindex'
env['MAKEACRONYMSSTYLE'] = '${SOURCE.filebase}.ist'
env['MAKEACRONYMSFLAGS'] = SCons.Util.CLVar('-s ${MAKEACRONYMSSTYLE} -t ${SOURCE.filebase}.alg')
- env['MAKEACRONYMSCOM'] = 'cd ${TARGET.dir} && $MAKEACRONYMS ${SOURCE.filebase}.acn $MAKEACRONYMSFLAGS -o ${SOURCE.filebase}.acr'
+ env['MAKEACRONYMSCOM'] = CDCOM + '${TARGET.dir} && $MAKEACRONYMS ${SOURCE.filebase}.acn $MAKEACRONYMSFLAGS -o ${SOURCE.filebase}.acr'
env['MAKENCL'] = 'makeindex'
env['MAKENCLSTYLE'] = 'nomencl.ist'
env['MAKENCLFLAGS'] = '-s ${MAKENCLSTYLE} -t ${SOURCE.filebase}.nlg'
- env['MAKENCLCOM'] = 'cd ${TARGET.dir} && $MAKENCL ${SOURCE.filebase}.nlo $MAKENCLFLAGS -o ${SOURCE.filebase}.nls'
+ env['MAKENCLCOM'] = CDCOM + '${TARGET.dir} && $MAKENCL ${SOURCE.filebase}.nlo $MAKENCLFLAGS -o ${SOURCE.filebase}.nls'
def exists(env):
return env.Detect('tex')