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

Unified Diff: tools/verify_source_deps.py

Issue 2343423002: Use git ls-tree to collect source files instead of walking the fs (Closed)
Patch Set: updates 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 | « tools/oom_dump/oom_dump.cc ('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 941943bf17a44547b2ba969bb9606e27936267f4..e62ec8f306a41b0452b5fa2f0a99cff81dd5c346 100755
--- a/tools/verify_source_deps.py
+++ b/tools/verify_source_deps.py
@@ -15,27 +15,48 @@ is referenced from a gyp/gn file, we won't necessarily detect it.
import itertools
import re
import os
+import subprocess
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.gypi'),
os.path.join(V8_BASE, 'src', 'third_party', 'vtune', 'v8vtune.gyp'),
+ os.path.join(V8_BASE, 'samples', 'samples.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, 'testing', 'gmock.gyp'),
+ os.path.join(V8_BASE, 'testing', 'gtest.gyp'),
os.path.join(V8_BASE, 'tools', 'parser-shell.gyp'),
]
+ALL_GYP_PREFIXES = [
+ '..',
+ 'common',
+ os.path.join('src', 'third_party', 'vtune'),
+ 'src',
+ 'samples',
+ 'testing',
+ 'tools',
+ os.path.join('test', 'cctest'),
+ os.path.join('test', 'common'),
+ os.path.join('test', 'fuzzer'),
+ os.path.join('test', 'unittests'),
+]
+
+GYP_UNSUPPORTED_FEATURES = [
+ 'gcmole',
+]
+
GN_FILES = [
os.path.join(V8_BASE, 'BUILD.gn'),
+ os.path.join(V8_BASE, 'build', 'secondary', 'testing', 'gmock', 'BUILD.gn'),
+ os.path.join(V8_BASE, 'build', 'secondary', 'testing', 'gtest', 'BUILD.gn'),
os.path.join(V8_BASE, 'src', 'inspector', 'BUILD.gn'),
os.path.join(V8_BASE, 'test', 'cctest', 'BUILD.gn'),
os.path.join(V8_BASE, 'test', 'unittests', 'BUILD.gn'),
@@ -46,6 +67,7 @@ GN_UNSUPPORTED_FEATURES = [
'aix',
'cygwin',
'freebsd',
+ 'gcmole',
'openbsd',
'ppc',
'qnx',
@@ -58,21 +80,11 @@ ALL_GN_PREFIXES = [
'..',
os.path.join('src', 'inspector'),
'src',
+ 'testing',
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 pathsplit(path):
return re.split('[/\\\\]', path)
@@ -83,13 +95,12 @@ def path_no_prefix(path, prefixes):
return path
-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), prefixes)
+def isources(prefixes):
+ cmd = ['git', 'ls-tree', '-r', 'HEAD', '--full-name', '--name-only']
+ for f in subprocess.check_output(cmd, universal_newlines=True).split('\n'):
+ if not (f.endswith('.h') or f.endswith('.cc')):
+ continue
+ yield path_no_prefix(os.path.join(*pathsplit(f)), prefixes)
def iflatten(obj):
@@ -127,10 +138,8 @@ def iflatten_gn_file(gn_file):
os.path.join(*pathsplit(match.group(1))), ALL_GN_PREFIXES)
-def icheck_values(values, prefixes, *source_dirs):
- for source_file in itertools.chain(
- *[isources(source_dir, prefixes) for source_dir in source_dirs]
- ):
+def icheck_values(values, prefixes):
+ for source_file in isources(prefixes):
if source_file not in values:
yield source_file
@@ -139,8 +148,9 @@ 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))
+ gyp_files = sorted(icheck_values(gyp_values, ALL_GYP_PREFIXES))
+ return filter(
+ lambda x: not any(i in x for i in GYP_UNSUPPORTED_FEATURES), gyp_files)
def missing_gn_files():
@@ -148,8 +158,7 @@ def missing_gn_files():
*[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))
+ gn_files = sorted(icheck_values(gn_values, ALL_GN_PREFIXES))
return filter(
lambda x: not any(i in x for i in GN_UNSUPPORTED_FEATURES), gn_files)
« no previous file with comments | « tools/oom_dump/oom_dump.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698