| 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 # Disable lint check for finding modules: | |
| 18 # pylint: disable=F0401 | |
| 19 | |
| 20 sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), | |
| 21 "bindings/pylib")) | |
| 22 | |
| 23 from mojom.parse.parser import Parse | |
| 24 from mojom.parse.translate import Translate | |
| 25 | |
| 26 USE_LINKS = sys.platform != "win32" | 17 USE_LINKS = sys.platform != "win32" |
| 27 | 18 |
| 28 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__)), |
| 29 "dart_analyze.py") | 20 "dart_analyze.py") |
| 30 | 21 |
| 31 def mojom_dart_filter(path): | 22 def mojom_dart_filter(path): |
| 32 if os.path.isdir(path): | 23 if os.path.isdir(path): |
| 33 return True | 24 return True |
| 34 # Don't include all .dart, just .mojom.dart. | 25 # Don't include all .dart, just .mojom.dart. |
| 35 return path.endswith('.mojom.dart') | 26 return path.endswith('.mojom.dart') |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 remove_if_exists(path) | 144 remove_if_exists(path) |
| 154 | 145 |
| 155 | 146 |
| 156 def remove_broken_symlinks(root_dir): | 147 def remove_broken_symlinks(root_dir): |
| 157 for current_dir, _, child_files in os.walk(root_dir): | 148 for current_dir, _, child_files in os.walk(root_dir): |
| 158 for filename in child_files: | 149 for filename in child_files: |
| 159 path = os.path.join(current_dir, filename) | 150 path = os.path.join(current_dir, filename) |
| 160 remove_broken_symlink(path) | 151 remove_broken_symlink(path) |
| 161 | 152 |
| 162 | 153 |
| 163 def mojom_path(filename): | |
| 164 with open(filename) as f: | |
| 165 source = f.read() | |
| 166 tree = Parse(source, filename) | |
| 167 _, name = os.path.split(filename) | |
| 168 mojom = Translate(tree, name) | |
| 169 elements = mojom['namespace'].split('.') | |
| 170 elements.append("%s" % mojom['name']) | |
| 171 return os.path.join(*elements) | |
| 172 | |
| 173 | |
| 174 def analyze_entrypoints(dart_sdk, package_root, entrypoints): | 154 def analyze_entrypoints(dart_sdk, package_root, entrypoints): |
| 175 cmd = [ "python", DART_ANALYZE ] | 155 cmd = [ "python", DART_ANALYZE ] |
| 176 cmd.append("--dart-sdk") | 156 cmd.append("--dart-sdk") |
| 177 cmd.append(dart_sdk) | 157 cmd.append(dart_sdk) |
| 178 cmd.append("--entrypoints") | 158 cmd.append("--entrypoints") |
| 179 cmd.extend(entrypoints) | 159 cmd.extend(entrypoints) |
| 180 cmd.append("--package-root") | 160 cmd.append("--package-root") |
| 181 cmd.append(package_root) | 161 cmd.append(package_root) |
| 182 cmd.append("--no-hints") | 162 cmd.append("--no-hints") |
| 183 try: | 163 try: |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 f.write(entrypoint + '\n') | 303 f.write(entrypoint + '\n') |
| 324 | 304 |
| 325 # Write stamp file. | 305 # Write stamp file. |
| 326 with open(args.stamp_file, 'w'): | 306 with open(args.stamp_file, 'w'): |
| 327 pass | 307 pass |
| 328 | 308 |
| 329 return 0 | 309 return 0 |
| 330 | 310 |
| 331 if __name__ == '__main__': | 311 if __name__ == '__main__': |
| 332 sys.exit(main()) | 312 sys.exit(main()) |
| OLD | NEW |