Home | History | Annotate | Download | only in chromedriver
      1 #!/usr/bin/env python
      2 # Copyright 2013 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 """Embeds Chrome user data files in C++ code."""
      7 
      8 import optparse
      9 import os
     10 import sys
     11 
     12 import chrome_paths
     13 import cpp_source
     14 
     15 sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
     16 import lastchange
     17 
     18 
     19 def main():
     20   parser = optparse.OptionParser()
     21   parser.add_option('', '--version-file')
     22   parser.add_option(
     23       '', '--directory', type='string', default='.',
     24       help='Path to directory where the cc/h  file should be created')
     25   options, args = parser.parse_args()
     26 
     27   version = open(options.version_file, 'r').read().strip()
     28   revision = lastchange.FetchVersionInfo(None).revision
     29   if revision:
     30     version += '.' + revision.strip()
     31 
     32   global_string_map = {
     33       'kChromeDriverVersion': version
     34   }
     35   cpp_source.WriteSource('version',
     36                          'chrome/test/chromedriver',
     37                          options.directory, global_string_map)
     38 
     39 
     40 if __name__ == '__main__':
     41   sys.exit(main())
     42 
     43