| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Utility for dart_pkg and dart_pkg_app rules""" | 7 """Utility for dart_pkg and dart_pkg_app rules""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import errno | 10 import errno |
| 11 import json | 11 import json |
| 12 import os | 12 import os |
| 13 import shutil | 13 import shutil |
| 14 import subprocess | 14 import subprocess |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 USE_LINKS = sys.platform != "win32" | 17 USE_LINKS = sys.platform != "win32" |
| 18 | 18 |
| 19 DART_ANALYZE = os.path.join(os.path.dirname(os.path.abspath(__file__)), | 19 DART_ANALYZE = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 20 "dart_analyze.py") | 20 "dart_analyze.py") |
| 21 | 21 |
| 22 def mojom_dart_filter(path): | |
| 23 if os.path.isdir(path): | |
| 24 return True | |
| 25 # Don't include all .dart, just .mojom.dart. | |
| 26 return path.endswith('.mojom.dart') | |
| 27 | |
| 28 | |
| 29 def dart_filter(path): | 22 def dart_filter(path): |
| 30 if os.path.isdir(path): | 23 if os.path.isdir(path): |
| 31 return True | 24 return True |
| 32 _, ext = os.path.splitext(path) | 25 _, ext = os.path.splitext(path) |
| 33 # .dart includes '.mojom.dart' | 26 # .dart includes '.mojom.dart' |
| 34 return ext == '.dart' | 27 return ext == '.dart' |
| 35 | 28 |
| 36 | 29 |
| 37 def mojom_filter(path): | |
| 38 if os.path.isdir(path): | |
| 39 return True | |
| 40 _, ext = os.path.splitext(path) | |
| 41 return ext == '.mojom' | |
| 42 | |
| 43 | |
| 44 def ensure_dir_exists(path): | 30 def ensure_dir_exists(path): |
| 45 abspath = os.path.abspath(path) | 31 abspath = os.path.abspath(path) |
| 46 if not os.path.exists(abspath): | 32 if not os.path.exists(abspath): |
| 47 os.makedirs(abspath) | 33 os.makedirs(abspath) |
| 48 | 34 |
| 49 | 35 |
| 50 def has_pubspec_yaml(paths): | 36 def has_pubspec_yaml(paths): |
| 51 for path in paths: | 37 for path in paths: |
| 52 _, filename = os.path.split(path) | 38 _, filename = os.path.split(path) |
| 53 if 'pubspec.yaml' == filename: | 39 if 'pubspec.yaml' == filename: |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 required=True) | 184 required=True) |
| 199 parser.add_argument('--package-sources', | 185 parser.add_argument('--package-sources', |
| 200 metavar='package_sources', | 186 metavar='package_sources', |
| 201 help='Package sources', | 187 help='Package sources', |
| 202 nargs='+') | 188 nargs='+') |
| 203 parser.add_argument('--package-entrypoints', | 189 parser.add_argument('--package-entrypoints', |
| 204 metavar='package_entrypoints', | 190 metavar='package_entrypoints', |
| 205 help='Package entry points for analyzer', | 191 help='Package entry points for analyzer', |
| 206 nargs='*', | 192 nargs='*', |
| 207 default=[]) | 193 default=[]) |
| 208 parser.add_argument('--mojom-sources', | |
| 209 metavar='mojom_sources', | |
| 210 help='.mojom and .mojom.dart sources', | |
| 211 nargs='*', | |
| 212 default=[]) | |
| 213 parser.add_argument('--sdk-ext-directories', | 194 parser.add_argument('--sdk-ext-directories', |
| 214 metavar='sdk_ext_directories', | 195 metavar='sdk_ext_directories', |
| 215 help='Directory containing .dart sources', | 196 help='Directory containing .dart sources', |
| 216 nargs='*', | 197 nargs='*', |
| 217 default=[]) | 198 default=[]) |
| 218 parser.add_argument('--sdk-ext-files', | 199 parser.add_argument('--sdk-ext-files', |
| 219 metavar='sdk_ext_files', | 200 metavar='sdk_ext_files', |
| 220 help='List of .dart files that are part of of sdk_ext.', | 201 help='List of .dart files that are part of of sdk_ext.', |
| 221 nargs='*', | 202 nargs='*', |
| 222 default=[]) | 203 default=[]) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 f.write(entrypoint + '\n') | 284 f.write(entrypoint + '\n') |
| 304 | 285 |
| 305 # Write stamp file. | 286 # Write stamp file. |
| 306 with open(args.stamp_file, 'w'): | 287 with open(args.stamp_file, 'w'): |
| 307 pass | 288 pass |
| 308 | 289 |
| 309 return 0 | 290 return 0 |
| 310 | 291 |
| 311 if __name__ == '__main__': | 292 if __name__ == '__main__': |
| 312 sys.exit(main()) | 293 sys.exit(main()) |
| OLD | NEW |