| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import argparse | 6 import argparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 from skypy.url_mappings import URLMappings |
| 13 |
| 12 SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) | 14 SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 13 SKY_ROOT = os.path.dirname(SKY_TOOLS_DIR) | 15 SKY_ROOT = os.path.dirname(SKY_TOOLS_DIR) |
| 14 SRC_ROOT = os.path.dirname(SKY_ROOT) | 16 SRC_ROOT = os.path.dirname(SKY_ROOT) |
| 15 | 17 |
| 16 _IGNORED_PATTERNS = [ | 18 _IGNORED_PATTERNS = [ |
| 17 # Ignored because they're not indicative of specific errors. | 19 # Ignored because they're not indicative of specific errors. |
| 18 re.compile(r'^$'), | 20 re.compile(r'^$'), |
| 19 re.compile(r'^Analyzing \['), | 21 re.compile(r'^Analyzing \['), |
| 20 re.compile(r'^No issues found'), | 22 re.compile(r'^No issues found'), |
| 21 re.compile(r'^[0-9]+ errors? and [0-9]+ warnings? found.'), | 23 re.compile(r'^[0-9]+ errors? and [0-9]+ warnings? found.'), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 # TODO: Remove this once Sky no longer generates this warning. | 41 # TODO: Remove this once Sky no longer generates this warning. |
| 40 # dartbug.com/23606 | 42 # dartbug.com/23606 |
| 41 re.compile(r'^\[warning] Missing concrete implementation of \'RenderObject.toS
tring\''), | 43 re.compile(r'^\[warning] Missing concrete implementation of \'RenderObject.toS
tring\''), |
| 42 ] | 44 ] |
| 43 | 45 |
| 44 def main(): | 46 def main(): |
| 45 parser = argparse.ArgumentParser(description='Sky Analyzer') | 47 parser = argparse.ArgumentParser(description='Sky Analyzer') |
| 46 parser.add_argument('--congratulate', action="store_true") | 48 parser.add_argument('--congratulate', action="store_true") |
| 47 parser.add_argument('build_dir', type=str) | 49 parser.add_argument('build_dir', type=str) |
| 48 parser.add_argument('app_path', type=str) | 50 parser.add_argument('app_path', type=str) |
| 51 |
| 49 args = parser.parse_args() | 52 args = parser.parse_args() |
| 50 build_dir = os.path.abspath(args.build_dir) | 53 build_dir = os.path.abspath(args.build_dir) |
| 54 |
| 55 url_mappings = URLMappings(SRC_ROOT, build_dir) |
| 51 analyzer_path = os.path.join(SRC_ROOT, 'third_party/dart-sdk/dart-sdk/bin/da
rtanalyzer') | 56 analyzer_path = os.path.join(SRC_ROOT, 'third_party/dart-sdk/dart-sdk/bin/da
rtanalyzer') |
| 52 dart_builtin_natives_path = os.path.join(SRC_ROOT, 'sky/engine/bindings/buil
tin_natives.dart') | |
| 53 dart_mojo_internal_path = os.path.join(SRC_ROOT, 'mojo/public/dart/sdk_ext/i
nternal.dart') | |
| 54 dart_sky_internals_path = os.path.join(SRC_ROOT, 'sky/engine/bindings/sky_in
ternals.dart') | |
| 55 dart_sky_path = os.path.join(build_dir, 'gen/sky/bindings/dart_sky.dart') | |
| 56 packages_root = os.path.join(build_dir, 'gen/dart-pkg/packages') | 57 packages_root = os.path.join(build_dir, 'gen/dart-pkg/packages') |
| 57 analyzer_args = [analyzer_path, | 58 |
| 58 "--url-mapping=dart:mojo.internal,%s" % dart_mojo_internal_path, | 59 analyzer_args = [ |
| 59 "--url-mapping=dart:sky,%s" % dart_sky_path, | 60 analyzer_path, |
| 60 "--url-mapping=dart:sky.internals,%s" % dart_sky_internals_path, | |
| 61 "--url-mapping=dart:sky_builtin_natives,%s" % dart_builtin_natives_path, | |
| 62 "--package-root", packages_root, | 61 "--package-root", packages_root, |
| 63 "--package-warnings", | 62 "--package-warnings", args.app_path |
| 64 args.app_path | 63 ] + url_mappings.as_args |
| 65 ] | 64 |
| 66 try: | 65 try: |
| 67 subprocess.check_output(analyzer_args, stderr=subprocess.STDOUT) | 66 subprocess.check_output(analyzer_args, stderr=subprocess.STDOUT) |
| 68 except subprocess.CalledProcessError as e: | 67 except subprocess.CalledProcessError as e: |
| 69 errors = [l for l in e.output.split('\n') | 68 errors = [l for l in e.output.split('\n') |
| 70 if not any(p.match(l) for p in _IGNORED_PATTERNS)] | 69 if not any(p.match(l) for p in _IGNORED_PATTERNS)] |
| 71 if len(errors) > 0: | 70 if len(errors) > 0: |
| 72 for error in errors: | 71 for error in errors: |
| 73 print >> sys.stderr, error | 72 print >> sys.stderr, error |
| 74 # Propagate analyzer error code. | 73 # Propagate analyzer error code. |
| 75 return e.returncode | 74 return e.returncode |
| 76 # If we do not have any errors left after filtering, return 0. | 75 # If we do not have any errors left after filtering, return 0. |
| 77 if args.congratulate: | 76 if args.congratulate: |
| 78 print >> sys.stdout, "No analyzer warnings!" | 77 print >> sys.stdout, "No analyzer warnings!" |
| 79 return 0 | 78 return 0 |
| 80 | 79 |
| 81 if __name__ == '__main__': | 80 if __name__ == '__main__': |
| 82 sys.exit(main()) | 81 sys.exit(main()) |
| OLD | NEW |