Index: Source/build/scripts/xxd.py |
diff --git a/Tools/Scripts/print-layout-test-types b/Source/build/scripts/xxd.py |
old mode 100755 |
new mode 100644 |
similarity index 72% |
copy from Tools/Scripts/print-layout-test-types |
copy to Source/build/scripts/xxd.py |
index 3cc36c64bb26ebaf0e173e0dad4ce8c9b0b1cd52..858236c9a63b88449bfb0cf7ffbc771c10360046 |
--- a/Tools/Scripts/print-layout-test-types |
+++ b/Source/build/scripts/xxd.py |
@@ -1,5 +1,3 @@ |
-#!/usr/bin/python |
-# |
# Copyright (C) 2013 Google Inc. All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -28,9 +26,25 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+"""Represent a file as a C++ constant string. |
+ |
+Usage: |
+python xxd.py VAR SOURCE DEST |
+""" |
+ |
import sys |
-from webkitpy.common import host |
-from webkitpy.layout_tests import print_layout_test_types |
-print_layout_test_types.main(host.Host(), sys.argv[1:]) |
+def main(): |
+ variable_name, input_filename, output_filename = sys.argv[1:] |
+ 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] |
+ const_declaration = 'const unsigned char %s[] = {\n%s\n};\n' % ( |
+ variable_name, ', '.join(hex_values)) |
+ with open(output_filename, 'w') as output_file: |
+ output_file.write(const_declaration) |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |