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 |
index 19078b2eae6dab7e22257ca46c41844712ceeb35..8064ae710121deaeadae34f7fbb517778f441e9b 100644 |
--- a/Source/build/scripts/make_private_script_source.py |
+++ b/Source/build/scripts/make_private_script_source.py |
@@ -9,7 +9,6 @@ Usage: |
python make_private_script_source.py DESTINATION_FILE SOURCE_FILES |
""" |
-import optparse |
import os |
import re |
import sys |
@@ -33,51 +32,34 @@ def extract_partial_interface_name(filename): |
def main(): |
- parser = optparse.OptionParser() |
- parser.add_option('--for-testing', action="store_true", default=False) |
- |
- options, args = parser.parse_args() |
- output_filename = args[0] |
- input_filenames = args[1:] |
+ output_filename = sys.argv[1] |
+ input_filenames = sys.argv[2:] |
source_name, ext = os.path.splitext(os.path.basename(output_filename)) |
contents = [] |
- contents.append('#ifndef %s_h\n' % source_name) |
- contents.append('#define %s_h\n' % source_name) |
- if options.for_testing: |
- 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 char kSourceOf%s[] = {\n %s\n};\n\n' % ( |
- class_name, ', '.join(hex_values))) |
+ 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\n' % ( |
+ class_name, ', '.join(hex_values))) |
contents.append('struct %s {' % source_name) |
contents.append(""" |
const char* scriptClassName; |
const char* className; |
- """) |
- if options.for_testing: |
- contents.append(""" |
- const char* source; |
- size_t size;""") |
- else: |
- contents.append('const char* resourceFile;') |
- contents.append(""" |
+ const unsigned char* source; |
+ size_t size; |
}; |
""") |
- |
contents.append('struct %s k%s[] = {\n' % (source_name, source_name)) |
for input_filename in input_filenames: |
script_class_name, ext = os.path.splitext(os.path.basename(input_filename)) |
class_name = extract_partial_interface_name(input_filename) or script_class_name |
- if options.for_testing: |
- contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (script_class_name, class_name, script_class_name, script_class_name)) |
- else: |
- contents.append(' { "%s", "%s", "%s.js" },\n' % (script_class_name, class_name, script_class_name)) |
+ contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (script_class_name, class_name, script_class_name, script_class_name)) |
contents.append('};\n') |
- contents.append('#endif // %s_h\n' % source_name) |
+ |
with open(output_filename, 'w') as output_file: |
output_file.write("".join(contents)) |