OLD | NEW |
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 # This script scans a directory tree for any .mojom files and outputs a list of | 6 # This script scans a directory tree for any .mojom files and outputs a list of |
7 # .mojom.dart files. | 7 # .mojom.dart files. |
8 | 8 |
9 import argparse | 9 import argparse |
10 import os | 10 import os |
11 import sys | 11 import sys |
12 | 12 |
13 def main(args): | 13 def main(args): |
14 parser = argparse.ArgumentParser( | 14 parser = argparse.ArgumentParser( |
15 description='Prints list of generated dart binding source files.') | 15 description='Prints list of generated dart binding source files.') |
16 parser.add_argument('source_directory', | 16 parser.add_argument('source_directory', |
17 metavar='source_directory', | 17 metavar='source_directory', |
18 help='Path to source directory tree containing .mojom' | 18 help='Path to source directory tree containing .mojom' |
19 ' files') | 19 ' files') |
20 parser.add_argument('relative_directory_root', | 20 parser.add_argument('relative_directory_root', |
21 metavar='relative_directory_root', | 21 metavar='relative_directory_root', |
22 help='Path to directory which all outputted paths will' | 22 help='Path to directory which all outputted paths will' |
23 'be relative to.') | 23 'be relative to.') |
| 24 parser.add_argument('--bindings-types', |
| 25 dest='is_bindings_types', |
| 26 action="store_true", |
| 27 help='Whether or not the source directory is generating' |
| 28 'for mojo.bindings.types or not.') |
24 args = parser.parse_args() | 29 args = parser.parse_args() |
25 # Directory to start searching for .mojom files. | 30 # Directory to start searching for .mojom files. |
26 source_directory = args.source_directory | 31 source_directory = args.source_directory |
| 32 |
27 # Prefix to chop off output. | 33 # Prefix to chop off output. |
28 root_prefix = os.path.abspath(args.relative_directory_root) | 34 root_prefix = os.path.abspath(args.relative_directory_root) |
29 for dirname, _, filenames in os.walk(source_directory): | 35 for dirname, _, filenames in os.walk(source_directory): |
30 # filter for .mojom.dart files. | 36 # filter for .mojom.dart files. |
31 filenames = [f for f in filenames if f.endswith('.mojom')] | 37 filenames = [f for f in filenames if f.endswith('.mojom')] |
32 for f in filenames: | 38 for f in filenames: |
33 # Ignore tests. | 39 # Ignore tests. |
34 if dirname.endswith('tests'): | 40 if dirname.endswith('tests'): |
35 continue; | 41 continue; |
| 42 |
| 43 # A hacky solution that splits the interface_control_messages.mojom file |
| 44 # away from the other *.mojom files in the bindings directory. These |
| 45 # other mojom files have a different module, so they belong in a different |
| 46 # location. |
| 47 if dirname.endswith('bindings'): |
| 48 if args.is_bindings_types: |
| 49 if f.endswith('interface_control_messages.mojom'): |
| 50 continue |
| 51 else: |
| 52 if not f.endswith('interface_control_messages.mojom'): |
| 53 continue |
| 54 |
36 path = os.path.abspath(os.path.join(dirname, f)) | 55 path = os.path.abspath(os.path.join(dirname, f)) |
37 path = os.path.relpath(path, root_prefix) | 56 path = os.path.relpath(path, root_prefix) |
38 # Append .dart. | 57 # Append .dart. |
39 path += '.dart' | 58 path += '.dart' |
40 print(path) | 59 print(path) |
41 | 60 |
42 if __name__ == '__main__': | 61 if __name__ == '__main__': |
43 sys.exit(main(sys.argv[1:])) | 62 sys.exit(main(sys.argv[1:])) |
44 | |
OLD | NEW |