Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: sky/tools/missing_from_gn

Issue 679783002: Add a script for finding files missing from gn (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tools/missing_from_gn
diff --git a/sky/tools/missing_from_gn b/sky/tools/missing_from_gn
new file mode 100755
index 0000000000000000000000000000000000000000..262e20b08528688b26b2e216f2fed2c12bd69638
--- /dev/null
+++ b/sky/tools/missing_from_gn
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import subprocess
+import os
+import argparse
+import logging
+
+ROOT_DIR = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir,
+ os.pardir))
+
+def dependencies():
+ args = [
+ 'gn',
+ 'desc',
+ os.path.join('out', 'Debug'),
+ '//sky/engine/public:blink',
+ 'deps', '--all'
+ ]
+ targets = subprocess.check_output(args).splitlines()
+ return map(str.strip, targets)
+
+
+def sources(target):
+ print target
+ args = [
+ 'gn',
+ 'desc',
+ os.path.join('out', 'Debug'),
+ target,
+ 'sources'
+ ]
+ sources = subprocess.check_output(args).splitlines()
+ return map(lambda s: s[2:], map(str.strip, sources))
+
+
+def find_on_disk(path):
+ # FIXME: Use os.walk and do fancier ignoring.
+ find_output = subprocess.check_output(['find', path, '-type', 'f'])
+ return map(str.strip, find_output.splitlines())
+
+
+def main():
+ logging.basicConfig()
+
+ os.chdir(ROOT_DIR)
+ if os.path.exists('in_gn.txt'):
+ logging.info('Using cached GN list: %s' % os.path.abspath('in_gn.txt'))
+ in_gn = set(map(str.strip, open('in_gn.txt').readlines()))
+ else:
+ logging.info('No gn cache found, rebuilding: %s' % os.abspath('in_gn.txt'))
+ targets = filter(lambda s: '//sky' in s, dependencies())
+ in_gn = set(sum(map(sources, targets), []))
+ open('in_gn.txt', 'w+').write('\n'.join(in_gn))
+
+ on_disk = set(find_on_disk('sky/engine'))
+ # Ignore web/tests and bindings/tests
+ on_disk = set(filter(lambda p: '/tests/' not in p, on_disk))
+
+ missing_from_gn = sorted(on_disk - in_gn)
+
+ IGNORED_EXTENSIONS = [
+ '.py', # Probably some to remove, probably some to teach gn about.
+ # Python files not being known to gn can cause flaky builds too!
+ '.pyc',
+ '.gypi',
+ '.gn',
+ '.gni',
+ '.h', # Ignore headers for the moment.
+ ]
+ for ext in IGNORED_EXTENSIONS:
+ missing_from_gn = filter(lambda p: not p.endswith(ext), missing_from_gn)
+
+ # All upper-case files like README, DEPS, etc. are fine.
+ missing_from_gn = filter(lambda p: not os.path.basename(p).isupper(),
+ missing_from_gn)
+
+ print '\n'.join(missing_from_gn)
+
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698