Small style stuff
[zxing.git] / cpp / scons / scons-local-2.0.0.final.0 / SCons / Tool / midl.py
1 """SCons.Tool.midl
2
3 Tool-specific initialization for midl (Microsoft IDL compiler).
4
5 There normally shouldn't be any need to import this module directly.
6 It will usually be imported through the generic SCons.Tool.Tool()
7 selection method.
8
9 """
10
11 #
12 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
13 #
14 # Permission is hereby granted, free of charge, to any person obtaining
15 # a copy of this software and associated documentation files (the
16 # "Software"), to deal in the Software without restriction, including
17 # without limitation the rights to use, copy, modify, merge, publish,
18 # distribute, sublicense, and/or sell copies of the Software, and to
19 # permit persons to whom the Software is furnished to do so, subject to
20 # the following conditions:
21 #
22 # The above copyright notice and this permission notice shall be included
23 # in all copies or substantial portions of the Software.
24 #
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
26 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
27 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #
33
34 __revision__ = "src/engine/SCons/Tool/midl.py 5023 2010/06/14 22:05:46 scons"
35
36 import SCons.Action
37 import SCons.Builder
38 import SCons.Defaults
39 import SCons.Scanner.IDL
40 import SCons.Util
41
42 from MSCommon import msvc_exists
43
44 def midl_emitter(target, source, env):
45     """Produces a list of outputs from the MIDL compiler"""
46     base, ext = SCons.Util.splitext(str(target[0]))
47     tlb = target[0]
48     incl = base + '.h'
49     interface = base + '_i.c'
50     t = [tlb, incl, interface]
51
52     midlcom = env['MIDLCOM']
53
54     if midlcom.find('/proxy') != -1:
55         proxy = base + '_p.c'
56         t.append(proxy)
57     if midlcom.find('/dlldata') != -1:
58         dlldata = base + '_data.c'
59         t.append(dlldata)
60     
61     return (t,source)
62
63 idl_scanner = SCons.Scanner.IDL.IDLScan()
64
65 midl_action = SCons.Action.Action('$MIDLCOM', '$MIDLCOMSTR')
66
67 midl_builder = SCons.Builder.Builder(action = midl_action,
68                                      src_suffix = '.idl',
69                                      suffix='.tlb',
70                                      emitter = midl_emitter,
71                                      source_scanner = idl_scanner)
72
73 def generate(env):
74     """Add Builders and construction variables for midl to an Environment."""
75
76     env['MIDL']          = 'MIDL.EXE'
77     env['MIDLFLAGS']     = SCons.Util.CLVar('/nologo')
78     env['MIDLCOM']       = '$MIDL $MIDLFLAGS /tlb ${TARGETS[0]} /h ${TARGETS[1]} /iid ${TARGETS[2]} /proxy ${TARGETS[3]} /dlldata ${TARGETS[4]} $SOURCE 2> NUL'
79     env['BUILDERS']['TypeLibrary'] = midl_builder
80
81 def exists(env):
82     return msvc_exists()
83
84 # Local Variables:
85 # tab-width:4
86 # indent-tabs-mode:nil
87 # End:
88 # vim: set expandtab tabstop=4 shiftwidth=4: