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

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

Issue 953953003: Introduce dartanalyze into our build. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
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.
8 #
9 # The first argument to this script is a reference to this build's gen
10 # directory. The second is the stamp file to touch if we succeed. The rest are
11 # passed to the analyzer verbatim.
12 #
13 # While it'd be nice to get a list of generated *.mojom.dart files from the gn
14 # file, AFAICT, that's impossible because the targets are in different
15 # files. Besides, this won't deal with dependencies correctly. So instead, we
16 # search the entire gen directory for *.mojom.dart files, and add a url-mapping
17 # for each found mojom.dart in our build.
Elliot Glaysher 2015/02/24 22:41:53 I suspect that this is what is making it slow, but
zra 2015/02/24 23:04:39 Can you just pass main.dart to the analyzer? Does
Elliot Glaysher 2015/02/24 23:47:48 Using --package-root works. However, it doesn't s
18
19 import os
20 import subprocess
21 import sys
22 import re
23
24 _ANALYZING_PATTERN = re.compile(r'^Analyzing \[')
25 _FINAL_REPORT_PATTERN = re.compile(r'^[0-9]+ errors and [0-9]+ warnings found.')
26
27 _NATIVE_ERROR_PATTERN = re.compile(
28 r'^\[error\] Native functions can only be declared in the SDK and code that '
29 r'is loaded through native extensions')
30 _WARNING_PATTERN = re.compile(r'^\[warning\]')
31 _THAT_ONE_BROKEN_CLOSE_IN_WEB_SOCKETS_PATTERN = re.compile(
32 r'^\[error\] The name \'close\' is already defined')
33
34 def main(args):
35 cmd = [
36 "../../third_party/dart-sdk/dart-sdk/bin/dartanalyzer",
37 ]
38
39 gen_dir = args.pop(0)
40 gen_dir_len = len(gen_dir) + 1
41 stamp_file = args.pop(0)
42 cmd.extend(args)
43
44 # Recursively walk gen_dir looking for mojom files
45 mojom_dart_files = []
46 for root, _, files in os.walk(gen_dir):
47 for name in files:
48 if name.endswith(".mojom.dart"):
49 mojom_dart_files.append(os.path.join(root, name))
50
51 # For every file found, add the proper package mappings.
52 for file_path in mojom_dart_files:
53 dart_name = file_path[gen_dir_len:]
54 cmd.append("--url-mapping=package:%s,%s" % (dart_name, file_path))
zra 2015/02/24 23:04:40 We should either: 1) use the --package-root flag,
55
56 passed = True
57 try:
58 subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT)
59 except subprocess.CalledProcessError as e:
60 # Perform post processing on the output. Filter out non-error messages and
61 # known problem patterns that we're working on.
62 raw_lines = e.output.split('\n')
63 # Remove the last empty line
64 raw_lines.pop()
65 filtered_lines = [i for i in raw_lines if (
66 not re.match(_ANALYZING_PATTERN, i) and
67 not re.match(_FINAL_REPORT_PATTERN, i) and
68 # TODO(erg): Remove the rest of these as fixes land:
69 not re.match(_WARNING_PATTERN, i) and
70 not re.match(_NATIVE_ERROR_PATTERN, i) and
71 not re.match(_THAT_ONE_BROKEN_CLOSE_IN_WEB_SOCKETS_PATTERN, i))]
72 for line in filtered_lines:
73 passed = False
74 print >> sys.stderr, line
75
76 if passed:
77 # We passed cleanly, so touch the stamp file so that we don't run again.
78 with open(stamp_file, 'a'):
79 os.utime(stamp_file, None)
80 return 0
81 else:
82 return -2
83
84 if __name__ == '__main__':
85 sys.exit(main(sys.argv[1:]))
OLDNEW
« mojo/public/dart/src/data_pipe.dart ('K') | « mojo/public/dart/src/data_pipe.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698