diff --git a/cef_paths2.gypi b/cef_paths2.gypi index 29f76e99e..81ac6234b 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -34,6 +34,7 @@ 'include/base/internal/cef_lock_impl.h', 'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h', 'include/base/internal/cef_thread_checker_impl.h', + 'include/cef_api_hash.h', 'include/cef_base.h', 'include/cef_version.h', 'include/internal/cef_export.h', diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h new file mode 100644 index 000000000..24ee42432 --- /dev/null +++ b/include/cef_api_hash.h @@ -0,0 +1,76 @@ +// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// 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=b5fa5783096eaa1af5e76645e2557e123af56848$ +// + +#ifndef CEF_INCLUDE_API_HASH_H_ +#define CEF_INCLUDE_API_HASH_H_ + +#include "include/internal/cef_export.h" + +// The API hash is created by analyzing CEF header files for C API type +// definitions. The hash value will change when header files are modified in a +// way that may cause binary incompatibility with other builds. The universal +// hash value will change if any platform is affected whereas the platform hash +// values will change only if that particular platform is affected. +#define CEF_API_HASH_UNIVERSAL "8ae24aac4bd16d2e2d87e7d6561985064990670e" +#if defined(OS_WIN) +#define CEF_API_HASH_PLATFORM "fe476e7a38a8270fe783981b4bc6fac4284ab9fe" +#elif defined(OS_MACOSX) +#define CEF_API_HASH_PLATFORM "ab1b4d8c4578b0bcdc97f28f13a10384057bdf95" +#elif defined(OS_LINUX) +#define CEF_API_HASH_PLATFORM "73f24626e0179a3f5664d64ffe0fa2aab9edf7cf" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Returns CEF API hashes for the libcef library. The returned string is owned +// by the library and should not be freed. The |entry| parameter describes which +// hash value will be returned: +// 0 - CEF_API_HASH_PLATFORM +// 1 - CEF_API_HASH_UNIVERSAL +// 2 - CEF_COMMIT_HASH (from cef_version.h) +/// +CEF_EXPORT const char* cef_api_hash(int entry); + +#ifdef __cplusplus +} +#endif +#endif // CEF_INCLUDE_API_HASH_H_ diff --git a/libcef_dll/ctocpp/command_line_ctocpp.cc b/libcef_dll/ctocpp/command_line_ctocpp.cc index 428c129a9..9a4b63dcb 100644 --- a/libcef_dll/ctocpp/command_line_ctocpp.cc +++ b/libcef_dll/ctocpp/command_line_ctocpp.cc @@ -9,11 +9,11 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a87daf3d3e3bd604ac3c008561676181d42f3266$ +// $hash=0e24c6b07a7377337132b09396d9e5f3e4eca517$ // #include "libcef_dll/ctocpp/command_line_ctocpp.h" -#include "include/cef_version.h" +#include "include/cef_api_hash.h" #include "libcef_dll/transfer_util.h" // STATIC METHODS - Body may be edited by hand. diff --git a/libcef_dll/libcef_dll2.cc b/libcef_dll/libcef_dll2.cc index 12bf82328..80c16dd6f 100644 --- a/libcef_dll/libcef_dll2.cc +++ b/libcef_dll/libcef_dll2.cc @@ -4,6 +4,7 @@ // #include +#include "include/cef_api_hash.h" #include "include/cef_version.h" CEF_EXPORT int cef_version_info(int entry) { diff --git a/libcef_dll/wrapper/libcef_dll_dylib.cc b/libcef_dll/wrapper/libcef_dll_dylib.cc index e87a52b28..7244cf92c 100644 --- a/libcef_dll/wrapper/libcef_dll_dylib.cc +++ b/libcef_dll/wrapper/libcef_dll_dylib.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=ef8269462464beba6718a2e0d03e0f1cb41901bf$ +// $hash=4a4744491587c5f5b1ce8726d8dd08ad04646b92$ // #include @@ -58,6 +58,7 @@ #include "include/capi/views/cef_scroll_view_capi.h" #include "include/capi/views/cef_textfield_capi.h" #include "include/capi/views/cef_window_capi.h" +#include "include/cef_api_hash.h" #include "include/cef_version.h" #include "include/internal/cef_logging_internal.h" #include "include/internal/cef_string_list.h" @@ -333,8 +334,8 @@ typedef struct _cef_textfield_t* (*cef_textfield_create_ptr)( struct _cef_textfield_delegate_t*); typedef struct _cef_window_t* (*cef_window_create_top_level_ptr)( struct _cef_window_delegate_t*); -typedef int (*cef_version_info_ptr)(int); typedef const char* (*cef_api_hash_ptr)(int); +typedef int (*cef_version_info_ptr)(int); typedef int (*cef_get_min_log_level_ptr)(); typedef int (*cef_get_vlog_level_ptr)(const char*, size_t); typedef void (*cef_log_ptr)(const char*, int, int, const char*); @@ -656,8 +657,8 @@ struct libcef_pointers { cef_scroll_view_create_ptr cef_scroll_view_create; cef_textfield_create_ptr cef_textfield_create; cef_window_create_top_level_ptr cef_window_create_top_level; - cef_version_info_ptr cef_version_info; cef_api_hash_ptr cef_api_hash; + cef_version_info_ptr cef_version_info; cef_get_min_log_level_ptr cef_get_min_log_level; cef_get_vlog_level_ptr cef_get_vlog_level; cef_log_ptr cef_log; @@ -864,8 +865,8 @@ int libcef_init_pointers(const char* path) { INIT_ENTRY(cef_scroll_view_create); INIT_ENTRY(cef_textfield_create); INIT_ENTRY(cef_window_create_top_level); - INIT_ENTRY(cef_version_info); INIT_ENTRY(cef_api_hash); + INIT_ENTRY(cef_version_info); INIT_ENTRY(cef_get_min_log_level); INIT_ENTRY(cef_get_vlog_level); INIT_ENTRY(cef_log); @@ -1098,8 +1099,8 @@ int cef_create_url(const struct _cef_urlparts_t* parts, cef_string_t* url) { } NO_SANITIZE("cfi-icall") -cef_string_userfree_t - cef_format_url_for_security_display(const cef_string_t* origin_url) { +cef_string_userfree_t cef_format_url_for_security_display( + const cef_string_t* origin_url) { return g_libcef_pointers.cef_format_url_for_security_display(origin_url); } @@ -1590,54 +1591,46 @@ struct _cef_translator_test_t* cef_translator_test_create() { } NO_SANITIZE("cfi-icall") -struct - _cef_translator_test_ref_ptr_library_t* cef_translator_test_ref_ptr_library_create( - int value) { +struct _cef_translator_test_ref_ptr_library_t* +cef_translator_test_ref_ptr_library_create(int value) { return g_libcef_pointers.cef_translator_test_ref_ptr_library_create(value); } NO_SANITIZE("cfi-icall") -struct - _cef_translator_test_ref_ptr_library_child_t* cef_translator_test_ref_ptr_library_child_create( - int value, - int other_value) { +struct _cef_translator_test_ref_ptr_library_child_t* +cef_translator_test_ref_ptr_library_child_create(int value, int other_value) { return g_libcef_pointers.cef_translator_test_ref_ptr_library_child_create( value, other_value); } NO_SANITIZE("cfi-icall") -struct - _cef_translator_test_ref_ptr_library_child_child_t* cef_translator_test_ref_ptr_library_child_child_create( - int value, - int other_value, - int other_other_value) { +struct _cef_translator_test_ref_ptr_library_child_child_t* +cef_translator_test_ref_ptr_library_child_child_create(int value, + int other_value, + int other_other_value) { return g_libcef_pointers .cef_translator_test_ref_ptr_library_child_child_create( value, other_value, other_other_value); } NO_SANITIZE("cfi-icall") -struct - _cef_translator_test_scoped_library_t* cef_translator_test_scoped_library_create( - int value) { +struct _cef_translator_test_scoped_library_t* +cef_translator_test_scoped_library_create(int value) { return g_libcef_pointers.cef_translator_test_scoped_library_create(value); } NO_SANITIZE("cfi-icall") -struct - _cef_translator_test_scoped_library_child_t* cef_translator_test_scoped_library_child_create( - int value, - int other_value) { +struct _cef_translator_test_scoped_library_child_t* +cef_translator_test_scoped_library_child_create(int value, int other_value) { return g_libcef_pointers.cef_translator_test_scoped_library_child_create( value, other_value); } NO_SANITIZE("cfi-icall") -struct - _cef_translator_test_scoped_library_child_child_t* cef_translator_test_scoped_library_child_child_create( - int value, - int other_value, - int other_other_value) { +struct _cef_translator_test_scoped_library_child_child_t* +cef_translator_test_scoped_library_child_child_create(int value, + int other_value, + int other_other_value) { return g_libcef_pointers .cef_translator_test_scoped_library_child_child_create(value, other_value, other_other_value); @@ -1727,14 +1720,14 @@ struct _cef_window_t* cef_window_create_top_level( return g_libcef_pointers.cef_window_create_top_level(delegate); } -NO_SANITIZE("cfi-icall") int cef_version_info(int entry) { - return g_libcef_pointers.cef_version_info(entry); -} - NO_SANITIZE("cfi-icall") const char* cef_api_hash(int entry) { return g_libcef_pointers.cef_api_hash(entry); } +NO_SANITIZE("cfi-icall") int cef_version_info(int entry) { + return g_libcef_pointers.cef_version_info(entry); +} + NO_SANITIZE("cfi-icall") int cef_get_min_log_level() { return g_libcef_pointers.cef_get_min_log_level(); } diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index bba669112..7e94495a4 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -9,7 +9,7 @@ // implementations. See the translator.README.txt file in the tools directory // for more information. // -// $hash=a53efd61643236ca14fddb5541f23ef2d9d1dc54$ +// $hash=32eea715f2566d1b6a4e3d263e35400cf7c53869$ // #include "include/capi/cef_app_capi.h" @@ -26,6 +26,7 @@ #include "include/capi/cef_v8_capi.h" #include "include/capi/cef_web_plugin_capi.h" #include "include/capi/test/cef_test_helpers_capi.h" +#include "include/cef_api_hash.h" #include "include/cef_app.h" #include "include/cef_crash_util.h" #include "include/cef_file_util.h" @@ -38,7 +39,6 @@ #include "include/cef_task.h" #include "include/cef_trace.h" #include "include/cef_v8.h" -#include "include/cef_version.h" #include "include/cef_web_plugin.h" #include "include/test/cef_test_helpers.h" #include "libcef_dll/cpptoc/app_cpptoc.h" diff --git a/tests/ceftests/version_unittest.cc b/tests/ceftests/version_unittest.cc index 9e0f63605..99255354a 100644 --- a/tests/ceftests/version_unittest.cc +++ b/tests/ceftests/version_unittest.cc @@ -2,6 +2,7 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. +#include "include/cef_api_hash.h" #include "include/cef_version.h" #include "tests/gtest/include/gtest/gtest.h" diff --git a/tools/cef_api_hash.py b/tools/cef_api_hash.py index 4179631c6..ca1089cc2 100644 --- a/tools/cef_api_hash.py +++ b/tools/cef_api_hash.py @@ -44,6 +44,7 @@ class cef_api_hash: self.included_files = [] self.excluded_files = [ + "cef_api_hash.h", "cef_version.h", "internal/cef_tuple.h", "internal/cef_types_wrappers.h", diff --git a/tools/cef_parser.py b/tools/cef_parser.py index 13763978e..9266322a1 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -246,7 +246,7 @@ def format_translation_includes(header, body): result += '#include \n' if body.find('cef_api_hash(') > 0: - result += '#include "include/cef_version.h"\n' + result += '#include "include/cef_api_hash.h"\n' # identify what CppToC classes are being used p = re.compile('([A-Za-z0-9_]{1,})CppToC') @@ -452,12 +452,47 @@ def get_next_function_impl(existing, name): return result -def get_copyright(): - result = \ +def get_copyright(full=False): + if full: + result = \ +"""// Copyright (c) $YEAR$ Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +""" + else: + result = \ """// Copyright (c) $YEAR$ 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. -// +""" + + result += \ +"""// // --------------------------------------------------------------------------- // // This file was generated by the CEF translator tool. If making changes by diff --git a/tools/gclient_hook.py b/tools/gclient_hook.py index 44aa66507..6025e68bd 100644 --- a/tools/gclient_hook.py +++ b/tools/gclient_hook.py @@ -29,7 +29,7 @@ print "\nGenerating CEF version header file..." cmd = [ 'python', 'tools/make_version_header.py', '--header', 'include/cef_version.h', '--cef_version', 'VERSION.in', '--chrome_version', - '../chrome/VERSION', '--cpp_header_dir', 'include' + '../chrome/VERSION' ] RunAction(cef_dir, cmd) diff --git a/tools/make_api_hash_header.py b/tools/make_api_hash_header.py new file mode 100644 index 000000000..4f3dfd95f --- /dev/null +++ b/tools/make_api_hash_header.py @@ -0,0 +1,77 @@ +# Copyright (c) 2019 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 cef_api_hash import cef_api_hash +from cef_parser import * +from file_util import * + + +def make_api_hash_header(cpp_header_dir): + # calculate api hashes + 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_ +#define CEF_INCLUDE_API_HASH_H_ + +#include "include/internal/cef_export.h" + +// The API hash is created by analyzing CEF header files for C API type +// definitions. The hash value will change when header files are modified in a +// way that may cause binary incompatibility with other builds. The universal +// hash value will change if any platform is affected whereas the platform hash +// values will change only if that particular platform is affected. +#define CEF_API_HASH_UNIVERSAL "$UNIVERSAL$" +#if defined(OS_WIN) +#define CEF_API_HASH_PLATFORM "$WINDOWS$" +#elif defined(OS_MACOSX) +#define CEF_API_HASH_PLATFORM "$MACOSX$" +#elif defined(OS_LINUX) +#define CEF_API_HASH_PLATFORM "$LINUX$" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/// +// Returns CEF API hashes for the libcef library. The returned string is owned +// by the library and should not be freed. The |entry| parameter describes which +// hash value will be returned: +// 0 - CEF_API_HASH_PLATFORM +// 1 - CEF_API_HASH_UNIVERSAL +// 2 - CEF_COMMIT_HASH (from cef_version.h) +/// +CEF_EXPORT const char* cef_api_hash(int entry); + +#ifdef __cplusplus +} +#endif +#endif // CEF_INCLUDE_API_HASH_H_ +""" + + # Substitute hash values for placeholders. + for platform, value in api_hash.iteritems(): + result = result.replace('$%s$' % platform.upper(), value) + + return result + + +def write_api_hash_header(header, cpp_header_dir): + newcontents = make_api_hash_header(cpp_header_dir) + return (header, newcontents) + + +# Test the module. +if __name__ == "__main__": + import sys + + # Verify that the correct number of command-line arguments are provided. + if len(sys.argv) < 2: + sys.stderr.write('Usage: ' + sys.argv[0] + ' ') + sys.exit() + + # Dump the result to stdout. + sys.stdout.write(make_api_hash_header(sys.argv[1])) diff --git a/tools/make_libcef_dll_dylib_impl.py b/tools/make_libcef_dll_dylib_impl.py index 9fd0bf03c..3793dacf6 100644 --- a/tools/make_libcef_dll_dylib_impl.py +++ b/tools/make_libcef_dll_dylib_impl.py @@ -8,6 +8,7 @@ import os # Other headers that export C API functions. OTHER_HEADERS = [ + 'cef_api_hash.h', 'cef_version.h', 'internal/cef_logging_internal.h', 'internal/cef_string_list.h', @@ -205,7 +206,7 @@ if __name__ == "__main__": # Create the header object. Should match the logic in translator.py. header = obj_header() header.set_root_directory(cpp_header_dir) - excluded_files = ['cef_application_mac.h', 'cef_version.h'] + excluded_files = ['cef_api_hash.h', 'cef_application_mac.h', 'cef_version.h'] header.add_directory(cpp_header_dir, excluded_files) header.add_directory(os.path.join(cpp_header_dir, 'test')) header.add_directory(os.path.join(cpp_header_dir, 'views')) diff --git a/tools/make_version_header.py b/tools/make_version_header.py index d6d6bd256..6c3900795 100644 --- a/tools/make_version_header.py +++ b/tools/make_version_header.py @@ -5,7 +5,6 @@ from date_util import * from file_util import * from optparse import OptionParser -from cef_api_hash import cef_api_hash import git_util as git import sys @@ -35,11 +34,6 @@ parser.add_option( dest='chrome_version', metavar='FILE', help='input Chrome version config file [required]') -parser.add_option( - '--cpp_header_dir', - dest='cpp_header_dir', - metavar='DIR', - help='input directory for C++ header files [required]') parser.add_option( '-q', '--quiet', @@ -50,12 +44,12 @@ parser.add_option( (options, args) = parser.parse_args() # the header option is required -if options.header is None or options.cef_version is None or options.chrome_version is None or options.cpp_header_dir is None: +if options.header is None or options.cef_version is None or options.chrome_version is None: parser.print_help(sys.stdout) sys.exit() -def write_version_header(header, chrome_version, cef_version, cpp_header_dir): +def write_version_header(header, chrome_version, cef_version): """ 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. """ @@ -84,10 +78,6 @@ def write_version_header(header, chrome_version, cef_version, cpp_header_dir): version = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['BUILD'], commit_number, commit_hash[:7]) - # calculate api hashes - api_hash_calculator = cef_api_hash(cpp_header_dir, verbose=False) - api_hashes = api_hash_calculator.calculate() - newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\ '//\n'+\ '// Redistribution and use in source and binary forms, with or without\n'+\ @@ -139,20 +129,6 @@ def write_version_header(header, chrome_version, cef_version, cpp_header_dir): '#ifdef __cplusplus\n'+\ 'extern "C" {\n'+\ '#endif\n\n'+\ - '// The API hash is created by analyzing CEF header files for C API type\n'+\ - '// definitions. The hash value will change when header files are modified\n'+\ - '// in a way that may cause binary incompatibility with other builds. The\n'+\ - '// universal hash value will change if any platform is affected whereas the\n'+\ - '// platform hash values will change only if that particular platform is\n'+\ - '// affected.\n'+\ - '#define CEF_API_HASH_UNIVERSAL "' + api_hashes['universal'] + '"\n'+\ - '#if defined(OS_WIN)\n'+\ - '#define CEF_API_HASH_PLATFORM "' + api_hashes['windows'] + '"\n'+\ - '#elif defined(OS_MACOSX)\n'+\ - '#define CEF_API_HASH_PLATFORM "' + api_hashes['macosx'] + '"\n'+\ - '#elif defined(OS_LINUX)\n'+\ - '#define CEF_API_HASH_PLATFORM "' + api_hashes['linux'] + '"\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'+\ @@ -163,15 +139,6 @@ def write_version_header(header, chrome_version, cef_version, cpp_header_dir): '// 5 - CHROME_VERSION_PATCH\n'+\ '///\n'+\ 'CEF_EXPORT int cef_version_info(int entry);\n\n'+\ - '///\n'+\ - '// Returns CEF API hashes for the libcef library. The returned string is owned\n'+\ - '// by the library and should not be freed. The |entry| parameter describes which\n'+\ - '// hash value will be returned:\n'+\ - '// 0 - CEF_API_HASH_PLATFORM\n'+\ - '// 1 - CEF_API_HASH_UNIVERSAL\n'+\ - '// 2 - CEF_COMMIT_HASH\n'+\ - '///\n'+\ - 'CEF_EXPORT const char* cef_api_hash(int entry);\n\n'+\ '#ifdef __cplusplus\n'+\ '}\n'+\ '#endif\n\n'+\ @@ -185,7 +152,7 @@ def write_version_header(header, chrome_version, cef_version, cpp_header_dir): written = write_version_header(options.header, options.chrome_version, - options.cef_version, options.cpp_header_dir) + options.cef_version) if not options.quiet: if written: sys.stdout.write('File ' + options.header + ' updated.\n') diff --git a/tools/make_views_stub_impl.py b/tools/make_views_stub_impl.py index 2969610f1..d3feef6a7 100644 --- a/tools/make_views_stub_impl.py +++ b/tools/make_views_stub_impl.py @@ -87,7 +87,7 @@ if __name__ == "__main__": # Create the header object. Should match the logic in translator.py. header = obj_header() header.set_root_directory(cpp_header_dir) - excluded_files = ['cef_application_mac.h', 'cef_version.h'] + excluded_files = ['cef_api_hash.h', 'cef_application_mac.h', 'cef_version.h'] header.add_directory(cpp_header_dir, excluded_files) header.add_directory(os.path.join(cpp_header_dir, 'views')) diff --git a/tools/make_wrapper_types_header.py b/tools/make_wrapper_types_header.py index 09c9492f3..26bf83187 100644 --- a/tools/make_wrapper_types_header.py +++ b/tools/make_wrapper_types_header.py @@ -42,7 +42,7 @@ if __name__ == "__main__": # create the header object header = obj_header() - excluded_files = ['cef_application_mac.h', 'cef_version.h'] + excluded_files = ['cef_api_hash.h', 'cef_application_mac.h', 'cef_version.h'] header.add_directory(sys.argv[1], excluded_files) # dump the result to stdout diff --git a/tools/translator.py b/tools/translator.py index 9ed2b2d62..3d7c3d1b1 100644 --- a/tools/translator.py +++ b/tools/translator.py @@ -7,6 +7,7 @@ from cef_parser import * from clang_util import clang_format from file_util import * import hashlib +from make_api_hash_header import * from make_capi_header import * from make_cpptoc_header import * from make_cpptoc_impl import * @@ -72,6 +73,7 @@ cpp_header_dir = os.path.join(root_dir, 'include') cpp_header_test_dir = os.path.join(cpp_header_dir, 'test') cpp_header_views_dir = os.path.join(cpp_header_dir, 'views') capi_header_dir = os.path.join(cpp_header_dir, 'capi') +api_hash_header = os.path.join(cpp_header_dir, 'cef_api_hash.h') libcef_dll_dir = os.path.join(root_dir, 'libcef_dll') cpptoc_global_impl = os.path.join(libcef_dll_dir, 'libcef_dll.cc') ctocpp_global_impl = os.path.join(libcef_dll_dir, 'wrapper', @@ -96,7 +98,7 @@ header = obj_header() # add include files to be processed header.set_root_directory(cpp_header_dir) -excluded_files = ['cef_application_mac.h', 'cef_version.h'] +excluded_files = ['cef_api_hash.h', 'cef_application_mac.h', 'cef_version.h'] header.add_directory(cpp_header_dir, excluded_files) header.add_directory(cpp_header_test_dir) header.add_directory(cpp_header_views_dir) @@ -236,5 +238,11 @@ 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. +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 not options.quiet: sys.stdout.write('Done - Wrote ' + str(writect) + ' files.\n')