OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Run 'candle' and 'light' to transform .wxs to .msi.""" | 6 """Run 'candle' and 'light' to transform .wxs to .msi.""" |
7 | 7 |
8 from optparse import OptionParser | 8 from optparse import OptionParser |
9 import os | 9 import os |
10 import subprocess | 10 import subprocess |
11 import sys | 11 import sys |
12 | 12 |
13 def run(command, filter=None): | 13 def run(command, filter=None): |
14 popen = subprocess.Popen( | 14 popen = subprocess.Popen( |
15 command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 15 command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
16 out, _ = popen.communicate() | 16 out, _ = popen.communicate() |
17 for line in out.splitlines(): | 17 for line in out.splitlines(): |
18 if filter and line.strip() != filter: | 18 if filter and line.strip() != filter: |
19 print line | 19 print line |
20 return popen.returncode | 20 return popen.returncode |
21 | 21 |
22 def main(): | 22 def main(): |
23 parser = OptionParser() | 23 parser = OptionParser() |
24 parser.add_option('--wix_path', dest='wix_path') | 24 parser.add_option('--wix_path', dest='wix_path') |
25 parser.add_option('--version', dest='version') | 25 parser.add_option('--version', dest='version') |
26 parser.add_option('--controller_clsid', dest='controller_clsid') | |
27 parser.add_option('--product_dir', dest='product_dir') | 26 parser.add_option('--product_dir', dest='product_dir') |
28 parser.add_option('--intermediate_dir', dest='intermediate_dir') | 27 parser.add_option('--intermediate_dir', dest='intermediate_dir') |
29 parser.add_option('--sas_dll_path', dest='sas_dll_path') | 28 parser.add_option('--sas_dll_path', dest='sas_dll_path') |
30 parser.add_option('-d', dest='define_list', action='append') | 29 parser.add_option('-d', dest='define_list', action='append') |
31 parser.add_option('--input', dest='input') | 30 parser.add_option('--input', dest='input') |
32 parser.add_option('--output', dest='output') | 31 parser.add_option('--output', dest='output') |
33 options, args = parser.parse_args() | 32 options, args = parser.parse_args() |
34 if args: | 33 if args: |
35 parser.error("no positional arguments expected") | 34 parser.error("no positional arguments expected") |
36 parameters = dict(options.__dict__) | 35 parameters = dict(options.__dict__) |
37 | 36 |
38 parameters['basename'] = os.path.splitext(os.path.basename(options.input))[0] | 37 parameters['basename'] = os.path.splitext(os.path.basename(options.input))[0] |
39 parameters['defines'] = '-d' + ' -d'.join(parameters['define_list']) | 38 parameters['defines'] = '-d' + ' -d'.join(parameters['define_list']) |
40 | 39 |
41 common = ( | 40 common = ( |
42 '-nologo ' | 41 '-nologo ' |
43 '-ext "%(wix_path)s\\WixFirewallExtension.dll" ' | 42 '-ext "%(wix_path)s\\WixFirewallExtension.dll" ' |
44 '-ext "%(wix_path)s\\WixUIExtension.dll" ' | 43 '-ext "%(wix_path)s\\WixUIExtension.dll" ' |
45 '-ext "%(wix_path)s\\WixUtilExtension.dll" ' | 44 '-ext "%(wix_path)s\\WixUtilExtension.dll" ' |
46 '"-dControllerClsid="%(controller_clsid)s"" ' | |
47 '-dVersion=%(version)s ' | 45 '-dVersion=%(version)s ' |
48 '"-dFileSource=%(product_dir)s" ' | 46 '"-dFileSource=%(product_dir)s" ' |
49 '-dIconPath=resources/chromoting.ico ' | 47 '-dIconPath=resources/chromoting.ico ' |
50 '"-dSasDllPath=%(sas_dll_path)s/sas.dll" ' | 48 '"-dSasDllPath=%(sas_dll_path)s/sas.dll" ' |
51 '%(defines)s ' | 49 '%(defines)s ' |
52 ) | 50 ) |
53 | 51 |
54 candle_template = ('"%(wix_path)s\\candle" ' + | 52 candle_template = ('"%(wix_path)s\\candle" ' + |
55 common + | 53 common + |
56 '-out "%(intermediate_dir)s/%(basename)s.wixobj" ' + | 54 '-out "%(intermediate_dir)s/%(basename)s.wixobj" ' + |
57 '"%(input)s" ') | 55 '"%(input)s" ') |
58 rc = run(candle_template % parameters, os.path.basename(parameters['input'])) | 56 rc = run(candle_template % parameters, os.path.basename(parameters['input'])) |
59 if rc: | 57 if rc: |
60 return rc | 58 return rc |
61 | 59 |
62 light_template = ('"%(wix_path)s\\light" ' + | 60 light_template = ('"%(wix_path)s\\light" ' + |
63 common + | 61 common + |
64 '-cultures:en-us ' + | 62 '-cultures:en-us ' + |
65 '-sw1076 ' + | 63 '-sw1076 ' + |
66 '-out "%(output)s" ' + | 64 '-out "%(output)s" ' + |
67 '"%(intermediate_dir)s/%(basename)s.wixobj" ') | 65 '"%(intermediate_dir)s/%(basename)s.wixobj" ') |
68 rc = run(light_template % parameters) | 66 rc = run(light_template % parameters) |
69 if rc: | 67 if rc: |
70 return rc | 68 return rc |
71 | 69 |
72 return 0 | 70 return 0 |
73 | 71 |
74 if __name__ == "__main__": | 72 if __name__ == "__main__": |
75 sys.exit(main()) | 73 sys.exit(main()) |
OLD | NEW |