2019-03-14 16:18:06 +01:00
|
|
|
# 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.
|
|
|
|
|
2020-01-09 21:22:11 +01:00
|
|
|
from __future__ import absolute_import
|
2019-03-14 16:18:06 +01:00
|
|
|
from cef_api_hash import cef_api_hash
|
2020-04-30 21:59:23 +02:00
|
|
|
from cef_parser import get_copyright
|
2019-03-14 16:18:06 +01:00
|
|
|
from file_util import *
|
2020-04-30 21:59:23 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2019-03-14 16:18:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
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_
|
2019-03-14 16:18:06 +01:00
|
|
|
#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$"
|
2020-08-29 00:39:23 +02:00
|
|
|
#elif defined(OS_MAC)
|
|
|
|
#define CEF_API_HASH_PLATFORM "$MAC$"
|
2019-03-14 16:18:06 +01:00
|
|
|
#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.
|
2020-01-09 21:22:11 +01:00
|
|
|
for platform, value in api_hash.items():
|
2019-03-14 16:18:06 +01:00
|
|
|
result = result.replace('$%s$' % platform.upper(), value)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
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
|
2019-03-14 16:18:06 +01:00
|
|
|
|
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
def main(argv):
|
|
|
|
if len(argv) < 3:
|
|
|
|
print(("Usage:\n %s <output_filename> <cpp_header_dir>" % argv[0]))
|
|
|
|
sys.exit(-1)
|
|
|
|
write_api_hash_header(argv[1], argv[2])
|
2019-03-14 16:18:06 +01:00
|
|
|
|
|
|
|
|
2020-04-30 21:59:23 +02:00
|
|
|
if '__main__' == __name__:
|
|
|
|
main(sys.argv)
|