renamed SCons.Tool.ninja -> SCons.Tool.ninja_tool and added alias in tool loading...
[scons.git] / SCons / Tool / wix.py
blob617abf27385b8f78b8d8695153c906a9696c713f
1 """SCons.Tool.wix
3 Tool-specific initialization for wix, the Windows Installer XML Tool.
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 """
11 # __COPYRIGHT__
13 # Permission is hereby granted, free of charge, to any person obtaining
14 # a copy of this software and associated documentation files (the
15 # "Software"), to deal in the Software without restriction, including
16 # without limitation the rights to use, copy, modify, merge, publish,
17 # distribute, sublicense, and/or sell copies of the Software, and to
18 # permit persons to whom the Software is furnished to do so, subject to
19 # the following conditions:
21 # The above copyright notice and this permission notice shall be included
22 # in all copies or substantial portions of the Software.
24 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
26 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
35 import SCons.Builder
36 import SCons.Action
37 import os
39 def generate(env) -> None:
40 """Add Builders and construction variables for WiX to an Environment."""
41 if not exists(env):
42 return
44 env['WIXCANDLEFLAGS'] = ['-nologo']
45 env['WIXCANDLEINCLUDE'] = []
46 env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}'
48 env['WIXLIGHTFLAGS'].append( '-nologo' )
49 env['WIXLIGHTCOM'] = "$WIXLIGHT $WIXLIGHTFLAGS -out ${TARGET} ${SOURCES}"
50 env['WIXSRCSUF'] = '.wxs'
51 env['WIXOBJSUF'] = '.wixobj'
53 object_builder = SCons.Builder.Builder(
54 action = '$WIXCANDLECOM',
55 suffix = '$WIXOBJSUF',
56 src_suffix = '$WIXSRCSUF')
58 linker_builder = SCons.Builder.Builder(
59 action = '$WIXLIGHTCOM',
60 src_suffix = '$WIXOBJSUF',
61 src_builder = object_builder)
63 env['BUILDERS']['WiX'] = linker_builder
65 def exists(env):
66 env['WIXCANDLE'] = 'candle.exe'
67 env['WIXLIGHT'] = 'light.exe'
69 # try to find the candle.exe and light.exe tools and
70 # add the install directory to light libpath.
71 for path in os.environ['PATH'].split(os.pathsep):
72 if not path:
73 continue
75 # workaround for some weird python win32 bug.
76 if path[0] == '"' and path[-1:]=='"':
77 path = path[1:-1]
79 # normalize the path
80 path = os.path.normpath(path)
82 # search for the tools in the PATH environment variable
83 try:
84 files = os.listdir(path)
85 if env['WIXCANDLE'] in files and env['WIXLIGHT'] in files:
86 env.PrependENVPath('PATH', path)
87 # include appropriate flags if running WiX 2.0
88 if 'wixui.wixlib' in files and 'WixUI_en-us.wxl' in files:
89 env['WIXLIGHTFLAGS'] = [ os.path.join( path, 'wixui.wixlib' ),
90 '-loc',
91 os.path.join( path, 'WixUI_en-us.wxl' ) ]
92 else:
93 env['WIXLIGHTFLAGS'] = []
94 return 1
95 except OSError:
96 pass # ignore this, could be a stale PATH entry.
98 return None
100 # Local Variables:
101 # tab-width:4
102 # indent-tabs-mode:nil
103 # End:
104 # vim: set expandtab tabstop=4 shiftwidth=4: