Chromium Code Reviews| Index: third_party/closure_compiler/compile.py |
| diff --git a/third_party/closure_compiler/compile.py b/third_party/closure_compiler/compile.py |
| index b40dcfc962f0dae97c82b16825b4604e2f056f15..059cb35c872a19ff95244f88b3412443a8b1fd86 100755 |
| --- a/third_party/closure_compiler/compile.py |
| +++ b/third_party/closure_compiler/compile.py |
| @@ -49,6 +49,17 @@ class Checker(object): |
| "--source_map_format=V3", |
| ] |
| + # Extra flags used when compiling polymer code. |
| + _POLYMER_ARGS = [ |
| + "--polymer_pass", |
| + "--extra_annotation_name=attribute", |
| + "--extra_annotation_name=status", |
| + "--extra_annotation_name=element", |
| + "--extra_annotation_name=homepage", |
| + "--extra_annotation_name=submodule", |
| + "--extra_annotation_name=group", |
|
Dan Beam
2015/05/12 01:09:06
arguable that we should be doing:
_POLYMER_ARGS
Jeremy Klein
2015/05/12 03:58:23
Done.
|
| + ] |
| + |
| # These are the extra flags used when compiling in strict mode. |
| # Flags that are normally disabled are turned on for strict mode. |
| _STRICT_CLOSURE_ARGS = [ |
| @@ -75,17 +86,19 @@ class Checker(object): |
| _MAP_FILE_FORMAT = "%s.map" |
| - def __init__(self, verbose=False, strict=False): |
| + def __init__(self, verbose=False, strict=False, polymer=False): |
| """ |
| Args: |
| verbose: Whether this class should output diagnostic messages. |
| strict: Whether the Closure Compiler should be invoked more strictly. |
| + polymer: Whether the Polymer pass is being run. |
| """ |
| current_dir = os.path.join(os.path.dirname(__file__)) |
|
Dan Beam
2015/05/12 01:09:06
can you move this to a global and re-use?
Jeremy Klein
2015/05/12 03:58:23
Done.
|
| self._runner_jar = os.path.join(current_dir, "runner", "runner.jar") |
| self._temp_files = [] |
| self._verbose = verbose |
| self._strict = strict |
| + self._polymer = polymer |
| self._error_filter = error_filter.PromiseErrorFilter() |
| def _nuke_temp_files(self): |
| @@ -259,6 +272,9 @@ class Checker(object): |
| if output_wrapper: |
| args += ['--output_wrapper="%s"' % output_wrapper] |
| + if self._polymer: |
| + args += self._POLYMER_ARGS |
| + |
| args_file_content = " %s" % " ".join(self._common_args() + args) |
| self._log_debug("Args: %s" % args_file_content.strip()) |
| @@ -382,6 +398,8 @@ if __name__ == "__main__": |
| help="Show more information as this script runs") |
| parser.add_argument("--strict", action="store_true", |
| help="Enable strict type checking") |
| + parser.add_argument("-p", "--polymer", type=int, |
| + help="'1' to run polymer-specific checks.") |
| parser.add_argument("--success-stamp", |
| help="Timestamp file to update upon success") |
| @@ -389,14 +407,22 @@ if __name__ == "__main__": |
| opts = parser.parse_args() |
| depends = opts.depends or [] |
| - externs = opts.externs or set() |
| + externs = set(opts.externs) or set() |
| + |
| + if opts.polymer: |
| + current_dir = os.path.join(os.path.dirname(__file__)) |
| + polymer_externs = os.path.join( |
| + current_dir, |
| + "../polymer/v0_8/components-chromium/polymer-externs/polymer.externs.js") |
|
Dan Beam
2015/05/12 01:10:57
80 col wrap
Dan Beam
2015/05/12 01:12:25
i think you might also want to use os.path.join()
Jeremy Klein
2015/05/12 03:58:23
Done.
Jeremy Klein
2015/05/12 03:58:23
Done.
|
| + externs.add(os.path.abspath(polymer_externs)) |
| if opts.out_file: |
| out_dir = os.path.dirname(opts.out_file) |
| if not os.path.exists(out_dir): |
| os.makedirs(out_dir) |
| - checker = Checker(verbose=opts.verbose, strict=opts.strict) |
| + checker = Checker(verbose=opts.verbose, strict=opts.strict, |
| + polymer=opts.polymer) |
| if opts.single_file: |
| for source in opts.sources: |
| depends, externs = build.inputs.resolve_recursive_dependencies( |