PageRenderTime 82ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/cpp/src/tools/scons/scons-local-1.2.0.d20090223/SCons/Tool/tex.py

https://code.google.com/
Python | 646 lines | 634 code | 1 blank | 11 comment | 8 complexity | 7f1b692497ea3dff91e1b459da11f5d0 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. """SCons.Tool.tex
  2. Tool-specific initialization for TeX.
  3. There normally shouldn't be any need to import this module directly.
  4. It will usually be imported through the generic SCons.Tool.Tool()
  5. selection method.
  6. """
  7. #
  8. # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
  9. #
  10. # Permission is hereby granted, free of charge, to any person obtaining
  11. # a copy of this software and associated documentation files (the
  12. # "Software"), to deal in the Software without restriction, including
  13. # without limitation the rights to use, copy, modify, merge, publish,
  14. # distribute, sublicense, and/or sell copies of the Software, and to
  15. # permit persons to whom the Software is furnished to do so, subject to
  16. # the following conditions:
  17. #
  18. # The above copyright notice and this permission notice shall be included
  19. # in all copies or substantial portions of the Software.
  20. #
  21. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  22. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  23. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. #
  29. __revision__ = "src/engine/SCons/Tool/tex.py 4043 2009/02/23 09:06:45 scons"
  30. import os.path
  31. import re
  32. import string
  33. import shutil
  34. import SCons.Action
  35. import SCons.Node
  36. import SCons.Node.FS
  37. import SCons.Util
  38. import SCons.Scanner.LaTeX
  39. Verbose = False
  40. must_rerun_latex = True
  41. # these are files that just need to be checked for changes and then rerun latex
  42. check_suffixes = ['.toc', '.lof', '.lot', '.out', '.nav', '.snm']
  43. # these are files that require bibtex or makeindex to be run when they change
  44. all_suffixes = check_suffixes + ['.bbl', '.idx', '.nlo', '.glo']
  45. #
  46. # regular expressions used to search for Latex features
  47. # or outputs that require rerunning latex
  48. #
  49. # search for all .aux files opened by latex (recorded in the .log file)
  50. openout_aux_re = re.compile(r"\\openout.*`(.*\.aux)'")
  51. #printindex_re = re.compile(r"^[^%]*\\printindex", re.MULTILINE)
  52. #printnomenclature_re = re.compile(r"^[^%]*\\printnomenclature", re.MULTILINE)
  53. #printglossary_re = re.compile(r"^[^%]*\\printglossary", re.MULTILINE)
  54. # search to find rerun warnings
  55. warning_rerun_str = '(^LaTeX Warning:.*Rerun)|(^Package \w+ Warning:.*Rerun)'
  56. warning_rerun_re = re.compile(warning_rerun_str, re.MULTILINE)
  57. # search to find citation rerun warnings
  58. rerun_citations_str = "^LaTeX Warning:.*\n.*Rerun to get citations correct"
  59. rerun_citations_re = re.compile(rerun_citations_str, re.MULTILINE)
  60. # search to find undefined references or citations warnings
  61. undefined_references_str = '(^LaTeX Warning:.*undefined references)|(^Package \w+ Warning:.*undefined citations)'
  62. undefined_references_re = re.compile(undefined_references_str, re.MULTILINE)
  63. # used by the emitter
  64. auxfile_re = re.compile(r".", re.MULTILINE)
  65. tableofcontents_re = re.compile(r"^[^%\n]*\\tableofcontents", re.MULTILINE)
  66. makeindex_re = re.compile(r"^[^%\n]*\\makeindex", re.MULTILINE)
  67. bibliography_re = re.compile(r"^[^%\n]*\\bibliography", re.MULTILINE)
  68. listoffigures_re = re.compile(r"^[^%\n]*\\listoffigures", re.MULTILINE)
  69. listoftables_re = re.compile(r"^[^%\n]*\\listoftables", re.MULTILINE)
  70. hyperref_re = re.compile(r"^[^%\n]*\\usepackage.*\{hyperref\}", re.MULTILINE)
  71. makenomenclature_re = re.compile(r"^[^%\n]*\\makenomenclature", re.MULTILINE)
  72. makeglossary_re = re.compile(r"^[^%\n]*\\makeglossary", re.MULTILINE)
  73. beamer_re = re.compile(r"^[^%\n]*\\documentclass\{beamer\}", re.MULTILINE)
  74. # search to find all files included by Latex
  75. include_re = re.compile(r'^[^%\n]*\\(?:include|input){([^}]*)}', re.MULTILINE)
  76. # search to find all graphics files included by Latex
  77. includegraphics_re = re.compile(r'^[^%\n]*\\(?:includegraphics(?:\[[^\]]+\])?){([^}]*)}', re.MULTILINE)
  78. # search to find all files opened by Latex (recorded in .log file)
  79. openout_re = re.compile(r"\\openout.*`(.*)'")
  80. # list of graphics file extensions for TeX and LaTeX
  81. TexGraphics = SCons.Scanner.LaTeX.TexGraphics
  82. LatexGraphics = SCons.Scanner.LaTeX.LatexGraphics
  83. # An Action sufficient to build any generic tex file.
  84. TeXAction = None
  85. # An action to build a latex file. This action might be needed more
  86. # than once if we are dealing with labels and bibtex.
  87. LaTeXAction = None
  88. # An action to run BibTeX on a file.
  89. BibTeXAction = None
  90. # An action to run MakeIndex on a file.
  91. MakeIndexAction = None
  92. # An action to run MakeIndex (for nomencl) on a file.
  93. MakeNclAction = None
  94. # An action to run MakeIndex (for glossary) on a file.
  95. MakeGlossaryAction = None
  96. # Used as a return value of modify_env_var if the variable is not set.
  97. _null = SCons.Scanner.LaTeX._null
  98. modify_env_var = SCons.Scanner.LaTeX.modify_env_var
  99. def FindFile(name,suffixes,paths,env,requireExt=False):
  100. if requireExt:
  101. name,ext = SCons.Util.splitext(name)
  102. # if the user gave an extension use it.
  103. if ext:
  104. name = name + ext
  105. if Verbose:
  106. print " searching for '%s' with extensions: " % name,suffixes
  107. for path in paths:
  108. testName = os.path.join(path,name)
  109. if Verbose:
  110. print " look for '%s'" % testName
  111. if os.path.exists(testName):
  112. if Verbose:
  113. print " found '%s'" % testName
  114. return env.fs.File(testName)
  115. else:
  116. name_ext = SCons.Util.splitext(testName)[1]
  117. if name_ext:
  118. continue
  119. # if no suffix try adding those passed in
  120. for suffix in suffixes:
  121. testNameExt = testName + suffix
  122. if Verbose:
  123. print " look for '%s'" % testNameExt
  124. if os.path.exists(testNameExt):
  125. if Verbose:
  126. print " found '%s'" % testNameExt
  127. return env.fs.File(testNameExt)
  128. if Verbose:
  129. print " did not find '%s'" % name
  130. return None
  131. def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None):
  132. """A builder for LaTeX files that checks the output in the aux file
  133. and decides how many times to use LaTeXAction, and BibTeXAction."""
  134. global must_rerun_latex
  135. # This routine is called with two actions. In this file for DVI builds
  136. # with LaTeXAction and from the pdflatex.py with PDFLaTeXAction
  137. # set this up now for the case where the user requests a different extension
  138. # for the target filename
  139. if (XXXLaTeXAction == LaTeXAction):
  140. callerSuffix = ".dvi"
  141. else:
  142. callerSuffix = env['PDFSUFFIX']
  143. basename = SCons.Util.splitext(str(source[0]))[0]
  144. basedir = os.path.split(str(source[0]))[0]
  145. basefile = os.path.split(str(basename))[1]
  146. abspath = os.path.abspath(basedir)
  147. targetext = os.path.splitext(str(target[0]))[1]
  148. targetdir = os.path.split(str(target[0]))[0]
  149. saved_env = {}
  150. for var in SCons.Scanner.LaTeX.LaTeX.env_variables:
  151. saved_env[var] = modify_env_var(env, var, abspath)
  152. # Create base file names with the target directory since the auxiliary files
  153. # will be made there. That's because the *COM variables have the cd
  154. # command in the prolog. We check
  155. # for the existence of files before opening them--even ones like the
  156. # aux file that TeX always creates--to make it possible to write tests
  157. # with stubs that don't necessarily generate all of the same files.
  158. targetbase = os.path.join(targetdir, basefile)
  159. # if there is a \makeindex there will be a .idx and thus
  160. # we have to run makeindex at least once to keep the build
  161. # happy even if there is no index.
  162. # Same for glossaries and nomenclature
  163. src_content = source[0].get_text_contents()
  164. run_makeindex = makeindex_re.search(src_content) and not os.path.exists(targetbase + '.idx')
  165. run_nomenclature = makenomenclature_re.search(src_content) and not os.path.exists(targetbase + '.nlo')
  166. run_glossary = makeglossary_re.search(src_content) and not os.path.exists(targetbase + '.glo')
  167. saved_hashes = {}
  168. suffix_nodes = {}
  169. for suffix in all_suffixes:
  170. theNode = env.fs.File(targetbase + suffix)
  171. suffix_nodes[suffix] = theNode
  172. saved_hashes[suffix] = theNode.get_csig()
  173. if Verbose:
  174. print "hashes: ",saved_hashes
  175. must_rerun_latex = True
  176. #
  177. # routine to update MD5 hash and compare
  178. #
  179. # TODO(1.5): nested scopes
  180. def check_MD5(filenode, suffix, saved_hashes=saved_hashes, targetbase=targetbase):
  181. global must_rerun_latex
  182. # two calls to clear old csig
  183. filenode.clear_memoized_values()
  184. filenode.ninfo = filenode.new_ninfo()
  185. new_md5 = filenode.get_csig()
  186. if saved_hashes[suffix] == new_md5:
  187. if Verbose:
  188. print "file %s not changed" % (targetbase+suffix)
  189. return False # unchanged
  190. saved_hashes[suffix] = new_md5
  191. must_rerun_latex = True
  192. if Verbose:
  193. print "file %s changed, rerunning Latex, new hash = " % (targetbase+suffix), new_md5
  194. return True # changed
  195. # generate the file name that latex will generate
  196. resultfilename = targetbase + callerSuffix
  197. count = 0
  198. while (must_rerun_latex and count < int(env.subst('$LATEXRETRIES'))) :
  199. result = XXXLaTeXAction(target, source, env)
  200. if result != 0:
  201. return result
  202. count = count + 1
  203. must_rerun_latex = False
  204. # Decide if various things need to be run, or run again.
  205. # Read the log file to find all .aux files
  206. logfilename = targetbase + '.log'
  207. logContent = ''
  208. auxfiles = []
  209. if os.path.exists(logfilename):
  210. logContent = open(logfilename, "rb").read()
  211. auxfiles = openout_aux_re.findall(logContent)
  212. # Now decide if bibtex will need to be run.
  213. # The information that bibtex reads from the .aux file is
  214. # pass-independent. If we find (below) that the .bbl file is unchanged,
  215. # then the last latex saw a correct bibliography.
  216. # Therefore only do this on the first pass
  217. if count == 1:
  218. for auxfilename in auxfiles:
  219. target_aux = os.path.join(targetdir, auxfilename)
  220. if os.path.exists(target_aux):
  221. content = open(target_aux, "rb").read()
  222. if string.find(content, "bibdata") != -1:
  223. if Verbose:
  224. print "Need to run bibtex"
  225. bibfile = env.fs.File(targetbase)
  226. result = BibTeXAction(bibfile, bibfile, env)
  227. if result != 0:
  228. return result
  229. must_rerun_latex = check_MD5(suffix_nodes['.bbl'],'.bbl')
  230. break
  231. # Now decide if latex will need to be run again due to index.
  232. if check_MD5(suffix_nodes['.idx'],'.idx') or (count == 1 and run_makeindex):
  233. # We must run makeindex
  234. if Verbose:
  235. print "Need to run makeindex"
  236. idxfile = suffix_nodes['.idx']
  237. result = MakeIndexAction(idxfile, idxfile, env)
  238. if result != 0:
  239. return result
  240. # TO-DO: need to add a way for the user to extend this list for whatever
  241. # auxiliary files they create in other (or their own) packages
  242. # Harder is case is where an action needs to be called -- that should be rare (I hope?)
  243. for index in check_suffixes:
  244. check_MD5(suffix_nodes[index],index)
  245. # Now decide if latex will need to be run again due to nomenclature.
  246. if check_MD5(suffix_nodes['.nlo'],'.nlo') or (count == 1 and run_nomenclature):
  247. # We must run makeindex
  248. if Verbose:
  249. print "Need to run makeindex for nomenclature"
  250. nclfile = suffix_nodes['.nlo']
  251. result = MakeNclAction(nclfile, nclfile, env)
  252. if result != 0:
  253. return result
  254. # Now decide if latex will need to be run again due to glossary.
  255. if check_MD5(suffix_nodes['.glo'],'.glo') or (count == 1 and run_glossary):
  256. # We must run makeindex
  257. if Verbose:
  258. print "Need to run makeindex for glossary"
  259. glofile = suffix_nodes['.glo']
  260. result = MakeGlossaryAction(glofile, glofile, env)
  261. if result != 0:
  262. return result
  263. # Now decide if latex needs to be run yet again to resolve warnings.
  264. if warning_rerun_re.search(logContent):
  265. must_rerun_latex = True
  266. if Verbose:
  267. print "rerun Latex due to latex or package rerun warning"
  268. if rerun_citations_re.search(logContent):
  269. must_rerun_latex = True
  270. if Verbose:
  271. print "rerun Latex due to 'Rerun to get citations correct' warning"
  272. if undefined_references_re.search(logContent):
  273. must_rerun_latex = True
  274. if Verbose:
  275. print "rerun Latex due to undefined references or citations"
  276. if (count >= int(env.subst('$LATEXRETRIES')) and must_rerun_latex):
  277. print "reached max number of retries on Latex ,",int(env.subst('$LATEXRETRIES'))
  278. # end of while loop
  279. # rename Latex's output to what the target name is
  280. if not (str(target[0]) == resultfilename and os.path.exists(resultfilename)):
  281. if os.path.exists(resultfilename):
  282. print "move %s to %s" % (resultfilename, str(target[0]), )
  283. shutil.move(resultfilename,str(target[0]))
  284. # Original comment (when TEXPICTS was not restored):
  285. # The TEXPICTS enviroment variable is needed by a dvi -> pdf step
  286. # later on Mac OSX so leave it
  287. #
  288. # It is also used when searching for pictures (implicit dependencies).
  289. # Why not set the variable again in the respective builder instead
  290. # of leaving local modifications in the environment? What if multiple
  291. # latex builds in different directories need different TEXPICTS?
  292. for var in SCons.Scanner.LaTeX.LaTeX.env_variables:
  293. if var == 'TEXPICTS':
  294. continue
  295. if saved_env[var] is _null:
  296. try:
  297. del env['ENV'][var]
  298. except KeyError:
  299. pass # was never set
  300. else:
  301. env['ENV'][var] = saved_env[var]
  302. return result
  303. def LaTeXAuxAction(target = None, source= None, env=None):
  304. result = InternalLaTeXAuxAction( LaTeXAction, target, source, env )
  305. return result
  306. LaTeX_re = re.compile("\\\\document(style|class)")
  307. def is_LaTeX(flist):
  308. # Scan a file list to decide if it's TeX- or LaTeX-flavored.
  309. for f in flist:
  310. content = f.get_text_contents()
  311. if LaTeX_re.search(content):
  312. return 1
  313. return 0
  314. def TeXLaTeXFunction(target = None, source= None, env=None):
  315. """A builder for TeX and LaTeX that scans the source file to
  316. decide the "flavor" of the source and then executes the appropriate
  317. program."""
  318. if is_LaTeX(source):
  319. result = LaTeXAuxAction(target,source,env)
  320. else:
  321. result = TeXAction(target,source,env)
  322. return result
  323. def TeXLaTeXStrFunction(target = None, source= None, env=None):
  324. """A strfunction for TeX and LaTeX that scans the source file to
  325. decide the "flavor" of the source and then returns the appropriate
  326. command string."""
  327. if env.GetOption("no_exec"):
  328. if is_LaTeX(source):
  329. result = env.subst('$LATEXCOM',0,target,source)+" ..."
  330. else:
  331. result = env.subst("$TEXCOM",0,target,source)+" ..."
  332. else:
  333. result = ''
  334. return result
  335. def tex_eps_emitter(target, source, env):
  336. """An emitter for TeX and LaTeX sources when
  337. executing tex or latex. It will accept .ps and .eps
  338. graphics files
  339. """
  340. (target, source) = tex_emitter_core(target, source, env, TexGraphics)
  341. return (target, source)
  342. def tex_pdf_emitter(target, source, env):
  343. """An emitter for TeX and LaTeX sources when
  344. executing pdftex or pdflatex. It will accept graphics
  345. files of types .pdf, .jpg, .png, .gif, and .tif
  346. """
  347. (target, source) = tex_emitter_core(target, source, env, LatexGraphics)
  348. return (target, source)
  349. def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir):
  350. # for theFile (a Node) update any file_tests and search for graphics files
  351. # then find all included files and call ScanFiles for each of them
  352. content = theFile.get_text_contents()
  353. if Verbose:
  354. print " scanning ",str(theFile)
  355. for i in range(len(file_tests_search)):
  356. if file_tests[i][0] == None:
  357. file_tests[i][0] = file_tests_search[i].search(content)
  358. # recursively call this on each of the included files
  359. inc_files = [ ]
  360. inc_files.extend( include_re.findall(content) )
  361. if Verbose:
  362. print "files included by '%s': "%str(theFile),inc_files
  363. # inc_files is list of file names as given. need to find them
  364. # using TEXINPUTS paths.
  365. for src in inc_files:
  366. srcNode = srcNode = FindFile(src,['.tex','.ltx','.latex'],paths,env,requireExt=False)
  367. if srcNode != None:
  368. file_test = ScanFiles(srcNode, target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir)
  369. if Verbose:
  370. print " done scanning ",str(theFile)
  371. return file_tests
  372. def tex_emitter_core(target, source, env, graphics_extensions):
  373. """An emitter for TeX and LaTeX sources.
  374. For LaTeX sources we try and find the common created files that
  375. are needed on subsequent runs of latex to finish tables of contents,
  376. bibliographies, indices, lists of figures, and hyperlink references.
  377. """
  378. targetbase = SCons.Util.splitext(str(target[0]))[0]
  379. basename = SCons.Util.splitext(str(source[0]))[0]
  380. basefile = os.path.split(str(basename))[1]
  381. basedir = os.path.split(str(source[0]))[0]
  382. targetdir = os.path.split(str(target[0]))[0]
  383. abspath = os.path.abspath(basedir)
  384. target[0].attributes.path = abspath
  385. #
  386. # file names we will make use of in searching the sources and log file
  387. #
  388. emit_suffixes = ['.aux', '.log', '.ilg', '.blg', '.nls', '.nlg', '.gls', '.glg'] + all_suffixes
  389. auxfilename = targetbase + '.aux'
  390. logfilename = targetbase + '.log'
  391. env.SideEffect(auxfilename,target[0])
  392. env.SideEffect(logfilename,target[0])
  393. env.Clean(target[0],auxfilename)
  394. env.Clean(target[0],logfilename)
  395. content = source[0].get_text_contents()
  396. idx_exists = os.path.exists(targetbase + '.idx')
  397. nlo_exists = os.path.exists(targetbase + '.nlo')
  398. glo_exists = os.path.exists(targetbase + '.glo')
  399. # set up list with the regular expressions
  400. # we use to find features used
  401. file_tests_search = [auxfile_re,
  402. makeindex_re,
  403. bibliography_re,
  404. tableofcontents_re,
  405. listoffigures_re,
  406. listoftables_re,
  407. hyperref_re,
  408. makenomenclature_re,
  409. makeglossary_re,
  410. beamer_re ]
  411. # set up list with the file suffixes that need emitting
  412. # when a feature is found
  413. file_tests_suff = [['.aux'],
  414. ['.idx', '.ind', '.ilg'],
  415. ['.bbl', '.blg'],
  416. ['.toc'],
  417. ['.lof'],
  418. ['.lot'],
  419. ['.out'],
  420. ['.nlo', '.nls', '.nlg'],
  421. ['.glo', '.gls', '.glg'],
  422. ['.nav', '.snm', '.out', '.toc'] ]
  423. # build the list of lists
  424. file_tests = []
  425. for i in range(len(file_tests_search)):
  426. file_tests.append( [None, file_tests_suff[i]] )
  427. # TO-DO: need to add a way for the user to extend this list for whatever
  428. # auxiliary files they create in other (or their own) packages
  429. # get path list from both env['TEXINPUTS'] and env['ENV']['TEXINPUTS']
  430. savedpath = modify_env_var(env, 'TEXINPUTS', abspath)
  431. paths = env['ENV']['TEXINPUTS']
  432. if SCons.Util.is_List(paths):
  433. pass
  434. else:
  435. # Split at os.pathsep to convert into absolute path
  436. # TODO(1.5)
  437. #paths = paths.split(os.pathsep)
  438. paths = string.split(paths, os.pathsep)
  439. # now that we have the path list restore the env
  440. if savedpath is _null:
  441. try:
  442. del env['ENV']['TEXINPUTS']
  443. except KeyError:
  444. pass # was never set
  445. else:
  446. env['ENV']['TEXINPUTS'] = savedpath
  447. if Verbose:
  448. print "search path ",paths
  449. file_tests = ScanFiles(source[0], target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir)
  450. for (theSearch,suffix_list) in file_tests:
  451. if theSearch:
  452. for suffix in suffix_list:
  453. env.SideEffect(targetbase + suffix,target[0])
  454. env.Clean(target[0],targetbase + suffix)
  455. # read log file to get all other files that latex creates and will read on the next pass
  456. if os.path.exists(logfilename):
  457. content = open(logfilename, "rb").read()
  458. out_files = openout_re.findall(content)
  459. env.SideEffect(out_files,target[0])
  460. env.Clean(target[0],out_files)
  461. return (target, source)
  462. TeXLaTeXAction = None
  463. def generate(env):
  464. """Add Builders and construction variables for TeX to an Environment."""
  465. # A generic tex file Action, sufficient for all tex files.
  466. global TeXAction
  467. if TeXAction is None:
  468. TeXAction = SCons.Action.Action("$TEXCOM", "$TEXCOMSTR")
  469. # An Action to build a latex file. This might be needed more
  470. # than once if we are dealing with labels and bibtex.
  471. global LaTeXAction
  472. if LaTeXAction is None:
  473. LaTeXAction = SCons.Action.Action("$LATEXCOM", "$LATEXCOMSTR")
  474. # Define an action to run BibTeX on a file.
  475. global BibTeXAction
  476. if BibTeXAction is None:
  477. BibTeXAction = SCons.Action.Action("$BIBTEXCOM", "$BIBTEXCOMSTR")
  478. # Define an action to run MakeIndex on a file.
  479. global MakeIndexAction
  480. if MakeIndexAction is None:
  481. MakeIndexAction = SCons.Action.Action("$MAKEINDEXCOM", "$MAKEINDEXCOMSTR")
  482. # Define an action to run MakeIndex on a file for nomenclatures.
  483. global MakeNclAction
  484. if MakeNclAction is None:
  485. MakeNclAction = SCons.Action.Action("$MAKENCLCOM", "$MAKENCLCOMSTR")
  486. # Define an action to run MakeIndex on a file for glossaries.
  487. global MakeGlossaryAction
  488. if MakeGlossaryAction is None:
  489. MakeGlossaryAction = SCons.Action.Action("$MAKEGLOSSARYCOM", "$MAKEGLOSSARYCOMSTR")
  490. global TeXLaTeXAction
  491. if TeXLaTeXAction is None:
  492. TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction,
  493. strfunction=TeXLaTeXStrFunction)
  494. import dvi
  495. dvi.generate(env)
  496. bld = env['BUILDERS']['DVI']
  497. bld.add_action('.tex', TeXLaTeXAction)
  498. bld.add_emitter('.tex', tex_eps_emitter)
  499. env['TEX'] = 'tex'
  500. env['TEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode')
  501. env['TEXCOM'] = 'cd ${TARGET.dir} && $TEX $TEXFLAGS ${SOURCE.file}'
  502. # Duplicate from latex.py. If latex.py goes away, then this is still OK.
  503. env['LATEX'] = 'latex'
  504. env['LATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode')
  505. env['LATEXCOM'] = 'cd ${TARGET.dir} && $LATEX $LATEXFLAGS ${SOURCE.file}'
  506. env['LATEXRETRIES'] = 3
  507. env['BIBTEX'] = 'bibtex'
  508. env['BIBTEXFLAGS'] = SCons.Util.CLVar('')
  509. env['BIBTEXCOM'] = 'cd ${TARGET.dir} && $BIBTEX $BIBTEXFLAGS ${SOURCE.filebase}'
  510. env['MAKEINDEX'] = 'makeindex'
  511. env['MAKEINDEXFLAGS'] = SCons.Util.CLVar('')
  512. env['MAKEINDEXCOM'] = 'cd ${TARGET.dir} && $MAKEINDEX $MAKEINDEXFLAGS ${SOURCE.file}'
  513. env['MAKEGLOSSARY'] = 'makeindex'
  514. env['MAKEGLOSSARYSTYLE'] = '${SOURCE.filebase}.ist'
  515. env['MAKEGLOSSARYFLAGS'] = SCons.Util.CLVar('-s ${MAKEGLOSSARYSTYLE} -t ${SOURCE.filebase}.glg')
  516. env['MAKEGLOSSARYCOM'] = 'cd ${TARGET.dir} && $MAKEGLOSSARY ${SOURCE.filebase}.glo $MAKEGLOSSARYFLAGS -o ${SOURCE.filebase}.gls'
  517. env['MAKENCL'] = 'makeindex'
  518. env['MAKENCLSTYLE'] = '$nomencl.ist'
  519. env['MAKENCLFLAGS'] = '-s ${MAKENCLSTYLE} -t ${SOURCE.filebase}.nlg'
  520. env['MAKENCLCOM'] = 'cd ${TARGET.dir} && $MAKENCL ${SOURCE.filebase}.nlo $MAKENCLFLAGS -o ${SOURCE.filebase}.nls'
  521. # Duplicate from pdflatex.py. If latex.py goes away, then this is still OK.
  522. env['PDFLATEX'] = 'pdflatex'
  523. env['PDFLATEXFLAGS'] = SCons.Util.CLVar('-interaction=nonstopmode')
  524. env['PDFLATEXCOM'] = 'cd ${TARGET.dir} && $PDFLATEX $PDFLATEXFLAGS ${SOURCE.file}'
  525. def exists(env):
  526. return env.Detect('tex')
  527. # Local Variables:
  528. # tab-width:4
  529. # indent-tabs-mode:nil
  530. # End:
  531. # vim: set expandtab tabstop=4 shiftwidth=4: