Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: Source/build/scripts/make_private_script_source.py

Issue 345893002: Implement an infrastructure of Blink-in-JS Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/v8.gypi ('k') | Source/core/core_generated.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « Source/bindings/v8/v8.gypi ('k') | Source/core/core_generated.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698