Index: third_party/closure_compiler/compile.py |
diff --git a/third_party/closure_compiler/compile.py b/third_party/closure_compiler/compile.py |
index c287884f6a019d5f0c74b59e31909009c36f562e..421634d2c31a35cfe79882d97dc8332fb0439d9d 100755 |
--- a/third_party/closure_compiler/compile.py |
+++ b/third_party/closure_compiler/compile.py |
@@ -186,13 +186,14 @@ class Checker(object): |
return tmp_file.name |
def _run_js_check(self, sources, out_file=None, externs=None, |
- closure_args=None): |
+ runner_args=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. |
+ runner_args: Arguments passed to runner.jar. |
closure_args: Arguments passed directly to the Closure compiler. |
Returns: |
@@ -220,7 +221,8 @@ class Checker(object): |
args_file = self._create_temp_file(args_file_content) |
self._log_debug("Args file: %s" % args_file) |
- runner_args = ["--compiler-args-file=%s" % args_file] |
+ runner_args = ["--%s" % arg for arg in runner_args or []] |
aberent
2016/08/02 10:52:24
Using the same variable for both the processed and
Dan Beam
2016/08/02 19:36:33
Done.
|
+ runner_args += ["--compiler-args-file=%s" % args_file] |
_, stderr = self._run_jar(self._runner_jar, runner_args) |
errors = stderr.strip().split("\n\n") |
@@ -243,7 +245,7 @@ class Checker(object): |
return errors, stderr |
def check(self, source_file, out_file=None, depends=None, externs=None, |
- closure_args=None): |
+ runner_args=None, closure_args=None): |
"""Closure compiler |source_file| while checking for errors. |
Args: |
@@ -251,6 +253,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. |
+ runner_args: Arguments passed to runner.jar. |
closure_args: Arguments passed directly to the Closure compiler. |
Returns: |
@@ -280,6 +283,7 @@ class Checker(object): |
errors, stderr = self._run_js_check([self._expanded_file], |
out_file=out_file, externs=externs, |
+ runner_args=runner_args, |
closure_args=closure_args) |
filtered_errors = self._filter_errors(errors) |
cleaned_errors = map(self._clean_up_error, filtered_errors) |
@@ -295,13 +299,14 @@ class Checker(object): |
return bool(cleaned_errors), stderr |
def check_multiple(self, sources, out_file=None, externs=None, |
- closure_args=None): |
+ runner_args=None, closure_args=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. |
externs: @extern files that inform the compiler about custom globals. |
+ runner_args: Arguments passed to runner.jar. |
closure_args: Arguments passed directly to the Closure compiler. |
Returns: |
@@ -310,6 +315,7 @@ class Checker(object): |
""" |
errors, stderr = self._run_js_check(sources, out_file=out_file, |
externs=externs, |
+ runner_args=runner_args, |
closure_args=closure_args) |
self._nuke_temp_files() |
return bool(errors), stderr |
@@ -330,9 +336,12 @@ if __name__ == "__main__": |
help="Process all source files as a group") |
parser.add_argument("-d", "--depends", nargs=argparse.ZERO_OR_MORE) |
parser.add_argument("-e", "--externs", nargs=argparse.ZERO_OR_MORE) |
- parser.add_argument("-o", "--out-file", dest="out_file", |
+ parser.add_argument("-o", "--out_file", dest="out_file", |
aberent
2016/08/02 10:52:24
Why the change? A '-' is conventional for multi-wo
Dan Beam
2016/08/02 19:36:33
switching to _ consistently everywhere to:
a) be
|
help="A file where the compiled output is written to") |
- parser.add_argument("-c", "--closure-args", dest="closure_args", |
+ parser.add_argument("-r", "--runner_args", dest="runner_args", |
+ nargs=argparse.ZERO_OR_MORE, |
+ help="Arguments passed to runner.jar") |
+ parser.add_argument("-c", "--closure_args", dest="closure_args", |
aberent
2016/08/02 10:52:24
Ditto.
Dan Beam
2016/08/02 19:36:33
Done.
|
nargs=argparse.ZERO_OR_MORE, |
help="Arguments passed directly to the Closure compiler") |
parser.add_argument("-v", "--verbose", action="store_true", |
@@ -359,6 +368,7 @@ if __name__ == "__main__": |
found_errors, _ = checker.check(source, out_file=opts.out_file, |
depends=depends, externs=externs, |
+ runner_args=opts.runner_args, |
closure_args=opts.closure_args) |
if found_errors: |
sys.exit(1) |
@@ -367,6 +377,7 @@ if __name__ == "__main__": |
sources, |
out_file=opts.out_file, |
externs=externs, |
+ runner_args=opts.runner_args, |
closure_args=opts.closure_args) |
if found_errors: |
print stderr |