2015-06-26 10:35:12 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Script to print potentially missing source dependencies based on the actual
|
|
|
|
.h and .cc files in the source tree and which files are included in the gyp
|
|
|
|
and gn files. The latter inclusion is overapproximated.
|
2015-06-26 14:24:42 +00:00
|
|
|
|
2016-09-19 11:40:17 +00:00
|
|
|
TODO(machenbach): If two source files with the same name exist, but only one
|
|
|
|
is referenced from a gyp/gn file, we won't necessarily detect it.
|
2015-06-26 10:35:12 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import itertools
|
|
|
|
import re
|
|
|
|
import os
|
2016-09-20 07:27:52 +00:00
|
|
|
import subprocess
|
2016-09-19 10:58:59 +00:00
|
|
|
import sys
|
2015-06-26 10:35:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
V8_BASE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
|
|
|
|
|
|
|
GYP_FILES = [
|
|
|
|
os.path.join(V8_BASE, 'src', 'd8.gyp'),
|
2016-04-25 12:19:32 +00:00
|
|
|
os.path.join(V8_BASE, 'src', 'v8.gyp'),
|
2016-09-19 10:58:59 +00:00
|
|
|
os.path.join(V8_BASE, 'src', 'inspector', 'inspector.gypi'),
|
2015-06-26 10:35:12 +00:00
|
|
|
os.path.join(V8_BASE, 'src', 'third_party', 'vtune', 'v8vtune.gyp'),
|
2016-09-20 07:27:52 +00:00
|
|
|
os.path.join(V8_BASE, 'samples', 'samples.gyp'),
|
2015-06-26 10:35:12 +00:00
|
|
|
os.path.join(V8_BASE, 'test', 'cctest', 'cctest.gyp'),
|
2016-09-19 10:58:59 +00:00
|
|
|
os.path.join(V8_BASE, 'test', 'fuzzer', 'fuzzer.gyp'),
|
2015-06-26 10:35:12 +00:00
|
|
|
os.path.join(V8_BASE, 'test', 'unittests', 'unittests.gyp'),
|
2016-09-30 15:52:31 +00:00
|
|
|
os.path.join(V8_BASE, 'test', 'inspector', 'inspector.gyp'),
|
2016-09-20 07:27:52 +00:00
|
|
|
os.path.join(V8_BASE, 'testing', 'gmock.gyp'),
|
|
|
|
os.path.join(V8_BASE, 'testing', 'gtest.gyp'),
|
2015-06-26 10:35:12 +00:00
|
|
|
os.path.join(V8_BASE, 'tools', 'parser-shell.gyp'),
|
|
|
|
]
|
|
|
|
|
2016-09-20 07:27:52 +00:00
|
|
|
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'),
|
2016-09-30 15:52:31 +00:00
|
|
|
os.path.join('test', 'inspector'),
|
2016-09-20 07:27:52 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
GYP_UNSUPPORTED_FEATURES = [
|
|
|
|
'gcmole',
|
|
|
|
]
|
|
|
|
|
2016-09-15 13:14:33 +00:00
|
|
|
GN_FILES = [
|
|
|
|
os.path.join(V8_BASE, 'BUILD.gn'),
|
2016-09-20 07:27:52 +00:00
|
|
|
os.path.join(V8_BASE, 'build', 'secondary', 'testing', 'gmock', 'BUILD.gn'),
|
|
|
|
os.path.join(V8_BASE, 'build', 'secondary', 'testing', 'gtest', 'BUILD.gn'),
|
2016-09-15 13:14:33 +00:00
|
|
|
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'),
|
2016-09-30 15:52:31 +00:00
|
|
|
os.path.join(V8_BASE, 'test', 'inspector', 'BUILD.gn'),
|
2016-09-15 13:14:33 +00:00
|
|
|
os.path.join(V8_BASE, 'tools', 'BUILD.gn'),
|
|
|
|
]
|
|
|
|
|
|
|
|
GN_UNSUPPORTED_FEATURES = [
|
|
|
|
'aix',
|
|
|
|
'cygwin',
|
|
|
|
'freebsd',
|
2016-09-20 07:27:52 +00:00
|
|
|
'gcmole',
|
2016-09-15 13:14:33 +00:00
|
|
|
'openbsd',
|
|
|
|
'ppc',
|
|
|
|
'qnx',
|
|
|
|
'solaris',
|
|
|
|
'vtune',
|
|
|
|
'x87',
|
|
|
|
]
|
|
|
|
|
2016-09-19 10:58:59 +00:00
|
|
|
ALL_GN_PREFIXES = [
|
|
|
|
'..',
|
|
|
|
os.path.join('src', 'inspector'),
|
|
|
|
'src',
|
2016-09-20 07:27:52 +00:00
|
|
|
'testing',
|
2016-09-19 10:58:59 +00:00
|
|
|
os.path.join('test', 'cctest'),
|
|
|
|
os.path.join('test', 'unittests'),
|
2016-09-30 15:52:31 +00:00
|
|
|
os.path.join('test', 'inspector'),
|
2016-09-19 10:58:59 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
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)
|
2016-09-15 13:14:33 +00:00
|
|
|
return path
|
2015-06-26 10:35:12 +00:00
|
|
|
|
|
|
|
|
2016-09-20 07:27:52 +00:00
|
|
|
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)
|
2015-06-26 10:35:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def iflatten(obj):
|
|
|
|
if isinstance(obj, dict):
|
|
|
|
for value in obj.values():
|
|
|
|
for i in iflatten(value):
|
|
|
|
yield i
|
|
|
|
elif isinstance(obj, list):
|
|
|
|
for value in obj:
|
|
|
|
for i in iflatten(value):
|
|
|
|
yield i
|
|
|
|
elif isinstance(obj, basestring):
|
2016-09-19 10:58:59 +00:00
|
|
|
yield path_no_prefix(os.path.join(*pathsplit(obj)), ALL_GYP_PREFIXES)
|
2015-06-26 10:35:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def iflatten_gyp_file(gyp_file):
|
|
|
|
"""Overaproximates all values in the gyp file.
|
|
|
|
|
|
|
|
Iterates over all string values recursively. Removes '../' path prefixes.
|
|
|
|
"""
|
|
|
|
with open(gyp_file) as f:
|
|
|
|
return iflatten(eval(f.read()))
|
|
|
|
|
|
|
|
|
|
|
|
def iflatten_gn_file(gn_file):
|
|
|
|
"""Overaproximates all values in the gn file.
|
|
|
|
|
|
|
|
Iterates over all double quoted strings.
|
|
|
|
"""
|
|
|
|
with open(gn_file) as f:
|
|
|
|
for line in f.read().splitlines():
|
|
|
|
match = re.match(r'.*"([^"]*)".*', line)
|
|
|
|
if match:
|
2016-09-19 10:58:59 +00:00
|
|
|
yield path_no_prefix(
|
|
|
|
os.path.join(*pathsplit(match.group(1))), ALL_GN_PREFIXES)
|
2015-06-26 10:35:12 +00:00
|
|
|
|
|
|
|
|
2016-09-20 07:27:52 +00:00
|
|
|
def icheck_values(values, prefixes):
|
|
|
|
for source_file in isources(prefixes):
|
2015-06-26 10:35:12 +00:00
|
|
|
if source_file not in values:
|
|
|
|
yield source_file
|
|
|
|
|
|
|
|
|
2016-09-19 10:58:59 +00:00
|
|
|
def missing_gyp_files():
|
|
|
|
gyp_values = set(itertools.chain(
|
|
|
|
*[iflatten_gyp_file(gyp_file) for gyp_file in GYP_FILES]
|
|
|
|
))
|
2016-09-20 07:27:52 +00:00
|
|
|
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)
|
2016-09-19 10:58:59 +00:00
|
|
|
|
2015-06-26 10:35:12 +00:00
|
|
|
|
2016-09-19 10:58:59 +00:00
|
|
|
def missing_gn_files():
|
|
|
|
gn_values = set(itertools.chain(
|
|
|
|
*[iflatten_gn_file(gn_file) for gn_file in GN_FILES]
|
|
|
|
))
|
2015-06-26 10:35:12 +00:00
|
|
|
|
2016-09-20 07:27:52 +00:00
|
|
|
gn_files = sorted(icheck_values(gn_values, ALL_GN_PREFIXES))
|
2016-09-19 10:58:59 +00:00
|
|
|
return filter(
|
|
|
|
lambda x: not any(i in x for i in GN_UNSUPPORTED_FEATURES), gn_files)
|
2015-06-26 10:35:12 +00:00
|
|
|
|
2016-09-19 10:58:59 +00:00
|
|
|
|
|
|
|
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():
|
2016-09-15 13:14:33 +00:00
|
|
|
print i
|
2016-09-19 10:58:59 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
if '__main__' == __name__:
|
|
|
|
sys.exit(main())
|