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

Side by Side Diff: tools/dom/scripts/chromegenerator.py

Issue 1526973002: Remove outdated support for chrome-only apis (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # BSD-style license that can be found in the LICENSE file.
5
6 """This module generates Dart Chrome APIs from the Chrome IDL files."""
7
8 import sys
9 import os
10
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.
13 COMPILER = "../../../third_party/chrome/tools/json_schema_compiler/compiler.py"
14
15 # The path to the Chrome IDL files. They live in the Chromium repository, so
16 # need to be pulled in somehow.
17 API_DIR = "../../../third_party/chrome/idl/"
18
19 # The path to the custom overrides directory, containing override files.
20 OVERRIDES_DIR = "../src/_chrome/custom_dart/"
21
22 # The path to where the generated .dart files should be saved.
23 OUTPUT_DIR = "../src/_chrome/"
24
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.
27 OUTPUT_TEMPLATE = "../templates/html/dart2js/chrome_dart2js.darttemplate"
28
29 # The content to fill OUTPUT_TEMPLATE with. Will be followed by a list of the
30 # names of the generated .dart files.
31 TEMPLATE_CONTENT = """
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
34 // BSD-style license that can be found in the LICENSE file.
35
36 // DO NOT EDIT
37 // Auto-generated dart:_chrome library.
38
39 /// Native wrappers for the Chrome packaged app APIs.
40 ///
41 /// These functions allow direct access to the chrome.* APIs, allowing
42 /// Chrome packaged apps to be written using Dart.
43 ///
44 /// For more information on these APIs, see the
45 /// [chrome.* API documentation](http://developer.chrome.com/apps/api_index.html ).
46 library _chrome;
47
48 import 'dart:_foreign_helper' show JS;
49 /* TODO(sashab): Add "show convertDartClosureToJS" once 'show' works. */
50 import 'dart:_js_helper';
51 import 'dart:html_common';
52 import 'dart:html';
53
54 part "$AUXILIARY_DIR/_chrome/utils.dart";
55 part "$AUXILIARY_DIR/_chrome/_chrome.dart";
56
57 // Generated files below this line.
58 """
59
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.
62 TEMPLATE_FILE_FORMAT = 'part "$AUXILIARY_DIR/_chrome/%s.dart";'
63
64 # A list of schema files to generate.
65 # TODO(sashab): Later, use the ones from API_DIR/api.gyp and
66 # API_DIR/_permission_features.json (for 'platform_apps').
67 API_FILES = [
68 "app_window.idl",
69 "app_runtime.idl",
70 "file_system.idl",
71 ]
72
73 if __name__ == "__main__":
74 # Generate each file.
75 for filename in API_FILES:
76 result = os.system('python "%s" -g dart -D "%s" -d "%s" -r "%s" "%s"' % (
77 COMPILER, OVERRIDES_DIR, OUTPUT_DIR, API_DIR,
78 os.path.join(API_DIR, filename)))
79 if result != 0:
80 print "Error occurred during generation of %s" % (
81 os.path.join(API_DIR, filename))
82 sys.exit(1)
83 else:
84 print "Generated %s successfully to %s.dart" % (
85 os.path.join(API_DIR, filename),
86 os.path.join(OUTPUT_DIR, os.path.splitext(filename)[0]))
87
88 # Generate the template.
89 files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0]
90 for f in API_FILES)
91 with open(OUTPUT_TEMPLATE, 'w') as template_file:
92 template_file.write(TEMPLATE_CONTENT)
93 template_file.write('\n'.join(files_to_add))
94 print "Generated template succesfully."
95
96
OLDNEW
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698