Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

SCons / scons / 635

19 Jan 2019 - 18:10 coverage decreased (-0.6%) to 80.079%
635

Pull #3204

travis-ci

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
Really clean up the rebase problem this time

Signed-off-by: Mats Wichmann <mats@linux.com>
Pull Request #3204: Add wix installer toolset in appveyor setup

23 of 27 new or added lines in 1 file covered. (85.19%)

18737 of 23398 relevant lines covered (80.08%)

4.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.2
/src/engine/SCons/Tool/wix.py
1
"""SCons.Tool.wix
2

3
Tool-specific initialization for wix, the Windows Installer XML Tool.
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
# __COPYRIGHT__
12
#
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:
20
#
21
# The above copyright notice and this permission notice shall be included
22
# in all copies or substantial portions of the Software.
23
#
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.
31
#
32

33
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
8×
34
import os
8×
35
import glob
8×
36

37
import SCons.Builder
8×
38
import SCons.Action
8×
39
import os
8×
40

41
def generate(env):
8×
42
    """Add Builders and construction variables for WiX to an Environment."""
43
    if not exists(env):
2×
44
        return
1×
45

46
    env['WIXCANDLEFLAGS'] = ['-nologo']
1×
47
    env['WIXCANDLEINCLUDE'] = []
1×
48
    env['WIXCANDLECOM'] = '$WIXCANDLE $WIXCANDLEFLAGS -I $WIXCANDLEINCLUDE -o ${TARGET} ${SOURCE}'
1×
49

50
    env['WIXLIGHTFLAGS'].append('-nologo')
1×
51
    env['WIXLIGHTCOM'] = "$WIXLIGHT $WIXLIGHTFLAGS -out ${TARGET} ${SOURCES}"
1×
52
    env['WIXSRCSUF'] = '.wxs'
1×
53
    env['WIXOBJSUF'] = '.wixobj'
1×
54

55
    object_builder = SCons.Builder.Builder(
1×
56
        action      = '$WIXCANDLECOM',
57
        suffix      = '$WIXOBJSUF',
58
        src_suffix  = '$WIXSRCSUF')
59

60
    linker_builder = SCons.Builder.Builder(
1×
61
        action      = '$WIXLIGHTCOM',
62
        src_suffix  = '$WIXOBJSUF',
63
        src_builder = object_builder)
64

65
    env['BUILDERS']['WiX'] = linker_builder
1×
66

67

68
def exists(env):
8×
69
    env['WIXCANDLE'] = 'candle.exe'
8×
70
    env['WIXLIGHT']  = 'light.exe'
8×
71

72
    def check_wix(e, p):
8×
73
        """try to find the candle and light tools; add to path if found."""
74
        try:
8×
75
            files = os.listdir(p)
8×
76
            if e['WIXCANDLE'] in files and e['WIXLIGHT'] in files:
8×
77
                e.PrependENVPath('PATH', p)
1×
78
                # include appropriate flags if running WiX 2.0
79
                if 'wixui.wixlib' in files and 'WixUI_en-us.wxl' in files:
1×
NEW
80
                    e['WIXLIGHTFLAGS'] = [os.path.join(p, 'wixui.wixlib'),
!
81
                                          '-loc',
82
                                          os.path.join(p, 'WixUI_en-us.wxl')]
83
                else:
84
                    e['WIXLIGHTFLAGS'] = []
1×
85
                return 1
1×
86
        except OSError:
8×
87
            pass  # ignore this, could be a stale PATH entry.
8×
88
        return None
8×
89

90
    # look in existing paths first
91
    for path in os.environ['PATH'].split(os.pathsep):
8×
92
        if not path:
8×
93
            continue
1×
94

95
        # workaround for some weird python win32 bug.
96
        if path[0] == '"' and path[-1:] == '"':
8×
97
            path = path[1:-1]
!
98

99
        # normalize the path
100
        path = os.path.normpath(path)
8×
101

102
        if check_wix(env, path):
8×
103
            return 1
1×
104

105
    # Wix is not in scons' PATH. Let's look in typical install locations.
106
    wix_env = os.environ.get('WIX', None)
8×
107
    if wix_env:
8×
NEW
108
        wix_installs = [os.path.join(wix_env, 'bin')]
!
109
    else:
110
        wix_path = r'C:\Program Files (x86)\WiX Toolset v*.*\bin'
8×
111
        wix_installs = glob.glob(wix_path)
8×
112
    for path in wix_installs:
8×
NEW
113
        if check_wix(env, path):
!
NEW
114
            return 1
!
115

116
    return None
8×
117

118
# Local Variables:
119
# tab-width:4
120
# indent-tabs-mode:nil
121
# End:
122
# vim: set expandtab tabstop=4 shiftwidth=4:
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2022 Coveralls, Inc