| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import subprocess | 6 import subprocess |
| 7 import os | 7 import os |
| 8 import argparse | 8 import argparse |
| 9 import logging | 9 import logging |
| 10 | 10 |
| 11 ROOT_DIR = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, | 11 ROOT_DIR = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, |
| 12 os.pardir)) | 12 os.pardir)) |
| 13 | 13 |
| 14 # Where to cache GN results (they're expensive to compute). | 14 # Where to cache GN results (they're expensive to compute). |
| 15 GN_CACHE_PATH = os.path.abspath(os.path.join(ROOT_DIR, 'in_gn.txt')) | 15 GN_CACHE_PATH = os.path.abspath(os.path.join(ROOT_DIR, 'in_gn.txt')) |
| 16 | 16 |
| 17 | 17 |
| 18 def stripped_lines_from_command(cmd, cwd=None): | 18 def stripped_lines_from_command(cmd, cwd=None): |
| 19 lines = subprocess.check_output(cmd, cwd=cwd).splitlines() | 19 lines = subprocess.check_output(cmd, cwd=cwd).splitlines() |
| 20 return map(str.strip, lines) | 20 return map(str.strip, lines) |
| 21 | 21 |
| 22 | 22 |
| 23 def gn_desc(*args): | 23 def gn_desc(*args): |
| 24 # GN doesn't understand absolute paths yet, so use a relative BUILD_DIR | 24 # GN doesn't understand absolute paths yet, so use a relative BUILD_DIR |
| 25 # and pass ROOT_DIR as the CWD. | 25 # and pass ROOT_DIR as the CWD. |
| 26 cmd = [ | 26 # Hard-coding Debug for now: |
| 27 'gn', 'desc', | 27 BUILD_DIR = '//out/Debug' # // means repository root-relative. |
| 28 # Hard-coding Debug for now: | 28 cmd = ['gn', 'desc', BUILD_DIR] + list(args) |
| 29 os.path.join('out', 'Debug'), | |
| 30 ] + list(args) | |
| 31 return stripped_lines_from_command(cmd, cwd=ROOT_DIR) | 29 return stripped_lines_from_command(cmd, cwd=ROOT_DIR) |
| 32 | 30 |
| 33 | 31 |
| 34 def targets_under(target): | 32 def targets_under(target): |
| 35 targets = gn_desc(target, 'deps', '--all') | 33 targets = gn_desc(target, 'deps', '--all') |
| 36 return filter(lambda s: s.startswith(target), targets) | 34 return filter(lambda s: s.startswith(target), targets) |
| 37 | 35 |
| 38 | 36 |
| 39 def used_files(target): | 37 def used_files(target): |
| 40 logging.info(target) | 38 logging.info(target) |
| 41 sources = map(lambda s: s[2:], gn_desc(target, 'sources')) | 39 sources = map(lambda s: s[2:], gn_desc(target, 'sources')) |
| 42 inputs = map(lambda s: s[2:], gn_desc(target, 'inputs')) | 40 inputs = map(lambda s: s[2:], gn_desc(target, 'inputs')) |
| 43 return sources + inputs | 41 public = map(lambda s: s[2:], gn_desc(target, 'public')) |
| 42 script = map(lambda s: s[2:], gn_desc(target, 'script')) |
| 43 return sources + inputs + public + script |
| 44 | 44 |
| 45 | 45 |
| 46 def find_on_disk(path): | 46 def find_on_disk(path): |
| 47 # FIXME: Use os.walk and do fancier ignoring. | 47 # FIXME: Use os.walk and do fancier ignoring. |
| 48 return stripped_lines_from_command(['find', path, '-type', 'f']) | 48 return stripped_lines_from_command(['find', path, '-type', 'f']) |
| 49 | 49 |
| 50 | 50 |
| 51 def main(): | 51 def main(): |
| 52 logging.basicConfig(level=logging.INFO) | 52 logging.basicConfig(level=logging.INFO) |
| 53 | 53 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 79 | 79 |
| 80 # All upper-case files like README, DEPS, etc. are fine. | 80 # All upper-case files like README, DEPS, etc. are fine. |
| 81 missing_from_gn = filter(lambda p: not os.path.basename(p).isupper(), | 81 missing_from_gn = filter(lambda p: not os.path.basename(p).isupper(), |
| 82 missing_from_gn) | 82 missing_from_gn) |
| 83 | 83 |
| 84 print '\n'.join(missing_from_gn) | 84 print '\n'.join(missing_from_gn) |
| 85 | 85 |
| 86 | 86 |
| 87 if __name__ == '__main__': | 87 if __name__ == '__main__': |
| 88 main() | 88 main() |
| OLD | NEW |