| Index: tools/testing/frogpad/frogpad.py
|
| diff --git a/tools/testing/frogpad/frogpad.py b/tools/testing/frogpad/frogpad.py
|
| index b53cf16d91667054ebe9a84ab2a07c8c52ac9c39..e00f5b93236166ed88aae27d7f8a21d87811315f 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
|
| @@ -52,19 +52,9 @@ class CommandFailedException(Exception):
|
| return self._message
|
|
|
|
|
| -# This file is produced by compiling frogpad.dart to javascript. To do this
|
| -# we run frogc.dart on the dart vm.
|
| -#
|
| -# Note, we use ".frogc.js" as the extension (instead of simply ".js"),
|
| -# because this file is generated by frogc and not by frogpad.
|
| -#
|
| -# (For testing, it's useful to be able to distinguish files that are generated
|
| -# by frogc from files that are generated by frogpad.)
|
| -#
|
| -FROGPAD_JS = "frogpad.dart.frogc.js"
|
| -
|
| # Template for the html page we're going to generate.
|
| -HTML = """<html>
|
| +HTML = """<!DOCTYPE html>
|
| +<html>
|
| <head>
|
| <style type="text/css">
|
| textarea {
|
| @@ -107,6 +97,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(".*frogpad compilation error.*", re.DOTALL)
|
| +
|
| # We use "application/inert" here to make the browser ignore the
|
| # these script tags. (frogpad.dart will fish out the contents as needed.)
|
| #
|
| @@ -129,10 +123,10 @@ DART_LIBRARIES = {
|
| "coreimpl": "lib/corelib_impl.dart",
|
| "dom": "../client/dom/frog/dom_frog.dart",
|
| "html": "../client/html/frog/html_frog.dart",
|
| + "isolate": "../lib/isolate/isolate_frog.dart",
|
| "json": "../lib/json/json_frog.dart"
|
| }
|
|
|
| -
|
| class Pad(object):
|
| """
|
| Accumulates all source files that are needed to compile a dart program,
|
| @@ -143,8 +137,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",
|
| @@ -176,15 +170,22 @@ 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 of frogpad.js
|
| + # (frogpad.js is generated by running frogsh_bootstrap_wrapper.py)
|
| + 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
|
| + # user has specified an output file name
|
| self.js_file = os.path.abspath(options.out)
|
| else:
|
| - # user didn't specify an output file, so base the name on the
|
| - # input file
|
| + # User didn't specify an output file, so use the input
|
| + # file name as the base of the output file name.
|
| self.js_file = self.main_file + ".frogpad.js"
|
|
|
| logging.debug("js_file: '%s" % self.js_file)
|
| @@ -200,12 +201,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)
|
|
|
| @@ -216,43 +211,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)
|
| + logging.debug("generated '%s' (%d lines)", self.js_file, line_count)
|
|
|
| - 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")
|
| -
|
| - # 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 = []
|
|
|