• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
2# reserved. Use of this source code is governed by a BSD-style license that
3# can be found in the LICENSE file.
4
5from __future__ import absolute_import
6from cef_parser import get_copyright
7from cef_version import VersionFormatter
8from date_util import *
9from file_util import *
10import git_util as git
11import sys
12
13
14def make_version_header(header):
15  if not git.is_checkout('.'):
16    raise Exception('Not a valid checkout')
17
18  result = get_copyright(full=True, translator=False) + \
19"""//
20// ---------------------------------------------------------------------------
21//
22// This file was generated by the make_version_header.py tool.
23//
24
25#ifndef CEF_INCLUDE_CEF_VERSION_H_
26#define CEF_INCLUDE_CEF_VERSION_H_
27
28#define CEF_VERSION "$VERSION$"
29#define CEF_VERSION_MAJOR $VERSION_MAJOR$
30#define CEF_VERSION_MINOR $VERSION_MINOR$
31#define CEF_VERSION_PATCH $VERSION_PATCH$
32#define CEF_COMMIT_NUMBER $COMMIT_NUMBER$
33#define CEF_COMMIT_HASH "$COMMIT_HASH$"
34#define COPYRIGHT_YEAR $YEAR$
35
36#define CHROME_VERSION_MAJOR $CHROME_MAJOR$
37#define CHROME_VERSION_MINOR $CHROME_MINOR$
38#define CHROME_VERSION_BUILD $CHROME_BUILD$
39#define CHROME_VERSION_PATCH $CHROME_PATCH$
40
41#define DO_MAKE_STRING(p) #p
42#define MAKE_STRING(p) DO_MAKE_STRING(p)
43
44#ifndef APSTUDIO_HIDDEN_SYMBOLS
45
46#include "include/internal/cef_export.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52// Returns CEF version information for the libcef library. The |entry|
53// parameter describes which version component will be returned:
54// 0 - CEF_VERSION_MAJOR
55// 1 - CEF_VERSION_MINOR
56// 2 - CEF_VERSION_PATCH
57// 3 - CEF_COMMIT_NUMBER
58// 4 - CHROME_VERSION_MAJOR
59// 5 - CHROME_VERSION_MINOR
60// 6 - CHROME_VERSION_BUILD
61// 7 - CHROME_VERSION_PATCH
62///
63CEF_EXPORT int cef_version_info(int entry);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif  // APSTUDIO_HIDDEN_SYMBOLS
70
71#endif  // CEF_INCLUDE_CEF_VERSION_H_
72"""
73
74  formatter = VersionFormatter()
75
76  # Substitute hash values for placeholders.
77  result = result.replace('$YEAR$', get_year())
78  result = result.replace('$VERSION$', formatter.get_version_string())
79
80  commit_components = formatter.get_cef_commit_components()
81  for key in ('HASH', 'NUMBER'):
82    result = result.replace('$COMMIT_%s$' % key, str(commit_components[key]))
83
84  version_parts = formatter.get_version_parts()
85  for key in ('MAJOR', 'MINOR', 'PATCH'):
86    result = result.replace('$VERSION_%s$' % key, str(version_parts[key]))
87
88  chrome_version_components = formatter.get_chrome_version_components()
89  for key in ('MAJOR', 'MINOR', 'BUILD', 'PATCH'):
90    result = result.replace('$CHROME_%s$' % key,
91                            str(chrome_version_components[key]))
92
93  return result
94
95
96def write_version_header(output):
97  result = make_version_header(output)
98  return write_file_if_changed(output, result)
99
100
101def main(argv):
102  if len(argv) < 2:
103    print(("Usage:\n  %s <output_filename>" % argv[0]))
104    sys.exit(-1)
105  write_version_header(argv[1])
106
107
108if '__main__' == __name__:
109  main(sys.argv)
110