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/tools/json_schema_compiler/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/idl/" | 17 API_DIR = "../../../third_party/chrome/idl/" |
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" |
28 | 28 |
29 # The content to fill OUTPUT_TEMPLATE with. Will be followed by a list of the | 29 # The content to fill OUTPUT_TEMPLATE with. Will be followed by a list of the |
30 # names of the generated .dart files. | 30 # names of the generated .dart files. |
31 TEMPLATE_CONTENT = """ | 31 TEMPLATE_CONTENT = """ |
32 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 32 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
33 // for details. All rights reserved. Use of this source code is governed by a | 33 // for details. All rights reserved. Use of this source code is governed by a |
34 // BSD-style license that can be found in the LICENSE file. | 34 // BSD-style license that can be found in the LICENSE file. |
35 | 35 |
36 // DO NOT EDIT | 36 // DO NOT EDIT |
37 // Auto-generated dart:chrome library. | 37 // Auto-generated dart:_chrome library. |
38 | 38 |
39 /// Native wrappers for the Chrome packaged app APIs. | 39 /// Native wrappers for the Chrome packaged app APIs. |
40 /// | 40 /// |
41 /// These functions allow direct access to the chrome.* APIs, allowing | 41 /// These functions allow direct access to the chrome.* APIs, allowing |
42 /// Chrome packaged apps to be written using Dart. | 42 /// Chrome packaged apps to be written using Dart. |
43 /// | 43 /// |
44 /// For more information on these APIs, see the | 44 /// For more information on these APIs, see the |
45 /// [chrome.* API documentation](http://developer.chrome.com/apps/api_index.html
). | 45 /// [chrome.* API documentation](http://developer.chrome.com/apps/api_index.html
). |
46 library chrome; | 46 library _chrome; |
47 | 47 |
48 import 'dart:_foreign_helper' show JS; | 48 import 'dart:_foreign_helper' show JS; |
49 /* TODO(sashab): Add "show convertDartClosureToJS" once 'show' works. */ | 49 /* TODO(sashab): Add "show convertDartClosureToJS" once 'show' works. */ |
50 import 'dart:_js_helper'; | 50 import 'dart:_js_helper'; |
51 import 'dart:html_common'; | 51 import 'dart:html_common'; |
52 import 'dart:html'; | 52 import 'dart:html'; |
53 | 53 |
54 part "$AUXILIARY_DIR/chrome/utils.dart"; | 54 part "$AUXILIARY_DIR/_chrome/utils.dart"; |
55 part "$AUXILIARY_DIR/chrome/chrome.dart"; | 55 part "$AUXILIARY_DIR/_chrome/_chrome.dart"; |
56 | 56 |
57 // Generated files below this line. | 57 // Generated files below this line. |
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 "app_window.idl", | 68 "app_window.idl", |
69 "app_runtime.idl", | 69 "app_runtime.idl", |
70 "file_system.idl", | 70 "file_system.idl", |
71 ] | 71 ] |
72 | 72 |
(...skipping 14 matching lines...) Expand all Loading... |
87 | 87 |
88 # Generate the template. | 88 # Generate the template. |
89 files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0] | 89 files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0] |
90 for f in API_FILES) | 90 for f in API_FILES) |
91 with open(OUTPUT_TEMPLATE, 'w') as template_file: | 91 with open(OUTPUT_TEMPLATE, 'w') as template_file: |
92 template_file.write(TEMPLATE_CONTENT) | 92 template_file.write(TEMPLATE_CONTENT) |
93 template_file.write('\n'.join(files_to_add)) | 93 template_file.write('\n'.join(files_to_add)) |
94 print "Generated template succesfully." | 94 print "Generated template succesfully." |
95 | 95 |
96 | 96 |
OLD | NEW |