| Index: Source/build/scripts/make_private_script_source.py
|
| diff --git a/Source/build/scripts/make_private_script_source.py b/Source/build/scripts/make_private_script_source.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..00ec1f94a7610f8fc36b4670710a9bc5e981a92e
|
| --- /dev/null
|
| +++ b/Source/build/scripts/make_private_script_source.py
|
| @@ -0,0 +1,46 @@
|
| +# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""Convert PrivateScript's sources to C++ constant strings.
|
| +FIXME: Move this script to grit.
|
| +
|
| +Usage:
|
| +python make_private_script.py DESTINATION_FILE SOURCE_FILES
|
| +"""
|
| +
|
| +import os
|
| +import sys
|
| +
|
| +
|
| +def main():
|
| + output_filename = sys.argv[1]
|
| + input_filenames = sys.argv[2:]
|
| + contents = []
|
| + for input_filename in input_filenames:
|
| + class_name, ext = os.path.splitext(os.path.basename(input_filename))
|
| + with open(input_filename) as input_file:
|
| + input_text = input_file.read()
|
| + hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
|
| + contents.append('const unsigned char kSourceOf%s[] = {\n %s\n};\n' % (
|
| + class_name, ', '.join(hex_values)))
|
| + contents.append("""
|
| +struct PrivateScriptSources {
|
| + const char* name;
|
| + const unsigned char* source;
|
| + size_t size;
|
| +};
|
| +
|
| +""")
|
| + contents.append('struct PrivateScriptSources kPrivateScriptSources[] = {\n')
|
| + for input_filename in input_filenames:
|
| + class_name, ext = os.path.splitext(os.path.basename(input_filename))
|
| + contents.append(' { "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (class_name, class_name, class_name))
|
| + contents.append('};\n')
|
| +
|
| + with open(output_filename, 'w') as output_file:
|
| + output_file.write("".join(contents))
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|