Followon to PR #4348: more bool fixes
[scons.git] / SCons / Tool / pdf.py
blob74b2449409ef35c779a9bc42056836ca65e6f20f
1 # MIT License
3 # Copyright The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 """Common PDF Builder definition.
26 This is for various other Tool modules that use it.
27 Add an explicit action to run epstopdf to convert .eps files to .pdf
28 """
30 import SCons.Builder
31 import SCons.Tool
33 PDFBuilder = None
35 EpsPdfAction = SCons.Action.Action('$EPSTOPDFCOM', '$EPSTOPDFCOMSTR')
37 def generate(env) -> None:
38 try:
39 env['BUILDERS']['PDF']
40 except KeyError:
41 global PDFBuilder
42 if PDFBuilder is None:
43 PDFBuilder = SCons.Builder.Builder(action = {},
44 source_scanner = SCons.Tool.PDFLaTeXScanner,
45 prefix = '$PDFPREFIX',
46 suffix = '$PDFSUFFIX',
47 emitter = {},
48 source_ext_match = None,
49 single_source=True)
50 env['BUILDERS']['PDF'] = PDFBuilder
52 env['PDFPREFIX'] = ''
53 env['PDFSUFFIX'] = '.pdf'
55 # put the epstopdf builder in this routine so we can add it after
56 # the pdftex builder so that one is the default for no source suffix
57 def generate2(env) -> None:
58 bld = env['BUILDERS']['PDF']
59 #bld.add_action('.ps', EpsPdfAction) # this is covered by direct Ghostcript action in gs.py
60 bld.add_action('.eps', EpsPdfAction)
62 env['EPSTOPDF'] = 'epstopdf'
63 env['EPSTOPDFFLAGS'] = SCons.Util.CLVar('')
64 env['EPSTOPDFCOM'] = '$EPSTOPDF $EPSTOPDFFLAGS ${SOURCE} --outfile=${TARGET}'
66 def exists(env) -> bool:
67 # This only puts a skeleton Builder in place, so if someone
68 # references this Tool directly, it's always "available."
69 return True
71 # Local Variables:
72 # tab-width:4
73 # indent-tabs-mode:nil
74 # End:
75 # vim: set expandtab tabstop=4 shiftwidth=4: