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
8import optparse
9import os
10import sys
11
12import chrome_paths
13import cpp_source
14
15sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
16import lastchange
17
18
19def 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
40if __name__ == '__main__':
41  sys.exit(main())
42
43