mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-08 07:41:04 +01:00
d65483ae16
The cef_api_hash.h file was previously only updated when the translator tool was run manually. Forgetting to run the translator tool after changing include/internal/cef_types*.h files would result in cef_parser.py incorrectly computing the CEF minor version number for future builds. By updating this file automatically at build time the number of errors should be reduced.
110 lines
3.0 KiB
Python
110 lines
3.0 KiB
Python
# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
|
# reserved. Use of this source code is governed by a BSD-style license that
|
|
# can be found in the LICENSE file.
|
|
|
|
from __future__ import absolute_import
|
|
from cef_parser import get_copyright
|
|
from cef_version import VersionFormatter
|
|
from date_util import *
|
|
from file_util import *
|
|
import git_util as git
|
|
import sys
|
|
|
|
|
|
def make_version_header(header):
|
|
if not git.is_checkout('.'):
|
|
raise Exception('Not a valid checkout')
|
|
|
|
result = get_copyright(full=True, translator=False) + \
|
|
"""//
|
|
// ---------------------------------------------------------------------------
|
|
//
|
|
// This file was generated by the make_version_header.py tool.
|
|
//
|
|
|
|
#ifndef CEF_INCLUDE_CEF_VERSION_H_
|
|
#define CEF_INCLUDE_CEF_VERSION_H_
|
|
|
|
#define CEF_VERSION "$VERSION$"
|
|
#define CEF_VERSION_MAJOR $VERSION_MAJOR$
|
|
#define CEF_VERSION_MINOR $VERSION_MINOR$
|
|
#define CEF_VERSION_PATCH $VERSION_PATCH$
|
|
#define CEF_COMMIT_NUMBER $COMMIT_NUMBER$
|
|
#define CEF_COMMIT_HASH "$COMMIT_HASH$"
|
|
#define COPYRIGHT_YEAR $YEAR$
|
|
|
|
#define CHROME_VERSION_MAJOR $CHROME_MAJOR$
|
|
#define CHROME_VERSION_MINOR $CHROME_MINOR$
|
|
#define CHROME_VERSION_BUILD $CHROME_BUILD$
|
|
#define CHROME_VERSION_PATCH $CHROME_PATCH$
|
|
|
|
#define DO_MAKE_STRING(p) #p
|
|
#define MAKE_STRING(p) DO_MAKE_STRING(p)
|
|
|
|
#ifndef APSTUDIO_HIDDEN_SYMBOLS
|
|
|
|
#include "include/internal/cef_export.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Returns CEF version information for the libcef library. The |entry|
|
|
// parameter describes which version component will be returned:
|
|
// 0 - CEF_VERSION_MAJOR
|
|
// 1 - CEF_VERSION_MINOR
|
|
// 2 - CEF_VERSION_PATCH
|
|
// 3 - CEF_COMMIT_NUMBER
|
|
// 4 - CHROME_VERSION_MAJOR
|
|
// 5 - CHROME_VERSION_MINOR
|
|
// 6 - CHROME_VERSION_BUILD
|
|
// 7 - CHROME_VERSION_PATCH
|
|
///
|
|
CEF_EXPORT int cef_version_info(int entry);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // APSTUDIO_HIDDEN_SYMBOLS
|
|
|
|
#endif // CEF_INCLUDE_CEF_VERSION_H_
|
|
"""
|
|
|
|
formatter = VersionFormatter()
|
|
|
|
# Substitute hash values for placeholders.
|
|
result = result.replace('$YEAR$', get_year())
|
|
result = result.replace('$VERSION$', formatter.get_version_string())
|
|
|
|
commit_components = formatter.get_cef_commit_components()
|
|
for key in ('HASH', 'NUMBER'):
|
|
result = result.replace('$COMMIT_%s$' % key, str(commit_components[key]))
|
|
|
|
version_parts = formatter.get_version_parts()
|
|
for key in ('MAJOR', 'MINOR', 'PATCH'):
|
|
result = result.replace('$VERSION_%s$' % key, str(version_parts[key]))
|
|
|
|
chrome_version_components = formatter.get_chrome_version_components()
|
|
for key in ('MAJOR', 'MINOR', 'BUILD', 'PATCH'):
|
|
result = result.replace('$CHROME_%s$' % key,
|
|
str(chrome_version_components[key]))
|
|
|
|
return result
|
|
|
|
|
|
def write_version_header(output):
|
|
result = make_version_header(output)
|
|
return write_file_if_changed(output, result)
|
|
|
|
|
|
def main(argv):
|
|
if len(argv) < 2:
|
|
print(("Usage:\n %s <output_filename>" % argv[0]))
|
|
sys.exit(-1)
|
|
write_version_header(argv[1])
|
|
|
|
|
|
if '__main__' == __name__:
|
|
main(sys.argv)
|