| Index: third_party/closure_compiler/compile2.py
|
| diff --git a/third_party/closure_compiler/compile2.py b/third_party/closure_compiler/compile2.py
|
| index df844d129109dc082700ee9e89fe45d6dc534117..fbec2d8e430436216431e45d801c86ad6509eae1 100755
|
| --- a/third_party/closure_compiler/compile2.py
|
| +++ b/third_party/closure_compiler/compile2.py
|
| @@ -2,6 +2,7 @@
|
| # Copyright 2015 The Chromium Authors. All rights reserved.
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
| +from argparse import Action
|
|
|
| """Runs Closure compiler on JavaScript files to check for errors and produce
|
| minified output."""
|
| @@ -190,7 +191,7 @@ class Checker(object):
|
| return tmp_file.name
|
|
|
| def check(self, sources, out_file=None, closure_args=None,
|
| - custom_sources=True):
|
| + custom_sources=True, enable_chrome_pass=True):
|
| """Closure compile |sources| while checking for errors.
|
|
|
| Args:
|
| @@ -224,7 +225,7 @@ class Checker(object):
|
| self._log_debug("Dependencies: %s" % deps)
|
| self._log_debug("Target: %s" % self._target)
|
|
|
| - js_args = deps + [self._target] if self._target else []
|
| + js_args = deps + ([self._target] if self._target else [])
|
|
|
| if not custom_sources:
|
| # TODO(dbeam): compiler.jar automatically detects "@externs" in a --js arg
|
| @@ -265,12 +266,16 @@ class Checker(object):
|
| self._log_debug("Args file: %s" % args_file)
|
|
|
| runner_args = ["--compiler-args-file=%s" % args_file]
|
| + if enable_chrome_pass:
|
| + runner_args += ["--enable_chrome_pass"]
|
| +
|
| _, stderr = self._run_jar(self._runner_jar, runner_args)
|
|
|
| errors = stderr.strip().split("\n\n")
|
| maybe_summary = errors.pop()
|
|
|
| - if re.search(".*error.*warning.*typed", maybe_summary):
|
| + summary = re.search("(?P<error_count>\d+).*error.*warning", maybe_summary)
|
| + if summary:
|
| self._log_debug("Summary: %s" % maybe_summary)
|
| else:
|
| # Not a summary. Running the jar failed. Bail.
|
| @@ -278,7 +283,7 @@ class Checker(object):
|
| self._nuke_temp_files()
|
| sys.exit(1)
|
|
|
| - if errors and out_file:
|
| + if summary.group('error_count') != "0" and out_file:
|
| if os.path.exists(out_file):
|
| os.remove(out_file)
|
| if os.path.exists(self._MAP_FILE_FORMAT % out_file):
|
| @@ -310,15 +315,20 @@ if __name__ == "__main__":
|
| help="A file where the compiled output is written to")
|
| parser.add_argument("-c", "--closure_args", nargs=argparse.ZERO_OR_MORE,
|
| help="Arguments passed directly to the Closure compiler")
|
| + parser.add_argument("--disable_chrome_pass", action="store_true",
|
| + help="Disables the extra Chrome specific processing")
|
| parser.add_argument("-v", "--verbose", action="store_true",
|
| help="Show more information as this script runs")
|
| opts = parser.parse_args()
|
|
|
| checker = Checker(verbose=opts.verbose)
|
|
|
| - found_errors, stderr = checker.check(opts.sources, out_file=opts.out_file,
|
| - closure_args=opts.closure_args,
|
| - custom_sources=opts.custom_sources)
|
| + found_errors, stderr = checker.check(
|
| + opts.sources,
|
| + out_file=opts.out_file,
|
| + closure_args=opts.closure_args,
|
| + custom_sources=opts.custom_sources,
|
| + enable_chrome_pass=not opts.disable_chrome_pass)
|
|
|
| if found_errors:
|
| if opts.custom_sources:
|
|
|