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