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.

95 lines
3.4 KiB

6 years ago
  1. """SCons.Tool.dvips
  2. Tool-specific initialization for dvips.
  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 - 2017 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/dvips.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  30. import SCons.Action
  31. import SCons.Builder
  32. import SCons.Tool.dvipdf
  33. import SCons.Util
  34. def DviPsFunction(target = None, source= None, env=None):
  35. result = SCons.Tool.dvipdf.DviPdfPsFunction(PSAction,target,source,env)
  36. return result
  37. def DviPsStrFunction(target = None, source= None, env=None):
  38. """A strfunction for dvipdf that returns the appropriate
  39. command string for the no_exec options."""
  40. if env.GetOption("no_exec"):
  41. result = env.subst('$PSCOM',0,target,source)
  42. else:
  43. result = ''
  44. return result
  45. PSAction = None
  46. DVIPSAction = None
  47. PSBuilder = None
  48. def generate(env):
  49. """Add Builders and construction variables for dvips to an Environment."""
  50. global PSAction
  51. if PSAction is None:
  52. PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR')
  53. global DVIPSAction
  54. if DVIPSAction is None:
  55. DVIPSAction = SCons.Action.Action(DviPsFunction, strfunction = DviPsStrFunction)
  56. global PSBuilder
  57. if PSBuilder is None:
  58. PSBuilder = SCons.Builder.Builder(action = PSAction,
  59. prefix = '$PSPREFIX',
  60. suffix = '$PSSUFFIX',
  61. src_suffix = '.dvi',
  62. src_builder = 'DVI',
  63. single_source=True)
  64. env['BUILDERS']['PostScript'] = PSBuilder
  65. env['DVIPS'] = 'dvips'
  66. env['DVIPSFLAGS'] = SCons.Util.CLVar('')
  67. # I'm not quite sure I got the directories and filenames right for variant_dir
  68. # We need to be in the correct directory for the sake of latex \includegraphics eps included files.
  69. env['PSCOM'] = 'cd ${TARGET.dir} && $DVIPS $DVIPSFLAGS -o ${TARGET.file} ${SOURCE.file}'
  70. env['PSPREFIX'] = ''
  71. env['PSSUFFIX'] = '.ps'
  72. def exists(env):
  73. SCons.Tool.tex.generate_darwin(env)
  74. return env.Detect('dvips')
  75. # Local Variables:
  76. # tab-width:4
  77. # indent-tabs-mode:nil
  78. # End:
  79. # vim: set expandtab tabstop=4 shiftwidth=4: