diff --git a/BUILD.gn b/BUILD.gn index f11ead842..9eee58953 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -303,6 +303,10 @@ gypi_paths2 = exec_script("//cef/tools/gypi_to_gn.py", "scope", [ "cef_paths2.gypi" ]) +includes_common = gypi_paths2.includes_common + gypi_paths2.includes_common_capi +includes_mac = gypi_paths2.includes_mac + gypi_paths2.includes_mac_capi +includes_linux = gypi_paths2.includes_linux + gypi_paths2.includes_linux_capi +includes_win = gypi_paths2.includes_win + gypi_paths2.includes_win_capi # # Targets that will be built when depending on "//cef". @@ -371,7 +375,7 @@ if (is_win) { } static_library("libcef_static") { - sources = gypi_paths2.includes_common + + sources = includes_common + gypi_paths.autogen_cpp_includes + [ "libcef/browser/browser_context.cc", "libcef/browser/browser_context.h", @@ -847,7 +851,7 @@ static_library("libcef_static") { ] if (is_win) { - sources += gypi_paths2.includes_win + [ + sources += includes_win + [ "libcef/browser/browser_main_win.cc", "libcef/browser/native/browser_platform_delegate_native_win.cc", "libcef/browser/native/browser_platform_delegate_native_win.h", @@ -892,7 +896,7 @@ static_library("libcef_static") { } if (is_linux) { - sources += gypi_paths2.includes_linux + [ + sources += includes_linux + [ "libcef/browser/native/browser_platform_delegate_native_linux.cc", "libcef/browser/native/browser_platform_delegate_native_linux.h", "libcef/browser/native/menu_runner_linux.cc", @@ -924,7 +928,7 @@ static_library("libcef_static") { } if (is_mac) { - sources += gypi_paths2.includes_mac + [ + sources += includes_mac + [ "libcef/browser/native/browser_platform_delegate_native_mac.h", "libcef/browser/native/browser_platform_delegate_native_mac.mm", "libcef/browser/native/file_dialog_runner_mac.h", @@ -1138,7 +1142,7 @@ config("libcef_dll_wrapper_config") { # libcef_dll_wrapper target. static_library("libcef_dll_wrapper") { - sources = gypi_paths2.includes_common + + sources = includes_common + gypi_paths.autogen_cpp_includes + gypi_paths2.includes_capi + gypi_paths.autogen_capi_includes + @@ -1494,11 +1498,29 @@ make_pack_header("strings") { ] } +# Generate cef_api_hash.h. +action("make_api_hash_header") { + script = "tools/make_api_hash_header.py" + + # List of all C API files that will be checked for changes by cef_api_hash.py. + inputs = gypi_paths2.includes_common_capi + + gypi_paths2.includes_linux_capi + + gypi_paths2.includes_mac_capi + + gypi_paths2.includes_win_capi + + gypi_paths2.includes_capi + + gypi_paths.autogen_capi_includes + include_dir = [ "include" ] + outputs = [ "$root_out_dir/includes/include/cef_api_hash.h" ] + + args = rebase_path(outputs + include_dir, root_build_dir) +} + # Generate pack files and associated CEF header files. group("cef_make_headers") { deps = [ ":make_pack_header_resources", ":make_pack_header_strings", + ":make_api_hash_header", ] } @@ -1634,8 +1656,8 @@ if (is_mac) { "Resources", ] - sources = gypi_paths2.includes_common + - gypi_paths2.includes_mac + + sources = includes_common + + includes_mac + gypi_paths.autogen_cpp_includes + gypi_paths2.includes_capi + gypi_paths.autogen_capi_includes + @@ -1678,7 +1700,7 @@ if (is_mac) { } } else { shared_library("libcef") { - sources = gypi_paths2.includes_common + + sources = includes_common + gypi_paths.autogen_cpp_includes + gypi_paths2.includes_capi + gypi_paths.autogen_capi_includes + @@ -1690,7 +1712,7 @@ if (is_mac) { ] if (is_win) { - sources += gypi_paths2.includes_win + [ + sources += includes_win + [ "libcef_dll/libcef_dll.rc", ] @@ -1901,8 +1923,8 @@ if (is_mac) { cef_app("cefclient") { helper_info_plist = "tests/cefclient/resources/mac/helper-Info.plist" - helper_sources = gypi_paths2.includes_mac + - gypi_paths2.includes_common + + helper_sources = includes_common + + includes_mac + gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper_mac + gypi_paths2.shared_sources_common + @@ -1915,8 +1937,8 @@ if (is_mac) { ] info_plist = "tests/cefclient/resources/mac/Info.plist" - sources = gypi_paths2.includes_mac + - gypi_paths2.includes_common + + sources = includes_common + + includes_mac + gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper_mac + gypi_paths2.shared_sources_browser + @@ -1974,8 +1996,8 @@ if (is_mac) { cef_app("cefsimple") { helper_info_plist = "tests/cefsimple/mac/helper-Info.plist" - helper_sources = gypi_paths2.includes_mac + - gypi_paths2.includes_common + + helper_sources = includes_common + + includes_mac + gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper_mac + gypi_paths2.cefsimple_sources_mac_helper @@ -1984,8 +2006,8 @@ if (is_mac) { ] info_plist = "tests/cefsimple/mac/Info.plist" - sources = gypi_paths2.includes_mac + - gypi_paths2.includes_common + + sources = includes_common + + includes_mac + gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper_mac + gypi_paths2.cefsimple_sources_common + @@ -2051,8 +2073,8 @@ if (is_mac) { ] info_plist = "tests/ceftests/resources/mac/Info.plist" - sources = gypi_paths2.includes_mac + - gypi_paths2.includes_common + + sources = includes_common + + includes_mac + gypi_paths2.includes_wrapper + gypi_paths2.includes_wrapper_mac + gypi_paths2.shared_sources_browser + @@ -2120,7 +2142,7 @@ if (is_mac) { } executable("cefclient") { - sources = gypi_paths2.includes_common + + sources = includes_common + gypi_paths2.includes_wrapper + gypi_paths2.shared_sources_browser + gypi_paths2.shared_sources_common + @@ -2139,7 +2161,7 @@ if (is_mac) { ] if (is_win) { - sources += gypi_paths2.includes_win + + sources += includes_win + gypi_paths2.shared_sources_win + gypi_paths2.cefclient_sources_win @@ -2174,7 +2196,7 @@ if (is_mac) { } if (is_linux) { - sources += gypi_paths2.includes_linux + + sources += includes_linux + gypi_paths2.shared_sources_linux + gypi_paths2.cefclient_sources_linux @@ -2213,7 +2235,7 @@ if (is_mac) { # executable("cefsimple") { - sources = gypi_paths2.includes_common + + sources = includes_common + gypi_paths2.includes_wrapper + gypi_paths2.cefsimple_sources_common @@ -2227,7 +2249,7 @@ if (is_mac) { ] if (is_win) { - sources += gypi_paths2.includes_win + + sources += includes_win + gypi_paths2.cefsimple_sources_win # Set /SUBSYSTEM:WINDOWS. @@ -2247,7 +2269,7 @@ if (is_mac) { } if (is_linux) { - sources += gypi_paths2.includes_linux + + sources += includes_linux + gypi_paths2.cefsimple_sources_linux if (use_x11) { @@ -2278,7 +2300,7 @@ if (is_mac) { executable("ceftests") { testonly = true - sources = gypi_paths2.includes_common + + sources = includes_common + gypi_paths2.includes_wrapper + gypi_paths2.shared_sources_browser + gypi_paths2.shared_sources_common + diff --git a/cef_paths2.gypi b/cef_paths2.gypi index fad6b5c01..5be1dddd4 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -39,19 +39,21 @@ 'include/cef_config.h', 'include/cef_version.h', 'include/internal/cef_export.h', - 'include/internal/cef_logging_internal.h', 'include/internal/cef_ptr.h', + 'include/internal/cef_string_wrappers.h', + 'include/internal/cef_types_wrappers.h', + ], + 'includes_common_capi': [ + 'include/internal/cef_logging_internal.h', 'include/internal/cef_string.h', 'include/internal/cef_string_list.h', 'include/internal/cef_string_map.h', 'include/internal/cef_string_multimap.h', 'include/internal/cef_string_types.h', - 'include/internal/cef_string_wrappers.h', 'include/internal/cef_thread_internal.h', 'include/internal/cef_time.h', 'include/internal/cef_trace_event_internal.h', 'include/internal/cef_types.h', - 'include/internal/cef_types_wrappers.h', ], 'includes_capi': [ 'include/capi/cef_base_capi.h', @@ -75,15 +77,19 @@ 'include/base/internal/cef_atomicops_x86_msvc.h', 'include/base/internal/cef_bind_internal_win.h', 'include/cef_sandbox_win.h', - 'include/internal/cef_types_win.h', 'include/internal/cef_win.h', ], + 'includes_win_capi': [ + 'include/internal/cef_types_win.h', + ], 'includes_mac': [ 'include/base/internal/cef_atomicops_atomicword_compat.h', 'include/base/internal/cef_atomicops_mac.h', 'include/cef_application_mac.h', 'include/cef_sandbox_mac.h', 'include/internal/cef_mac.h', + ], + 'includes_mac_capi': [ 'include/internal/cef_types_mac.h', ], 'includes_linux': [ @@ -92,6 +98,8 @@ 'include/base/internal/cef_atomicops_arm64_gcc.h', 'include/base/internal/cef_atomicops_x86_gcc.h', 'include/internal/cef_linux.h', + ], + 'includes_linux_capi': [ 'include/internal/cef_types_linux.h', ], 'libcef_sources_common': [ diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index dcdd7a8a5..f1ed52bce 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -29,12 +29,7 @@ // // --------------------------------------------------------------------------- // -// This file was generated by the CEF translator tool. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// -// $hash=fd013f5bdcf2333b1f0fb452442d300dffe598e5$ +// This file was generated by the make_api_hash_header.py tool. // #ifndef CEF_INCLUDE_API_HASH_H_ diff --git a/libcef_dll/CMakeLists.txt.in b/libcef_dll/CMakeLists.txt.in index 62dc2b761..a21855379 100644 --- a/libcef_dll/CMakeLists.txt.in +++ b/libcef_dll/CMakeLists.txt.in @@ -23,14 +23,18 @@ set(CEF_TARGET libcef_dll_wrapper) 'append_macro': 'LIBCEF_APPEND_PLATFORM_SOURCES', 'includes': [ 'includes_common', + 'includes_common_capi', 'autogen_cpp_includes', 'includes_capi', 'autogen_capi_includes', 'includes_wrapper', 'includes_wrapper_mac:MACOSX', 'includes_win:WINDOWS', + 'includes_win_capi:WINDOWS', 'includes_mac:MACOSX', + 'includes_mac_capi:MACOSX', 'includes_linux:LINUX', + 'includes_linux_capi:LINUX', 'libcef_dll_wrapper_sources_base', 'libcef_dll_wrapper_sources_common', 'libcef_dll_wrapper_sources_mac:MACOSX', diff --git a/tools/cef_api_hash.py b/tools/cef_api_hash.py index 80632bbb7..2ef623752 100644 --- a/tools/cef_api_hash.py +++ b/tools/cef_api_hash.py @@ -32,12 +32,15 @@ class cef_api_hash: self.platforms = ["windows", "macosx", "linux"] self.platform_files = { + # List of includes_win_capi from cef_paths2.gypi. "windows": [ "internal/cef_types_win.h", ], + # List of includes_mac_capi from cef_paths2.gypi. "macosx": [ "internal/cef_types_mac.h", ], + # List of includes_linux_capi from cef_paths2.gypi. "linux": [ "internal/cef_types_linux.h", ] @@ -45,14 +48,25 @@ class cef_api_hash: self.included_files = [] + # List of include/ and include/internal/ files from cef_paths2.gypi. self.excluded_files = [ + # includes_common "cef_api_hash.h", + "cef_base.h", + "cef_config.h", "cef_version.h", - "internal/cef_tuple.h", - "internal/cef_types_wrappers.h", + "internal/cef_export.h", + "internal/cef_ptr.h", "internal/cef_string_wrappers.h", + "internal/cef_types_wrappers.h", + # includes_win + "cef_sandbox_win.h", "internal/cef_win.h", + # includes_mac + "cef_application_mac.h", + "cef_sandbox_mac.h", "internal/cef_mac.h", + # includes_linux "internal/cef_linux.h", ] diff --git a/tools/cef_parser.py b/tools/cef_parser.py index 0be989d82..75f992ac0 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -469,7 +469,7 @@ def get_next_function_impl(existing, name): return result -def get_copyright(full=False): +def get_copyright(full=False, translator=True): if full: result = \ """// Copyright (c) $YEAR$ Marshall A. Greenblatt. All rights reserved. @@ -508,7 +508,8 @@ def get_copyright(full=False): // can be found in the LICENSE file. """ - result += \ + if translator: + result += \ """// // --------------------------------------------------------------------------- // @@ -521,6 +522,7 @@ def get_copyright(full=False): // """ + # add the copyright year return result.replace('$YEAR$', get_year()) diff --git a/tools/file_util.py b/tools/file_util.py index 0741f6fd4..54d79ee5f 100644 --- a/tools/file_util.py +++ b/tools/file_util.py @@ -47,6 +47,19 @@ def path_exists(name): return os.path.exists(name) +def write_file_if_changed(name, data): + """ Write a file if the contents have changed. Returns True if the file was written. """ + if path_exists(name): + old_contents = read_file(name) + else: + old_contents = '' + + if (data != old_contents): + write_file(name, data) + return True + return False + + def backup_file(name): """ Rename the file to a name that includes the current time stamp. """ move_file(name, name + '.' + time.strftime('%Y-%m-%d-%H-%M-%S')) diff --git a/tools/gclient_hook.py b/tools/gclient_hook.py index e07705491..f0be2d46b 100644 --- a/tools/gclient_hook.py +++ b/tools/gclient_hook.py @@ -29,10 +29,7 @@ else: sys.exit() print("\nGenerating CEF version header file...") -cmd = [ - sys.executable, 'tools/make_version_header.py', '--header', - 'include/cef_version.h' -] +cmd = [sys.executable, 'tools/make_version_header.py', 'include/cef_version.h'] RunAction(cef_dir, cmd) print("\nPatching build configuration and source files for CEF...") diff --git a/tools/make_api_hash_header.py b/tools/make_api_hash_header.py index 610c22b96..2d565f86a 100644 --- a/tools/make_api_hash_header.py +++ b/tools/make_api_hash_header.py @@ -4,8 +4,10 @@ from __future__ import absolute_import from cef_api_hash import cef_api_hash -from cef_parser import * +from cef_parser import get_copyright from file_util import * +import os +import sys def make_api_hash_header(cpp_header_dir): @@ -13,8 +15,14 @@ def make_api_hash_header(cpp_header_dir): api_hash_calculator = cef_api_hash(cpp_header_dir, verbose=False) api_hash = api_hash_calculator.calculate() - result = get_copyright(full=True) + \ -"""#ifndef CEF_INCLUDE_API_HASH_H_ + result = get_copyright(full=True, translator=False) + \ +"""// +// --------------------------------------------------------------------------- +// +// This file was generated by the make_api_hash_header.py tool. +// + +#ifndef CEF_INCLUDE_API_HASH_H_ #define CEF_INCLUDE_API_HASH_H_ #include "include/internal/cef_export.h" @@ -60,19 +68,28 @@ CEF_EXPORT const char* cef_api_hash(int entry); return result -def write_api_hash_header(header, cpp_header_dir): - newcontents = make_api_hash_header(cpp_header_dir) - return (header, newcontents) +def write_api_hash_header(output, cpp_header_dir): + output = os.path.abspath(output) + result = make_api_hash_header(cpp_header_dir) + ret = write_file_if_changed(output, result) + + # Also write to |cpp_header_dir| if a different path from |output|, since we + # need to commit the hash header for cef_version.py to correctly calculate the + # version number based on git history. + header_path = os.path.abspath( + os.path.join(cpp_header_dir, os.path.basename(output))) + if (output != header_path): + write_file_if_changed(header_path, result) + + return ret -# Test the module. -if __name__ == "__main__": - import sys +def main(argv): + if len(argv) < 3: + print(("Usage:\n %s " % argv[0])) + sys.exit(-1) + write_api_hash_header(argv[1], argv[2]) - # Verify that the correct number of command-line arguments are provided. - if len(sys.argv) < 2: - sys.stderr.write('Usage: ' + sys.argv[0] + ' \n') - sys.exit() - # Dump the result to stdout. - sys.stdout.write(make_api_hash_header(sys.argv[1])) +if '__main__' == __name__: + main(sys.argv) diff --git a/tools/make_distrib.py b/tools/make_distrib.py index 2078d8218..80ab514c0 100644 --- a/tools/make_distrib.py +++ b/tools/make_distrib.py @@ -694,6 +694,8 @@ if mode == 'standard' or mode == 'minimal': # transfer common include files transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \ 'include/', include_dir, options.quiet) + transfer_gypi_files(cef_dir, cef_paths2['includes_common_capi'], \ + 'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \ 'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \ @@ -948,6 +950,8 @@ if platform == 'windows': # transfer include files transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \ 'include/', include_dir, options.quiet) + transfer_gypi_files(cef_dir, cef_paths2['includes_win_capi'], \ + 'include/', include_dir, options.quiet) # transfer additional files, if any transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib', 'win'), \ @@ -1094,6 +1098,8 @@ elif platform == 'macosx': # transfer include files transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \ 'include/', include_dir, options.quiet) + transfer_gypi_files(cef_dir, cef_paths2['includes_mac_capi'], \ + 'include/', include_dir, options.quiet) transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper_mac'], \ 'include/', include_dir, options.quiet) @@ -1211,6 +1217,8 @@ elif platform == 'linux': # transfer include files transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \ 'include/', include_dir, options.quiet) + transfer_gypi_files(cef_dir, cef_paths2['includes_linux_capi'], \ + 'include/', include_dir, options.quiet) # transfer additional files, if any transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib', 'linux'), \ diff --git a/tools/make_pack_header.py b/tools/make_pack_header.py index e69c77b86..4f65d7669 100644 --- a/tools/make_pack_header.py +++ b/tools/make_pack_header.py @@ -119,16 +119,7 @@ def MakeFile(output, input): guard = 'CEF_INCLUDE_' + filename.replace('.', '_').upper() + '_' result = result.replace('$GUARD$', guard) - if path_exists(output): - old_contents = read_file(output) - else: - old_contents = '' - - if (result != old_contents): - write_file(output, result) - sys.stdout.write('File ' + output + ' updated.\n') - else: - sys.stdout.write('File ' + output + ' is already up to date.\n') + write_file_if_changed(output, result) def main(argv): diff --git a/tools/make_version_header.bat b/tools/make_version_header.bat index c875df7e7..e88874642 100644 --- a/tools/make_version_header.bat +++ b/tools/make_version_header.bat @@ -1,2 +1,2 @@ @echo off -python.bat tools\make_version_header.py --header include\cef_version.h +python.bat tools\make_version_header.py include\cef_version.h diff --git a/tools/make_version_header.py b/tools/make_version_header.py index 04e130e35..fa2325aa3 100644 --- a/tools/make_version_header.py +++ b/tools/make_version_header.py @@ -3,146 +3,107 @@ # 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 * -from optparse import OptionParser import git_util as git -import os import sys -# cannot be loaded as a module -if __name__ != "__main__": - sys.stderr.write('This file cannot be loaded as a module!') - sys.exit() - -# parse command-line options -disc = """ -This utility creates the version header file. -""" - -parser = OptionParser(description=disc) -parser.add_option( - '--header', - dest='header', - metavar='FILE', - help='output version header file [required]') -parser.add_option( - '-q', - '--quiet', - action='store_true', - dest='quiet', - default=False, - help='do not output detailed status information') -(options, args) = parser.parse_args() - -# the header option is required -if options.header is None: - parser.print_help(sys.stdout) - sys.exit() - - -def write_version_header(header): - """ Creates the header file for the current revision and Chrome version information - if the information has changed or if the file doesn't already exist. """ +def make_version_header(header): if not git.is_checkout('.'): raise Exception('Not a valid checkout') - if path_exists(header): - oldcontents = read_file(header) - else: - oldcontents = '' + 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_ +""" - year = get_year() formatter = VersionFormatter() - commit_hash = formatter.get_cef_commit_components()['HASH'] - commit_number = formatter.get_cef_commit_components()['NUMBER'] - version = formatter.get_version_string() + + # 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() - chrome = formatter.get_chrome_version_components() - - version_defines = '#define CEF_VERSION "%s"\n' % version for key in ('MAJOR', 'MINOR', 'PATCH'): - version_defines += '#define CEF_VERSION_%s %d\n' % (key, version_parts[key]) + result = result.replace('$VERSION_%s$' % key, str(version_parts[key])) - newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\ - '//\n'+\ - '// Redistribution and use in source and binary forms, with or without\n'+\ - '// modification, are permitted provided that the following conditions are\n'+\ - '// met:\n'+\ - '//\n'+\ - '// * Redistributions of source code must retain the above copyright\n'+\ - '// notice, this list of conditions and the following disclaimer.\n'+\ - '// * Redistributions in binary form must reproduce the above\n'+\ - '// copyright notice, this list of conditions and the following disclaimer\n'+\ - '// in the documentation and/or other materials provided with the\n'+\ - '// distribution.\n'+\ - '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\ - '// Framework nor the names of its contributors may be used to endorse\n'+\ - '// or promote products derived from this software without specific prior\n'+\ - '// written permission.\n'+\ - '//\n'+\ - '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ - '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ - '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ - '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ - '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ - '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ - '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ - '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ - '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ - '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ - '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ - '//\n'+\ - '// ---------------------------------------------------------------------------\n'+\ - '//\n'+\ - '// This file is generated by the make_version_header.py tool.\n'+\ - '//\n\n'+\ - '#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\ - '#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\ - version_defines+\ - '#define CEF_COMMIT_NUMBER ' + commit_number + '\n'+\ - '#define CEF_COMMIT_HASH "' + commit_hash + '"\n'+\ - '#define COPYRIGHT_YEAR ' + year + '\n\n'+\ - '#define CHROME_VERSION_MAJOR ' + chrome['MAJOR'] + '\n'+\ - '#define CHROME_VERSION_MINOR ' + chrome['MINOR'] + '\n'+\ - '#define CHROME_VERSION_BUILD ' + chrome['BUILD'] + '\n'+\ - '#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n\n'+\ - '#define DO_MAKE_STRING(p) #p\n'+\ - '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ - '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ - '#include "include/internal/cef_export.h"\n\n'+\ - '#ifdef __cplusplus\n'+\ - 'extern "C" {\n'+\ - '#endif\n\n'+\ - '// Returns CEF version information for the libcef library. The |entry|\n'+\ - '// parameter describes which version component will be returned:\n'+\ - '// 0 - CEF_VERSION_MAJOR\n'+\ - '// 1 - CEF_VERSION_MINOR\n'+\ - '// 2 - CEF_VERSION_PATCH\n'+\ - '// 3 - CEF_COMMIT_NUMBER\n'+\ - '// 4 - CHROME_VERSION_MAJOR\n'+\ - '// 5 - CHROME_VERSION_MINOR\n'+\ - '// 6 - CHROME_VERSION_BUILD\n'+\ - '// 7 - CHROME_VERSION_PATCH\n'+\ - '///\n'+\ - 'CEF_EXPORT int cef_version_info(int entry);\n\n'+\ - '#ifdef __cplusplus\n'+\ - '}\n'+\ - '#endif\n\n'+\ - '#endif // APSTUDIO_HIDDEN_SYMBOLS\n\n'+\ - '#endif // CEF_INCLUDE_CEF_VERSION_H_\n' - if newcontents != oldcontents: - write_file(header, newcontents) - return True + 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 False + return result -written = write_version_header(options.header) -if not options.quiet: - if written: - sys.stdout.write('File ' + options.header + ' updated.\n') - else: - sys.stdout.write('File ' + options.header + ' is already up to date.\n') +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 " % argv[0])) + sys.exit(-1) + write_version_header(argv[1]) + + +if '__main__' == __name__: + main(sys.argv) diff --git a/tools/make_version_header.sh b/tools/make_version_header.sh index 5c35a7d2e..50f83fcc8 100755 --- a/tools/make_version_header.sh +++ b/tools/make_version_header.sh @@ -1,2 +1,2 @@ #!/bin/sh -python tools/make_version_header.py --header include/cef_version.h +python tools/make_version_header.py include/cef_version.h diff --git a/tools/translator.py b/tools/translator.py index 28bb21a86..a2bfd89ac 100644 --- a/tools/translator.py +++ b/tools/translator.py @@ -238,11 +238,12 @@ if not options.quiet: sys.stdout.write('Generating ' + libcef_dll_dylib_impl + ' file...\n') update_file(*write_libcef_dll_dylib_impl(header, libcef_dll_dylib_impl)) -# Output the API hash header file. This must be done last because it reads files -# that were potentially written by proceeding operations. +# Update the API hash header file if necessary. This must be done last because +# it reads files that were potentially written by proceeding operations. if not options.quiet: sys.stdout.write('Generating API hash header...\n') -update_file(*write_api_hash_header(api_hash_header, cpp_header_dir)) +if write_api_hash_header(api_hash_header, cpp_header_dir): + writect += 1 if not options.quiet: sys.stdout.write('Done - Wrote ' + str(writect) + ' files.\n')