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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/chromegenerator.py
diff --git a/tools/dom/scripts/chromegenerator.py b/tools/dom/scripts/chromegenerator.py
new file mode 100755
index 0000000000000000000000000000000000000000..af6ef3a5b4d143fdb703b3a17cade665d6e9eb3f
--- /dev/null
+++ b/tools/dom/scripts/chromegenerator.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+"""This module generates Dart Chrome APIs from the Chrome IDL files."""
+
+import sys
+import os
+
+# The path to the JSON Schema Compiler, which can be run to generate the files.
+# Lives in the Chromium repository, so needs to be pulled in somehow.
+COMPILER = "../../../third_party/chrome_api_tools/compiler.py"
+
+# The path to the Chrome IDL files. They live in the Chromium repository, so
+# need to be pulled in somehow.
+API_DIR = "../../../third_party/chrome_api/"
+
+# The path to the custom overrides directory, containing override files.
+OVERRIDES_DIR = "../src/chrome/custom_dart/"
+
+# The path to where the generated .dart files should be saved.
+OUTPUT_DIR = "../src/chrome/"
+
+# The path to where the output template file is. This file will be populated
+# with TEMPLATE_CONTENT, followed by the list of generated .dart files.
+OUTPUT_TEMPLATE = "../templates/html/dart2js/chrome_dart2js.darttemplate"
+
+# The content to fill OUTPUT_TEMPLATE with. Will be followed by a list of the
+# names of the generated .dart files.
+TEMPLATE_CONTENT = """
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// DO NOT EDIT
+// Auto-generated dart:chrome library.
+
+/// Native wrappers for the Chrome Packaged App APIs.
+///
+/// These functions allow direct access to the Packaged App APIs, allowing
+/// Chrome Packaged Apps to be written using Dart.
+///
+/// For more information on these APIs, see the Chrome.* APIs Documentation:
+/// http://developer.chrome.com/extensions/api_index.html
+library chrome;
+
+import 'dart:_foreign_helper' show JS;
+/* TODO(sashab): Add "show convertDartClosureToJS" once 'show' works. */
+import 'dart:_js_helper';
+import 'dart:html_common';
+import 'dart:html';
+
+part "$AUXILIARY_DIR/chrome/utils.dart";
+part "$AUXILIARY_DIR/chrome/chrome.dart";
+
+// Generated files below this line.
+"""
+
+# The format for adding files to TEMPLATE_CONTENT. Will be substituted with the
+# filename (not including the extension) of the IDL/JSON file.
+TEMPLATE_FILE_FORMAT = 'part "$AUXILIARY_DIR/chrome/%s.dart";'
+
+# A list of schema files to generate.
+# TODO(sashab): Later, use the ones from API_DIR/api.gyp and
+# API_DIR/_permission_features.json (for 'platform_apps').
+API_FILES = [
+ "app_window.idl",
+ "app_runtime.idl",
+]
+
+if __name__ == "__main__":
+ # Generate each file.
+ for filename in API_FILES:
+ result = os.system('python "%s" -g dart -D "%s" -d "%s" -r "%s" "%s"' % (
+ COMPILER, OVERRIDES_DIR, OUTPUT_DIR, API_DIR,
+ os.path.join(API_DIR, filename)))
+ if result != 0:
+ print "Error occurred during generation of %s" % (
+ os.path.join(API_DIR, filename))
+ sys.exit(1)
+ else:
+ print "Generated %s successfully to %s.dart" % (
+ os.path.join(API_DIR, filename),
+ os.path.join(OUTPUT_DIR, os.path.splitext(filename)[0]))
+
+ # Generate the template.
+ files_to_add = (TEMPLATE_FILE_FORMAT % os.path.splitext(f)[0]
+ for f in API_FILES)
+ with open(OUTPUT_TEMPLATE, 'w') as template_file:
+ template_file.write(TEMPLATE_CONTENT)
+ template_file.write('\n'.join(files_to_add))
+ print "Generated template succesfully."
+
+
« 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