OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import subprocess |
| 7 import os |
| 8 import argparse |
| 9 import logging |
| 10 |
| 11 ROOT_DIR = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, |
| 12 os.pardir)) |
| 13 |
| 14 def dependencies(): |
| 15 args = [ |
| 16 'gn', |
| 17 'desc', |
| 18 os.path.join('out', 'Debug'), |
| 19 '//sky/engine/public:blink', |
| 20 'deps', '--all' |
| 21 ] |
| 22 targets = subprocess.check_output(args).splitlines() |
| 23 return map(str.strip, targets) |
| 24 |
| 25 |
| 26 def sources(target): |
| 27 print target |
| 28 args = [ |
| 29 'gn', |
| 30 'desc', |
| 31 os.path.join('out', 'Debug'), |
| 32 target, |
| 33 'sources' |
| 34 ] |
| 35 sources = subprocess.check_output(args).splitlines() |
| 36 return map(lambda s: s[2:], map(str.strip, sources)) |
| 37 |
| 38 |
| 39 def find_on_disk(path): |
| 40 # FIXME: Use os.walk and do fancier ignoring. |
| 41 find_output = subprocess.check_output(['find', path, '-type', 'f']) |
| 42 return map(str.strip, find_output.splitlines()) |
| 43 |
| 44 |
| 45 def main(): |
| 46 logging.basicConfig() |
| 47 |
| 48 os.chdir(ROOT_DIR) |
| 49 if os.path.exists('in_gn.txt'): |
| 50 logging.info('Using cached GN list: %s' % os.path.abspath('in_gn.txt')) |
| 51 in_gn = set(map(str.strip, open('in_gn.txt').readlines())) |
| 52 else: |
| 53 logging.info('No gn cache found, rebuilding: %s' % os.abspath('in_gn.txt
')) |
| 54 targets = filter(lambda s: '//sky' in s, dependencies()) |
| 55 in_gn = set(sum(map(sources, targets), [])) |
| 56 open('in_gn.txt', 'w+').write('\n'.join(in_gn)) |
| 57 |
| 58 on_disk = set(find_on_disk('sky/engine')) |
| 59 # Ignore web/tests and bindings/tests |
| 60 on_disk = set(filter(lambda p: '/tests/' not in p, on_disk)) |
| 61 |
| 62 missing_from_gn = sorted(on_disk - in_gn) |
| 63 |
| 64 IGNORED_EXTENSIONS = [ |
| 65 '.py', # Probably some to remove, probably some to teach gn about. |
| 66 # Python files not being known to gn can cause flaky builds too! |
| 67 '.pyc', |
| 68 '.gypi', |
| 69 '.gn', |
| 70 '.gni', |
| 71 '.h', # Ignore headers for the moment. |
| 72 ] |
| 73 for ext in IGNORED_EXTENSIONS: |
| 74 missing_from_gn = filter(lambda p: not p.endswith(ext), missing_from_gn) |
| 75 |
| 76 # All upper-case files like README, DEPS, etc. are fine. |
| 77 missing_from_gn = filter(lambda p: not os.path.basename(p).isupper(), |
| 78 missing_from_gn) |
| 79 |
| 80 print '\n'.join(missing_from_gn) |
| 81 |
| 82 |
| 83 if __name__ == '__main__': |
| 84 main() |
OLD | NEW |