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('is_bindings_types', | |
25 metavar='is_bindings_types', | |
26 help='Whether or not the source directory is generating' | |
27 'for mojo.bindings.types or not.') | |
24 args = parser.parse_args() | 28 args = parser.parse_args() |
25 # Directory to start searching for .mojom files. | 29 # Directory to start searching for .mojom files. |
26 source_directory = args.source_directory | 30 source_directory = args.source_directory |
31 | |
27 # Prefix to chop off output. | 32 # Prefix to chop off output. |
28 root_prefix = os.path.abspath(args.relative_directory_root) | 33 root_prefix = os.path.abspath(args.relative_directory_root) |
29 for dirname, _, filenames in os.walk(source_directory): | 34 for dirname, _, filenames in os.walk(source_directory): |
30 # filter for .mojom.dart files. | 35 # filter for .mojom.dart files. |
31 filenames = [f for f in filenames if f.endswith('.mojom')] | 36 filenames = [f for f in filenames if f.endswith('.mojom')] |
32 for f in filenames: | 37 for f in filenames: |
33 # Ignore tests. | 38 # Ignore tests. |
34 if dirname.endswith('tests'): | 39 if dirname.endswith('tests'): |
35 continue; | 40 continue; |
41 | |
42 # A hacky solution that splits the interface_control_messages.mojom file | |
zra
2016/01/15 21:01:34
What would be a non-hacky solution?
It sounds lik
alexfandrianto
2016/01/20 00:08:29
The weird thing about the files in //mojo/public/i
| |
43 # away from the other *.mojom files in the bindings directory. These | |
44 # other mojom files have a different module, so they belong in a different | |
45 # location. | |
46 if dirname.endswith('bindings'): | |
47 if args.is_bindings_types: | |
48 if f.endswith('interface_control_messages.mojom'): | |
49 continue | |
50 else: | |
51 if not f.endswith('interface_control_messages.mojom'): | |
52 continue | |
53 | |
36 path = os.path.abspath(os.path.join(dirname, f)) | 54 path = os.path.abspath(os.path.join(dirname, f)) |
37 path = os.path.relpath(path, root_prefix) | 55 path = os.path.relpath(path, root_prefix) |
38 # Append .dart. | 56 # Append .dart. |
39 path += '.dart' | 57 path += '.dart' |
40 print(path) | 58 print(path) |
41 | 59 |
42 if __name__ == '__main__': | 60 if __name__ == '__main__': |
43 sys.exit(main(sys.argv[1:])) | 61 sys.exit(main(sys.argv[1:])) |
44 | |
OLD | NEW |