You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.7 KiB

6 years ago
  1. """SCons.Tool.pdftex
  2. Tool-specific initialization for pdftex.
  3. Generates .pdf files from .tex files
  4. There normally shouldn't be any need to import this module directly.
  5. It will usually be imported through the generic SCons.Tool.Tool()
  6. selection method.
  7. """
  8. #
  9. # Copyright (c) 2001 - 2017 The SCons Foundation
  10. #
  11. # Permission is hereby granted, free of charge, to any person obtaining
  12. # a copy of this software and associated documentation files (the
  13. # "Software"), to deal in the Software without restriction, including
  14. # without limitation the rights to use, copy, modify, merge, publish,
  15. # distribute, sublicense, and/or sell copies of the Software, and to
  16. # permit persons to whom the Software is furnished to do so, subject to
  17. # the following conditions:
  18. #
  19. # The above copyright notice and this permission notice shall be included
  20. # in all copies or substantial portions of the Software.
  21. #
  22. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  23. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  24. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. #
  30. __revision__ = "src/engine/SCons/Tool/pdftex.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  31. import os
  32. import SCons.Action
  33. import SCons.Util
  34. import SCons.Tool.tex
  35. PDFTeXAction = None
  36. # This action might be needed more than once if we are dealing with
  37. # labels and bibtex.
  38. PDFLaTeXAction = None
  39. def PDFLaTeXAuxAction(target = None, source= None, env=None):
  40. result = SCons.Tool.tex.InternalLaTeXAuxAction( PDFLaTeXAction, target, source, env )
  41. return result
  42. def PDFTeXLaTeXFunction(target = None, source= None, env=None):
  43. """A builder for TeX and LaTeX that scans the source file to
  44. decide the "flavor" of the source and then executes the appropriate
  45. program."""
  46. basedir = os.path.split(str(source[0]))[0]
  47. abspath = os.path.abspath(basedir)
  48. if SCons.Tool.tex.is_LaTeX(source,env,abspath):
  49. result = PDFLaTeXAuxAction(target,source,env)
  50. if result != 0:
  51. SCons.Tool.tex.check_file_error_message(env['PDFLATEX'])
  52. else:
  53. result = PDFTeXAction(target,source,env)
  54. if result != 0:
  55. SCons.Tool.tex.check_file_error_message(env['PDFTEX'])
  56. return result
  57. PDFTeXLaTeXAction = None
  58. def generate(env):
  59. """Add Builders and construction variables for pdftex to an Environment."""
  60. global PDFTeXAction
  61. if PDFTeXAction is None:
  62. PDFTeXAction = SCons.Action.Action('$PDFTEXCOM', '$PDFTEXCOMSTR')
  63. global PDFLaTeXAction
  64. if PDFLaTeXAction is None:
  65. PDFLaTeXAction = SCons.Action.Action("$PDFLATEXCOM", "$PDFLATEXCOMSTR")
  66. global PDFTeXLaTeXAction
  67. if PDFTeXLaTeXAction is None:
  68. PDFTeXLaTeXAction = SCons.Action.Action(PDFTeXLaTeXFunction,
  69. strfunction=SCons.Tool.tex.TeXLaTeXStrFunction)
  70. env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes)
  71. from . import pdf
  72. pdf.generate(env)
  73. bld = env['BUILDERS']['PDF']
  74. bld.add_action('.tex', PDFTeXLaTeXAction)
  75. bld.add_emitter('.tex', SCons.Tool.tex.tex_pdf_emitter)
  76. # Add the epstopdf builder after the pdftex builder
  77. # so pdftex is the default for no source suffix
  78. pdf.generate2(env)
  79. SCons.Tool.tex.generate_common(env)
  80. def exists(env):
  81. SCons.Tool.tex.generate_darwin(env)
  82. return env.Detect('pdftex')
  83. # Local Variables:
  84. # tab-width:4
  85. # indent-tabs-mode:nil
  86. # End:
  87. # vim: set expandtab tabstop=4 shiftwidth=4: