OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 """Prints all non-system dependencies for the given module. | 6 """Prints all non-system dependencies for the given module. |
7 | 7 |
8 The primary use-case for this script is to genererate the list of python modules | 8 The primary use-case for this script is to genererate the list of python modules |
9 required for .isolate files. | 9 required for .isolate files. |
10 """ | 10 """ |
(...skipping 20 matching lines...) Expand all Loading... |
31 if m and hasattr(m, '__file__')) | 31 if m and hasattr(m, '__file__')) |
32 | 32 |
33 src_paths = set() | 33 src_paths = set() |
34 for path in module_paths: | 34 for path in module_paths: |
35 if path == __file__: | 35 if path == __file__: |
36 continue | 36 continue |
37 path = os.path.abspath(path) | 37 path = os.path.abspath(path) |
38 if not path.startswith(_SRC_ROOT): | 38 if not path.startswith(_SRC_ROOT): |
39 continue | 39 continue |
40 | 40 |
41 if path.endswith('.pyc'): | 41 if (path.endswith('.pyc') |
| 42 or (path.endswith('c') and not os.path.splitext(path)[1])): |
42 path = path[:-1] | 43 path = path[:-1] |
43 src_paths.add(path) | 44 src_paths.add(path) |
44 | 45 |
45 return src_paths | 46 return src_paths |
46 | 47 |
47 | 48 |
48 def _NormalizeCommandLine(options): | 49 def _NormalizeCommandLine(options): |
49 """Returns a string that when run from SRC_ROOT replicates the command.""" | 50 """Returns a string that when run from SRC_ROOT replicates the command.""" |
50 args = ['build/print_python_deps.py'] | 51 args = ['build/print_python_deps.py'] |
51 root = os.path.relpath(options.root, _SRC_ROOT) | 52 root = os.path.relpath(options.root, _SRC_ROOT) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 out = open(options.output, 'w') if options.output else sys.stdout | 98 out = open(options.output, 'w') if options.output else sys.stdout |
98 with out: | 99 with out: |
99 out.write('# Generated by running:\n') | 100 out.write('# Generated by running:\n') |
100 out.write('# %s\n' % normalized_cmdline) | 101 out.write('# %s\n' % normalized_cmdline) |
101 for path in sorted(paths): | 102 for path in sorted(paths): |
102 out.write(path + '\n') | 103 out.write(path + '\n') |
103 | 104 |
104 | 105 |
105 if __name__ == '__main__': | 106 if __name__ == '__main__': |
106 sys.exit(main()) | 107 sys.exit(main()) |
OLD | NEW |