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

Unified Diff: tools/verify_source_deps.py

Issue 2346103002: Fix BUILD.gn files and add presubmit step (Closed)
Patch Set: windows Created 4 years, 3 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 | « test/unittests/unittests.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/verify_source_deps.py
diff --git a/tools/verify_source_deps.py b/tools/verify_source_deps.py
index 7c147c06e038a317b0c476e7d131f2e9eed37db3..b5fa7a846935e54d1e942e1c48c055b7b0501324 100755
--- a/tools/verify_source_deps.py
+++ b/tools/verify_source_deps.py
@@ -16,18 +16,21 @@ tool won't be accurate for other sources in other directories (e.g. cctest).
import itertools
import re
import os
+import sys
V8_BASE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
V8_SRC_BASE = os.path.join(V8_BASE, 'src')
+V8_TEST_BASE = os.path.join(V8_BASE, 'test')
V8_INCLUDE_BASE = os.path.join(V8_BASE, 'include')
GYP_FILES = [
os.path.join(V8_BASE, 'src', 'd8.gyp'),
os.path.join(V8_BASE, 'src', 'v8.gyp'),
- os.path.join(V8_BASE, 'src', 'inspector', 'inspector.gyp'),
+ os.path.join(V8_BASE, 'src', 'inspector', 'inspector.gypi'),
os.path.join(V8_BASE, 'src', 'third_party', 'vtune', 'v8vtune.gyp'),
os.path.join(V8_BASE, 'test', 'cctest', 'cctest.gyp'),
+ os.path.join(V8_BASE, 'test', 'fuzzer', 'fuzzer.gyp'),
os.path.join(V8_BASE, 'test', 'unittests', 'unittests.gyp'),
os.path.join(V8_BASE, 'tools', 'parser-shell.gyp'),
]
@@ -48,25 +51,46 @@ GN_UNSUPPORTED_FEATURES = [
'ppc',
'qnx',
'solaris',
- 'valgrind',
'vtune',
'x87',
]
+ALL_GN_PREFIXES = [
+ '..',
+ os.path.join('src', 'inspector'),
+ 'src',
+ os.path.join('test', 'cctest'),
+ os.path.join('test', 'unittests'),
+]
+
+ALL_GYP_PREFIXES = [
+ '..',
+ 'common',
+ os.path.join('src', 'third_party', 'vtune'),
+ 'src',
+ os.path.join('test', 'cctest'),
+ os.path.join('test', 'common'),
+ os.path.join('test', 'fuzzer'),
+ os.path.join('test', 'unittests'),
+]
-def path_no_prefix(path):
- for prefix in ['../', 'src/inspector/', 'src/']:
- if path.startswith(prefix):
- return path_no_prefix(path[len(prefix):])
+def pathsplit(path):
+ return re.split('[/\\\\]', path)
+
+def path_no_prefix(path, prefixes):
+ for prefix in prefixes:
+ if path.startswith(prefix + os.sep):
+ return path_no_prefix(path[len(prefix) + 1:], prefixes)
return path
-def isources(directory):
+def isources(directory, prefixes):
for root, dirs, files in os.walk(directory):
for f in files:
if not (f.endswith('.h') or f.endswith('.cc')):
continue
- yield path_no_prefix(os.path.relpath(os.path.join(root, f), V8_BASE))
+ yield path_no_prefix(
+ os.path.relpath(os.path.join(root, f), V8_BASE), prefixes)
def iflatten(obj):
@@ -79,7 +103,7 @@ def iflatten(obj):
for i in iflatten(value):
yield i
elif isinstance(obj, basestring):
- yield path_no_prefix(obj)
+ yield path_no_prefix(os.path.join(*pathsplit(obj)), ALL_GYP_PREFIXES)
def iflatten_gyp_file(gyp_file):
@@ -100,30 +124,46 @@ def iflatten_gn_file(gn_file):
for line in f.read().splitlines():
match = re.match(r'.*"([^"]*)".*', line)
if match:
- yield path_no_prefix(match.group(1))
+ yield path_no_prefix(
+ os.path.join(*pathsplit(match.group(1))), ALL_GN_PREFIXES)
-def icheck_values(values, *source_dirs):
+def icheck_values(values, prefixes, *source_dirs):
for source_file in itertools.chain(
- *[isources(source_dir) for source_dir in source_dirs]
+ *[isources(source_dir, prefixes) for source_dir in source_dirs]
):
if source_file not in values:
yield source_file
-gyp_values = set(itertools.chain(
- *[iflatten_gyp_file(gyp_file) for gyp_file in GYP_FILES]
- ))
+def missing_gyp_files():
+ gyp_values = set(itertools.chain(
+ *[iflatten_gyp_file(gyp_file) for gyp_file in GYP_FILES]
+ ))
+ return sorted(icheck_values(
+ gyp_values, ALL_GYP_PREFIXES, V8_SRC_BASE, V8_INCLUDE_BASE, V8_TEST_BASE))
+
-print "----------- Files not in gyp: ------------"
-for i in sorted(icheck_values(gyp_values, V8_SRC_BASE, V8_INCLUDE_BASE)):
- print i
+def missing_gn_files():
+ gn_values = set(itertools.chain(
+ *[iflatten_gn_file(gn_file) for gn_file in GN_FILES]
+ ))
-gn_values = set(itertools.chain(
- *[iflatten_gn_file(gn_file) for gn_file in GN_FILES]
- ))
+ gn_files = sorted(icheck_values(
+ gn_values, ALL_GN_PREFIXES, V8_SRC_BASE, V8_INCLUDE_BASE, V8_TEST_BASE))
+ return filter(
+ lambda x: not any(i in x for i in GN_UNSUPPORTED_FEATURES), gn_files)
-print "\n----------- Files not in gn: -------------"
-for i in sorted(icheck_values(gn_values, V8_SRC_BASE, V8_INCLUDE_BASE)):
- if not any(f in i for f in GN_UNSUPPORTED_FEATURES):
+
+def main():
+ print "----------- Files not in gyp: ------------"
+ for i in missing_gyp_files():
+ print i
+
+ print "\n----------- Files not in gn: -------------"
+ for i in missing_gn_files():
print i
+ return 0
+
+if '__main__' == __name__:
+ sys.exit(main())
« no previous file with comments | « test/unittests/unittests.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698