| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module generates Dart Chrome APIs from the Chrome IDL files.""" | 6 """This module generates Dart Chrome APIs from the Chrome IDL files.""" |
| 7 | 7 |
| 8 import sys | 8 import sys |
| 9 import os | 9 import os |
| 10 | 10 |
| 11 # The path to the JSON Schema Compiler, which can be run to generate the files. | 11 # The path to the JSON Schema Compiler, which can be run to generate the files. |
| 12 # Lives in the Chromium repository, so needs to be pulled in somehow. | 12 # Lives in the Chromium repository, so needs to be pulled in somehow. |
| 13 COMPILER = "../../../third_party/chrome_api_tools/compiler.py" | 13 COMPILER = "../../../third_party/chrome/tools/json_schema_compiler/compiler.py" |
| 14 | 14 |
| 15 # The path to the Chrome IDL files. They live in the Chromium repository, so | 15 # The path to the Chrome IDL files. They live in the Chromium repository, so |
| 16 # need to be pulled in somehow. | 16 # need to be pulled in somehow. |
| 17 API_DIR = "../../../third_party/chrome_api/" | 17 API_DIR = "../../../third_party/chrome/api/" |
| 18 | 18 |
| 19 # The path to the custom overrides directory, containing override files. | 19 # The path to the custom overrides directory, containing override files. |
| 20 OVERRIDES_DIR = "../src/chrome/custom_dart/" | 20 OVERRIDES_DIR = "../src/chrome/custom_dart/" |
| 21 | 21 |
| 22 # The path to where the generated .dart files should be saved. | 22 # The path to where the generated .dart files should be saved. |
| 23 OUTPUT_DIR = "../src/chrome/" | 23 OUTPUT_DIR = "../src/chrome/" |
| 24 | 24 |
| 25 # The path to where the output template file is. This file will be populated | 25 # The path to where the output template file is. This file will be populated |
| 26 # with TEMPLATE_CONTENT, followed by the list of generated .dart files. | 26 # with TEMPLATE_CONTENT, followed by the list of generated .dart files. |
| 27 OUTPUT_TEMPLATE = "../templates/html/dart2js/chrome_dart2js.darttemplate" | 27 OUTPUT_TEMPLATE = "../templates/html/dart2js/chrome_dart2js.darttemplate" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 58 """ | 58 """ |
| 59 | 59 |
| 60 # The format for adding files to TEMPLATE_CONTENT. Will be substituted with the | 60 # The format for adding files to TEMPLATE_CONTENT. Will be substituted with the |
| 61 # filename (not including the extension) of the IDL/JSON file. | 61 # filename (not including the extension) of the IDL/JSON file. |
| 62 TEMPLATE_FILE_FORMAT = 'part "$AUXILIARY_DIR/chrome/%s.dart";' | 62 TEMPLATE_FILE_FORMAT = 'part "$AUXILIARY_DIR/chrome/%s.dart";' |
| 63 | 63 |
| 64 # A list of schema files to generate. | 64 # A list of schema files to generate. |
| 65 # TODO(sashab): Later, use the ones from API_DIR/api.gyp and | 65 # TODO(sashab): Later, use the ones from API_DIR/api.gyp and |
| 66 # API_DIR/_permission_features.json (for 'platform_apps'). | 66 # API_DIR/_permission_features.json (for 'platform_apps'). |
| 67 API_FILES = [ | 67 API_FILES = [ |
| 68 "alarms.idl", |
| 68 "app_window.idl", | 69 "app_window.idl", |
| 69 "app_runtime.idl", | 70 "app_runtime.idl", |
| 71 "bluetooth.idl", |
| 72 "context_menus.json", |
| 73 "file_system.idl", |
| 74 "media_galleries.idl", |
| 75 "media_galleries_private.idl", |
| 76 "push_messaging.idl", |
| 77 "serial.idl", |
| 78 "socket.idl", |
| 79 "sync_file_system.idl", |
| 80 "system_indicator.idl", |
| 81 "system_info_display.idl", |
| 82 "usb.idl", |
| 83 # TODO(sashab): Add experimental APIs here, too. |
| 70 ] | 84 ] |
| 71 | 85 |
| 72 if __name__ == "__main__": | 86 if __name__ == "__main__": |
| 73 # Generate each file. | 87 # Generate each file. |
| 74 for filename in API_FILES: | 88 for filename in API_FILES: |
| 75 result = os.system('python "%s" -g dart -D "%s" -d "%s" -r "%s" "%s"' % ( | 89 result = os.system('python "%s" -g dart -D "%s" -d "%s" -r "%s" "%s"' % ( |
| 76 COMPILER, OVERRIDES_DIR, OUTPUT_DIR, API_DIR, | 90 COMPILER, OVERRIDES_DIR, OUTPUT_DIR, API_DIR, |
| 77 os.path.join(API_DIR, filename))) | 91 os.path.join(API_DIR, filename))) |
| 78 if result != 0: | 92 if result != 0: |
| 79 print "Error occurred during generation of %s" % ( | 93 print "Error occurred during generation of %s" % ( |
| 80 os.path.join(API_DIR, filename)) | 94 os.path.join(API_DIR, filename)) |
| 81 sys.exit(1) | 95 sys.exit(1) |
| 82 else: | 96 else: |
| 83 print "Generated %s successfully to %s.dart" % ( | 97 print "Generated %s successfully to %s.dart" % ( |
| 84 os.path.join(API_DIR, filename), | 98 os.path.join(API_DIR, filename), |
| 85 os.path.join(OUTPUT_DIR, os.path.splitext(filename)[0])) | 99 os.path.join(OUTPUT_DIR, os.path.splitext(filename)[0])) |
| 86 | 100 |
| 87 # Generate the template. | 101 # Generate the template. |
| 88 files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0] | 102 files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0] |
| 89 for f in API_FILES) | 103 for f in API_FILES) |
| 90 with open(OUTPUT_TEMPLATE, 'w') as template_file: | 104 with open(OUTPUT_TEMPLATE, 'w') as template_file: |
| 91 template_file.write(TEMPLATE_CONTENT) | 105 template_file.write(TEMPLATE_CONTENT) |
| 92 template_file.write('\n'.join(files_to_add)) | 106 template_file.write('\n'.join(files_to_add)) |
| 93 print "Generated template succesfully." | 107 print "Generated template succesfully." |
| 94 | 108 |
| 95 | 109 |
| OLD | NEW |