mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update cef_api_hash.h at build time if necessary (fixes issue #2922)
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.
This commit is contained in:
@ -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 <output_filename> <cpp_header_dir>" % 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] + ' <cppheaderdir>\n')
|
||||
sys.exit()
|
||||
|
||||
# Dump the result to stdout.
|
||||
sys.stdout.write(make_api_hash_header(sys.argv[1]))
|
||||
if '__main__' == __name__:
|
||||
main(sys.argv)
|
||||
|
Reference in New Issue
Block a user