| Index: Source/build/scripts/make_blink_in_js.py
|
| diff --git a/Source/build/scripts/make_blink_in_js.py b/Source/build/scripts/make_blink_in_js.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8efcaf962e9588dfd565be55b198e16dac1ca08e
|
| --- /dev/null
|
| +++ b/Source/build/scripts/make_blink_in_js.py
|
| @@ -0,0 +1,38 @@
|
| +# 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 Blink-in-JS sources to C++ constant strings.
|
| +
|
| +Usage:
|
| +python make_blink_in_js.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 += 'const unsigned char kSourceOf%s[] = {\n %s\n};\n' % (
|
| + class_name, ', '.join(hex_values))
|
| + contents += '\nstruct BlinkInJSSources {\n const char* name;\n const unsigned char* source;\n size_t size;\n};\n\n'
|
| + contents += 'struct BlinkInJSSources kBlinkInJSSources[] = {\n'
|
| + for input_filename in input_filenames:
|
| + class_name, ext = os.path.splitext(os.path.basename(input_filename))
|
| + contents += ' { "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (class_name, class_name, class_name)
|
| + contents += '};\n'
|
| +
|
| + with open(output_filename, 'w') as output_file:
|
| + output_file.write(contents)
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|