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

Unified Diff: tools/testing/frogpad/frogpad.py

Issue 9610002: remove node.js dependency by running the frog compiler in (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: language status Created 8 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
« tools/testing/dart/test_options.dart ('K') | « tools/testing/frogpad/frogpad.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/frogpad/frogpad.py
diff --git a/tools/testing/frogpad/frogpad.py b/tools/testing/frogpad/frogpad.py
index c9f1f3a8a3fd208e20b14be2dce3e4b13cd1d3e4..7dae3163377b0820780c10345d93f6801710eb6a 100755
--- a/tools/testing/frogpad/frogpad.py
+++ b/tools/testing/frogpad/frogpad.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env 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
@@ -107,6 +107,10 @@ HTML = """<html>
# we need to use the DOTALL switch here.)
OUTPUT_JAVASCRIPT_REGEX = re.compile(".*\nOutput:(.*)#EOF", re.DOTALL)
+# If the frogpad.dart encounters a compilation error, the generated
+# javascript will start with the word 'throw'.
+COMPILATION_ERROR_REGEX = re.compile(r"\s*throw\s")
+
# We use "application/inert" here to make the browser ignore the
# these script tags. (frogpad.dart will fish out the contents as needed.)
#
@@ -130,6 +134,7 @@ DART_LIBRARIES = {
"dom": "../client/dom/frog/dom_frog.dart",
"html": "../client/html/release/html.dart",
"htmlimpl": "../client/html/release/htmlimpl.dart",
+ "isolate": "../lib/isolate/isolate_frog.dart",
"json": "../lib/json/json_frog.dart"
}
@@ -144,8 +149,8 @@ class Pad(object):
parser = optparse.OptionParser(usage=
"%prog [options] file_to_compile.dart"
)
- parser.add_option("-r", "--rebuild", action="store_true",
- help="forces rebuild of the frogpad javascript")
+ parser.add_option("-f", "--frogpad_js",
+ help="location of frogpad.js file")
parser.add_option("-o", "--out",
help="name of javascript output file")
parser.add_option("-v", "--verbose", action="store_true",
@@ -177,8 +182,14 @@ class Pad(object):
logging.debug("frog_dir: '%s'" % self.frog_dir)
logging.debug("frogpad_dir: '%s'" % self.frogpad_dir)
- # name of frogpad_js file
- self.frogpad_js = os.path.join(self.frogpad_dir, FROGPAD_JS)
+ # location frogpad.js file
+ if not options.frogpad_js:
+ raise Exception("--frogpad_js is required")
+
+ if not os.path.exists(options.frogpad_js):
+ raise FileNotFoundException(options.frogpad_js)
+
+ self.frogpad_js = options.frogpad_js
if options.out:
# user has specified an output file
@@ -201,12 +212,6 @@ class Pad(object):
# map from script tag id to File object
self.id_to_file = {}
- if not os.path.exists(self.frogpad_js):
- options.rebuild = True
-
- if options.rebuild:
- self.build_frogpad_js()
-
self.load_libraries()
self.load_file(self.main_file)
@@ -217,43 +222,11 @@ class Pad(object):
write_file(self.js_file, js)
line_count = len(js.splitlines())
- logging.info("generated '%s' (%d lines)", self.js_file, line_count)
-
- def build_frogpad_js(self):
- dart_vm = os.path.join(self.dart_dir, "out/Release_ia32/dart")
- check_exists(dart_vm)
-
- frogc_dart = os.path.join(self.frog_dir, "frogc.dart")
- frogpad_dart = os.path.join(self.frogpad_dir, "frogpad.dart")
- check_exists(frogc_dart)
- check_exists(frogpad_dart)
-
- args = []
- args.append(dart_vm)
-
- # command line arguments for the dart vm
-
- # We leave out --enable_type_checks here for speed.
- # args.append("--enable_type_checks")
-
- args.append("--enable_asserts")
+ logging.debug("generated '%s' (%d lines)", self.js_file, line_count)
- # The dart program we're going to run on the dart vm.
- args.append(frogc_dart)
-
- # Command line arguments for frogc.dart
- args.append("--libdir=%s/lib" % self.frog_dir)
- args.append("--compile-only")
- args.append("--enable_type_checks")
- args.append("--enable_asserts")
- args.append("--out=%s" % self.frogpad_js)
-
- # The dart program that we want frogc.dart to compile.
- args.append(frogpad_dart)
- logging.info("generating '%s'" % self.frogpad_js)
-
- run_command(args)
- check_exists(self.frogpad_js)
+ match = COMPILATION_ERROR_REGEX.match(js)
+ if match:
+ sys.exit(1)
def generate_html(self):
tags = []
« tools/testing/dart/test_options.dart ('K') | « tools/testing/frogpad/frogpad.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698