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

Unified Diff: third_party/closure_compiler/compile2.py

Issue 2247353004: GN files for running Closure Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add use of GN to run_compiler Created 4 years, 3 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/compile2.py
diff --git a/third_party/closure_compiler/compile2.py b/third_party/closure_compiler/compile2.py
index 59de787db165d03ba40e782322d844e06d65eafe..9f89126f2cd546683d6cf27fb8df805d9ee98ece 100755
--- a/third_party/closure_compiler/compile2.py
+++ b/third_party/closure_compiler/compile2.py
@@ -189,7 +189,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,
+ source_list_file=None,
Dan Beam 2016/09/06 16:46:46 can we call this like gn_source_list_file to make
aberent 2016/09/07 09:31:18 Done.
+ out_file=None,
+ runner_args=None,
+ closure_args=None,
custom_sources=True):
"""Closure compile |sources| while checking for errors.
@@ -209,6 +214,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 (source_list_file):
Dan Beam 2016/09/06 16:46:46 if source_list_file:
aberent 2016/09/07 09:31:18 Done.
+ with open(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
@@ -307,6 +324,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(
+ "--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",
@@ -321,7 +343,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,
+ source_list_file = opts.source_list_file,
Dan Beam 2016/09/06 16:46:46 no spaces between =, i.e. source_list_file=opts.so
aberent 2016/09/07 09:31:18 Done.
+ out_file=opts.out_file,
closure_args=opts.closure_args,
runner_args=opts.runner_args,
custom_sources=opts.custom_sources)

Powered by Google App Engine
This is Rietveld 408576698