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

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

Issue 12209045: Initial commit of generated dart:chrome app_window and app_runtime (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Ensuring latest copy is uploaded Created 7 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/chrome/dart2js/chrome_dart2js.dart ('k') | tools/dom/src/chrome/app.runtime.dart » ('j') | 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_api_tools/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_api/"
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 Packaged App APIs, allowing
42 /// Chrome Packaged Apps to be written using Dart.
43 ///
44 /// For more information on these APIs, see the Chrome.* APIs Documentation:
45 /// http://developer.chrome.com/extensions/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 ]
71
72 if __name__ == "__main__":
73 # Generate each file.
74 for filename in API_FILES:
75 result = os.system('python "%s" -g dart -D "%s" -d "%s" -r "%s" "%s"' % (
76 COMPILER, OVERRIDES_DIR, OUTPUT_DIR, API_DIR,
77 os.path.join(API_DIR, filename)))
78 if result != 0:
79 print "Error occurred during generation of %s" % (
80 os.path.join(API_DIR, filename))
81 sys.exit(1)
82 else:
83 print "Generated %s successfully to %s.dart" % (
84 os.path.join(API_DIR, filename),
85 os.path.join(OUTPUT_DIR, os.path.splitext(filename)[0]))
86
87 # Generate the template.
88 files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0]
89 for f in API_FILES)
90 with open(OUTPUT_TEMPLATE, 'w') as template_file:
91 template_file.write(TEMPLATE_CONTENT)
92 template_file.write('\n'.join(files_to_add))
93 print "Generated template succesfully."
94
95
OLDNEW
« no previous file with comments | « sdk/lib/chrome/dart2js/chrome_dart2js.dart ('k') | tools/dom/src/chrome/app.runtime.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698