| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (C) 2009 Google Inc. All rights reserved. | 3 # Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
| 7 # met: | 7 # met: |
| 8 # | 8 # |
| 9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 31 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 32 # Use of this source code is governed by a BSD-style license that can be | 32 # Use of this source code is governed by a BSD-style license that can be |
| 33 # found in the LICENSE file. | 33 # found in the LICENSE file. |
| 34 | 34 |
| 35 """Generate aggregate .cpp files that include multiple V8 binding .cpp files. | 35 """Generate aggregate .cpp files that include multiple V8 binding .cpp files. |
| 36 | 36 |
| 37 This can be a single output file, to preserve symbol space; or multiple output | 37 This can be a single output file, to preserve symbol space; or multiple output |
| 38 files, to reduce maximum compilation unit size and allow parallel compilation. | 38 files, to reduce maximum compilation unit size and allow parallel compilation. |
| 39 | 39 |
| 40 Usage: | 40 Usage: |
| 41 aggregate_generated_bindings.py IDL_FILES_LIST -- OUTPUT_FILE1 OUTPUT_FILE2 ... | 41 aggregate_generated_bindings.py COMPONENT_DIR IDL_FILES_LIST -- OUTPUT_FILE1 OUT
PUT_FILE2 ... |
| 42 | 42 |
| 43 COMPONENT_DIR is the relative directory of a component, e.g., 'core', 'modules'. |
| 43 IDL_FILES_LIST is a text file containing the IDL file paths, so the command | 44 IDL_FILES_LIST is a text file containing the IDL file paths, so the command |
| 44 line doesn't exceed OS length limits. | 45 line doesn't exceed OS length limits. |
| 45 OUTPUT_FILE1 etc. are filenames of output files. | 46 OUTPUT_FILE1 etc. are filenames of output files. |
| 46 | 47 |
| 47 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 48 Design doc: http://www.chromium.org/developers/design-documents/idl-build |
| 48 """ | 49 """ |
| 49 | 50 |
| 50 import errno | 51 import errno |
| 51 import os | 52 import os |
| 52 import re | 53 import re |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 139 |
| 139 meta_data = { | 140 meta_data = { |
| 140 'conditional': extract_conditional(file_path), | 141 'conditional': extract_conditional(file_path), |
| 141 'name': interface_name, | 142 'name': interface_name, |
| 142 } | 143 } |
| 143 meta_data_list.append(meta_data) | 144 meta_data_list.append(meta_data) |
| 144 | 145 |
| 145 return meta_data_list | 146 return meta_data_list |
| 146 | 147 |
| 147 | 148 |
| 148 def generate_content(files_meta_data_this_partition): | 149 def generate_content(component_dir, files_meta_data_this_partition): |
| 149 # Add fixed content. | 150 # Add fixed content. |
| 150 output = [COPYRIGHT_TEMPLATE, | 151 output = [COPYRIGHT_TEMPLATE, |
| 151 '#define NO_IMPLICIT_ATOMICSTRING\n\n'] | 152 '#define NO_IMPLICIT_ATOMICSTRING\n\n'] |
| 152 | 153 |
| 153 # List all includes segmented by if and endif. | 154 # List all includes segmented by if and endif. |
| 154 prev_conditional = None | 155 prev_conditional = None |
| 155 files_meta_data_this_partition.sort(key=lambda e: e['conditional']) | 156 files_meta_data_this_partition.sort(key=lambda e: e['conditional']) |
| 156 for meta_data in files_meta_data_this_partition: | 157 for meta_data in files_meta_data_this_partition: |
| 157 # FIXME: linking fails (in SVG) if conditionals occur | 158 # FIXME: linking fails (in SVG) if conditionals occur |
| 158 # conditional = meta_data['conditional'] | 159 # conditional = meta_data['conditional'] |
| 159 conditional = None | 160 conditional = None |
| 160 if prev_conditional != conditional: | 161 if prev_conditional != conditional: |
| 161 if prev_conditional: | 162 if prev_conditional: |
| 162 output.append('#endif\n') | 163 output.append('#endif\n') |
| 163 if conditional: | 164 if conditional: |
| 164 output.append('\n#if %s\n' % format_conditional(conditional)) | 165 output.append('\n#if %s\n' % format_conditional(conditional)) |
| 165 prev_conditional = conditional | 166 prev_conditional = conditional |
| 166 | 167 |
| 167 output.append('#include "bindings/V8%s.cpp"\n' % meta_data['name']) | 168 output.append('#include "bindings/%s/v8/V8%s.cpp"\n' % |
| 169 (component_dir, meta_data['name'])) |
| 168 | 170 |
| 169 if prev_conditional: | 171 if prev_conditional: |
| 170 output.append('#endif\n') | 172 output.append('#endif\n') |
| 171 | 173 |
| 172 return ''.join(output) | 174 return ''.join(output) |
| 173 | 175 |
| 174 | 176 |
| 175 def write_content(content, output_file_name): | 177 def write_content(content, output_file_name): |
| 176 parent_path, file_name = os.path.split(output_file_name) | 178 parent_path, file_name = os.path.split(output_file_name) |
| 177 if not os.path.exists(parent_path): | 179 if not os.path.exists(parent_path): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 190 for file_name in cygdrive_names: | 192 for file_name in cygdrive_names: |
| 191 process.stdin.write('%s\n' % file_name) | 193 process.stdin.write('%s\n' % file_name) |
| 192 process.stdin.flush() | 194 process.stdin.flush() |
| 193 idl_file_names.append(process.stdout.readline().rstrip()) | 195 idl_file_names.append(process.stdout.readline().rstrip()) |
| 194 process.stdin.close() | 196 process.stdin.close() |
| 195 process.wait() | 197 process.wait() |
| 196 return idl_file_names | 198 return idl_file_names |
| 197 | 199 |
| 198 | 200 |
| 199 def main(args): | 201 def main(args): |
| 200 if len(args) <= 3: | 202 if len(args) <= 4: |
| 201 raise Exception('Expected at least 4 arguments.') | 203 raise Exception('Expected at least 5 arguments.') |
| 202 input_file_name = args[1] | 204 component_dir = args[1] |
| 205 input_file_name = args[2] |
| 203 in_out_break_index = args.index('--') | 206 in_out_break_index = args.index('--') |
| 204 output_file_names = args[in_out_break_index + 1:] | 207 output_file_names = args[in_out_break_index + 1:] |
| 205 | 208 |
| 206 with open(input_file_name) as input_file: | 209 with open(input_file_name) as input_file: |
| 207 file_names = sorted([os.path.realpath(line.rstrip('\n')) | 210 file_names = sorted([os.path.realpath(line.rstrip('\n')) |
| 208 for line in input_file]) | 211 for line in input_file]) |
| 209 idl_file_names = [file_name for file_name in file_names | 212 idl_file_names = [file_name for file_name in file_names |
| 210 if not file_name.startswith('/cygdrive')] | 213 if not file_name.startswith('/cygdrive')] |
| 211 cygdrive_names = [file_name for file_name in file_names | 214 cygdrive_names = [file_name for file_name in file_names |
| 212 if file_name.startswith('/cygdrive')] | 215 if file_name.startswith('/cygdrive')] |
| 213 idl_file_names.extend(resolve_cygpath(cygdrive_names)) | 216 idl_file_names.extend(resolve_cygpath(cygdrive_names)) |
| 214 | 217 |
| 215 files_meta_data = extract_meta_data(idl_file_names) | 218 files_meta_data = extract_meta_data(idl_file_names) |
| 216 total_partitions = len(output_file_names) | 219 total_partitions = len(output_file_names) |
| 217 for partition, file_name in enumerate(output_file_names): | 220 for partition, file_name in enumerate(output_file_names): |
| 218 files_meta_data_this_partition = [ | 221 files_meta_data_this_partition = [ |
| 219 meta_data for meta_data in files_meta_data | 222 meta_data for meta_data in files_meta_data |
| 220 if hash(meta_data['name']) % total_partitions == partition] | 223 if hash(meta_data['name']) % total_partitions == partition] |
| 221 file_contents = generate_content(files_meta_data_this_partition) | 224 file_contents = generate_content(component_dir, |
| 225 files_meta_data_this_partition) |
| 222 write_content(file_contents, file_name) | 226 write_content(file_contents, file_name) |
| 223 | 227 |
| 224 | 228 |
| 225 if __name__ == '__main__': | 229 if __name__ == '__main__': |
| 226 sys.exit(main(sys.argv)) | 230 sys.exit(main(sys.argv)) |
| OLD | NEW |