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

Side by Side Diff: third_party/mojo/src/mojo/public/tools/dart_analyze.py

Issue 1142043005: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # To integrate dartanalyze with out build system, we take an input file, run 6 # To integrate dartanalyze with out build system, we take an input file, run
7 # the analyzer on it, and write a stamp file if it passed. 7 # the analyzer on it, and write a stamp file if it passed.
8 # 8 #
9 # The first argument to this script is a reference to this build's gen 9 # The first argument to this script is a reference to this build's gen
10 # directory, which we treat as the package root. The second is the stamp file 10 # directory, which we treat as the package root. The second is the stamp file
(...skipping 13 matching lines...) Expand all
24 re.compile(r'^$'), 24 re.compile(r'^$'),
25 re.compile(r'^Analyzing \['), 25 re.compile(r'^Analyzing \['),
26 re.compile(r'^No issues found'), 26 re.compile(r'^No issues found'),
27 re.compile(r'^[0-9]+ errors? and [0-9]+ warnings? found.'), 27 re.compile(r'^[0-9]+ errors? and [0-9]+ warnings? found.'),
28 re.compile(r'^([0-9]+|No) (error|warning|issue)s? found.'), 28 re.compile(r'^([0-9]+|No) (error|warning|issue)s? found.'),
29 29
30 # TODO: It seems like this should be re-enabled evenutally. 30 # TODO: It seems like this should be re-enabled evenutally.
31 re.compile(r'.*is a part and can not|^Only libraries can be analyzed'), 31 re.compile(r'.*is a part and can not|^Only libraries can be analyzed'),
32 # TODO: Remove this once dev SDK includes Uri.directory constructor. 32 # TODO: Remove this once dev SDK includes Uri.directory constructor.
33 re.compile(r'.*The class \'Uri\' does not have a constructor \'directory\''), 33 re.compile(r'.*The class \'Uri\' does not have a constructor \'directory\''),
34 # TODO: Remove this once Sky no longer generates this warning.
35 # dartbug.com/22836
36 re.compile(r'.*cannot both be unnamed'),
34 ] 37 ]
35 38
36 def _success(stamp_file): 39 def _success(stamp_file):
37 # We passed cleanly, so touch the stamp file so that we don't run again. 40 # We passed cleanly, so touch the stamp file so that we don't run again.
38 with open(stamp_file, 'a'): 41 with open(stamp_file, 'a'):
39 os.utime(stamp_file, None) 42 os.utime(stamp_file, None)
40 return 0 43 return 0
41 44
42 def main(args): 45 def main(args):
43 dartzip_file = args.pop(0) 46 dartzip_file = args.pop(0)
(...skipping 15 matching lines...) Expand all
59 ] 62 ]
60 63
61 # Grab all the toplevel dart files in the archive. 64 # Grab all the toplevel dart files in the archive.
62 dart_files = glob.glob(os.path.join(temp_dir, "*.dart")) 65 dart_files = glob.glob(os.path.join(temp_dir, "*.dart"))
63 66
64 if not dart_files: 67 if not dart_files:
65 return _success(stamp_file) 68 return _success(stamp_file)
66 69
67 cmd.extend(dart_files) 70 cmd.extend(dart_files)
68 cmd.extend(args) 71 cmd.extend(args)
69 cmd.append("--package-root=%s" % temp_dir) 72 cmd.append("--package-root=%s/packages" % temp_dir)
70 cmd.append("--fatal-warnings") 73 cmd.append("--fatal-warnings")
71 74
72 errors = 0 75 errors = 0
73 try: 76 try:
74 subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT) 77 subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT)
75 except subprocess.CalledProcessError as e: 78 except subprocess.CalledProcessError as e:
76 errors = set(l for l in e.output.split('\n') 79 errors = set(l for l in e.output.split('\n')
77 if not any(p.match(l) for p in _IGNORED_PATTERNS)) 80 if not any(p.match(l) for p in _IGNORED_PATTERNS))
78 for error in sorted(errors): 81 for error in sorted(errors):
79 print >> sys.stderr, error.replace(temp_dir + "/", dartzip_basename) 82 print >> sys.stderr, error.replace(temp_dir + "/", dartzip_basename)
80 83
81 if not errors: 84 if not errors:
82 return _success(stamp_file) 85 return _success(stamp_file)
83 return min(255, len(errors)) 86 return min(255, len(errors))
84 finally: 87 finally:
85 shutil.rmtree(temp_dir) 88 shutil.rmtree(temp_dir)
86 89
87 if __name__ == '__main__': 90 if __name__ == '__main__':
88 sys.exit(main(sys.argv[1:])) 91 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698