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

Unified Diff: third_party/closure_compiler/compile.py

Issue 1152583011: Refactor compile_js.gypi to support script_args and closure_args (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use script_args and closure_args Created 5 years, 7 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
Index: third_party/closure_compiler/compile.py
diff --git a/third_party/closure_compiler/compile.py b/third_party/closure_compiler/compile.py
index f39f94f3380c79cd5fa224763685863a7f55d20f..21526ab5a7467c30f7e3cbecb297c4b6fd81f5af 100755
--- a/third_party/closure_compiler/compile.py
+++ b/third_party/closure_compiler/compile.py
@@ -58,13 +58,6 @@ class Checker(object):
]
_COMMON_CLOSURE_ARGS = [
- "--accept_const_keyword",
- "--language_in=ECMASCRIPT5_STRICT",
- "--summary_detail_level=3",
- "--compilation_level=SIMPLE_OPTIMIZATIONS",
- "--source_map_format=V3",
- "--polymer_pass",
- ] + [
"--jscomp_error=%s" % err for err in _COMMON_JSCOMP_ERRORS
] + [
"--extra_annotation_name=%s" % a for a in _POLYMER_EXTRA_ANNOTATIONS
@@ -253,15 +246,14 @@ class Checker(object):
return tmp_file.name
def _run_js_check(self, sources, out_file=None, externs=None,
- output_wrapper=None):
+ closure_args=None):
"""Check |sources| for type errors.
Args:
sources: Files to check.
out_file: A file where the compiled output is written to.
externs: @extern files that inform the compiler about custom globals.
- output_wrapper: Wraps output into this string at the place denoted by the
- marker token %output%.
+ closure_args: Arguments passed directly to the closure compiler.
Returns:
(errors, stderr) A parsed list of errors (strings) found by the compiler
@@ -279,8 +271,7 @@ class Checker(object):
if externs:
args += ["--externs=%s" % e for e in externs]
- if output_wrapper:
- args += ['--output_wrapper="%s"' % output_wrapper]
+ args += closure_args
args_file_content = " %s" % " ".join(self._common_args() + args)
self._log_debug("Args: %s" % args_file_content.strip())
@@ -311,7 +302,7 @@ class Checker(object):
return errors, stderr
def check(self, source_file, out_file=None, depends=None, externs=None,
- output_wrapper=None):
+ closure_args=None):
"""Closure compiler |source_file| while checking for errors.
Args:
@@ -319,8 +310,7 @@ class Checker(object):
out_file: A file where the compiled output is written to.
depends: Files that |source_file| requires to run (e.g. earlier <script>).
externs: @extern files that inform the compiler about custom globals.
- output_wrapper: Wraps output into this string at the place denoted by the
- marker token %output%.
+ closure_args: Arguments passed directly to the closure compiler.
Returns:
(found_errors, stderr) A boolean indicating whether errors were found and
@@ -349,7 +339,7 @@ class Checker(object):
errors, stderr = self._run_js_check([self._expanded_file],
out_file=out_file, externs=externs,
- output_wrapper=output_wrapper)
+ closure_args=closure_args)
filtered_errors = self._filter_errors(errors)
cleaned_errors = map(self._clean_up_error, filtered_errors)
output = self._format_errors(cleaned_errors)
@@ -363,15 +353,14 @@ class Checker(object):
self._nuke_temp_files()
return bool(cleaned_errors), stderr
- def check_multiple(self, sources, out_file=None, output_wrapper=None,
+ def check_multiple(self, sources, out_file=None, closure_args=None,
externs=None):
"""Closure compile a set of files and check for errors.
Args:
sources: An array of files to check.
out_file: A file where the compiled output is written to.
- output_wrapper: Wraps output into this string at the place denoted by the
- marker token %output%.
+ closure_args: Arguments passed directly to the closure compiler.
externs: @extern files that inform the compiler about custom globals.
Returns:
@@ -379,7 +368,7 @@ class Checker(object):
the raw Closure Compiler stderr (as a string).
"""
errors, stderr = self._run_js_check(sources, out_file=out_file,
- output_wrapper=output_wrapper,
+ closure_args=closure_args,
externs=externs)
self._nuke_temp_files()
return bool(errors), stderr
@@ -401,9 +390,8 @@ if __name__ == "__main__":
parser.add_argument("-e", "--externs", nargs=argparse.ZERO_OR_MORE)
parser.add_argument("-o", "--out_file",
help="A file where the compiled output is written to")
- parser.add_argument("-w", "--output_wrapper",
- help="Wraps output into this string at the place"
- + " denoted by the marker token %output%")
+ parser.add_argument("-c", "--closure_args",
+ help="Arguments passed directly to the closure compiler")
parser.add_argument("-v", "--verbose", action="store_true",
help="Show more information as this script runs")
parser.add_argument("--strict", action="store_true",
@@ -429,14 +417,14 @@ if __name__ == "__main__":
source, depends, externs)
found_errors, _ = checker.check(source, out_file=opts.out_file,
depends=depends, externs=externs,
- output_wrapper=opts.output_wrapper)
+ closure_args=opts.closure_args)
if found_errors:
sys.exit(1)
else:
found_errors, stderr = checker.check_multiple(
opts.sources,
out_file=opts.out_file,
- output_wrapper=opts.output_wrapper,
+ closure_args=opts.closure_args,
externs=externs)
if found_errors:
print stderr

Powered by Google App Engine
This is Rietveld 408576698