| Index: third_party/closure_compiler/compile2.py
|
| diff --git a/third_party/closure_compiler/compile2.py b/third_party/closure_compiler/compile2.py
|
| index dfd22cfe26700adbec40eaeb000337cc5a474319..ff14b9dc016da6fdd98385d64707ed451ac3dcf2 100755
|
| --- a/third_party/closure_compiler/compile2.py
|
| +++ b/third_party/closure_compiler/compile2.py
|
| @@ -188,7 +188,12 @@ class Checker(object):
|
| tmp_file.write(contents)
|
| return tmp_file.name
|
|
|
| - def check(self, sources, out_file=None, runner_args=None, closure_args=None,
|
| + def check(self,
|
| + sources,
|
| + gn_source_list_file=None,
|
| + out_file=None,
|
| + runner_args=None,
|
| + closure_args=None,
|
| custom_sources=True):
|
| """Closure compile |sources| while checking for errors.
|
|
|
| @@ -208,6 +213,18 @@ class Checker(object):
|
| """
|
| is_extern = lambda f: 'extern' in f
|
| externs_and_deps = [self._POLYMER_EXTERNS]
|
| +
|
| + # Convert the sources to absolute paths to make comparisons easy.
|
| + sources = map(os.path.abspath, sources)
|
| + # Process the source list.
|
| + if gn_source_list_file:
|
| + with open(gn_source_list_file) as f:
|
| + listed_sources = f.read().splitlines()
|
| + # Ignore the first line, GN puts the output file name here
|
| + listed_sources = listed_sources[1:]
|
| + listed_sources = map(os.path.abspath, listed_sources)
|
| + # Concatenate onto sources, removing duplicates
|
| + sources += [x for x in listed_sources if x not in sources]
|
|
|
| if custom_sources:
|
| externs_and_deps += sources
|
| @@ -306,6 +323,11 @@ if __name__ == "__main__":
|
| description="Typecheck JavaScript using Closure compiler")
|
| parser.add_argument("sources", nargs=argparse.ONE_OR_MORE,
|
| help="Path to a source file to typecheck")
|
| + parser.add_argument(
|
| + "--gn_source_list_file",
|
| + help="""A file generated by GN containing a list of
|
| + additional sources. Due to an oddity in how this is
|
| + generated the first line is ignored""")
|
| parser.add_argument("--custom_sources", action="store_true",
|
| help="Whether this rules has custom sources.")
|
| parser.add_argument("-o", "--out_file",
|
| @@ -320,7 +342,9 @@ if __name__ == "__main__":
|
|
|
| checker = Checker(verbose=opts.verbose)
|
|
|
| - found_errors, stderr = checker.check(opts.sources, out_file=opts.out_file,
|
| + found_errors, stderr = checker.check(opts.sources,
|
| + gn_source_list_file=opts.gn_source_list_file,
|
| + out_file=opts.out_file,
|
| closure_args=opts.closure_args,
|
| runner_args=opts.runner_args,
|
| custom_sources=opts.custom_sources)
|
|
|