2012-04-03 03:34:16 +02:00
|
|
|
# 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.
|
|
|
|
|
2020-01-09 21:22:11 +01:00
|
|
|
from __future__ import absolute_import
|
2020-04-30 21:59:23 +02:00
|
|
|
from cef_parser import get_copyright
|
2019-03-14 22:37:47 +01:00
|
|
|
from cef_version import VersionFormatter
|
2012-04-03 03:34:16 +02:00
|
|
|
from date_util import *
|
|
|
|
from file_util import *
|
|
|
|
import git_util as git
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
def make_version_header(header):
|
2019-03-14 22:37:47 +01:00
|
|
|
if not git.is_checkout('.'):
|
|
|
|
raise Exception('Not a valid checkout')
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
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_
|
|
|
|
"""
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2019-03-14 22:37:47 +01:00
|
|
|
formatter = VersionFormatter()
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
# 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()
|
2019-03-14 22:37:47 +01:00
|
|
|
for key in ('MAJOR', 'MINOR', 'PATCH'):
|
2020-04-30 21:59:23 +02:00
|
|
|
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)
|