Index: tools/gn/bin/gyp_flag_compare.py
|
diff --git a/tools/gn/bin/gyp_flag_compare.py b/tools/gn/bin/gyp_flag_compare.py
|
index f2ce3c873a688c0f7b94c9e74cbb7c33cafcffa8..f53240fa05dfbd878773b53d9735d8d6190dcb7f 100755
|
--- a/tools/gn/bin/gyp_flag_compare.py
|
+++ b/tools/gn/bin/gyp_flag_compare.py
|
@@ -17,6 +17,8 @@ def FindAndRemoveArgWithValue(command_line, argname):
|
|
Modifies |command_line| in place.
|
"""
|
+ if argname not in command_line:
|
+ return ''
|
location = command_line.index(argname)
|
value = command_line[location + 1]
|
command_line[location:location + 2] = []
|
@@ -58,7 +60,12 @@ def GetFlags(lines):
|
include_dirs = [x for x in command_line if x.startswith('-I')]
|
dash_f = [x for x in command_line if x.startswith('-f')]
|
warnings = [x for x in command_line if x.startswith('-W')]
|
- cc_file = [x for x in command_line if x.endswith('.cc') or x.endswith('.c')]
|
+ cc_file = [x for x in command_line if x.endswith('.cc') or
|
+ x.endswith('.c') or
|
+ x.endswith('.cpp')]
|
+ if len(cc_file) != 1:
|
+ print 'Skipping %s' % command_line
|
+ continue
|
assert len(cc_file) == 1
|
others = [x for x in command_line if x not in defines and \
|
x not in include_dirs and \
|
@@ -78,21 +85,20 @@ def GetFlags(lines):
|
|
|
def CompareLists(gyp, gn, name, dont_care=None):
|
- """Output any differences between to lists, ignoring anything in
|
- |dont_care|."""
|
+ """Return a report of any differences between two lists, ignoring anything
|
+ in |dont_care|."""
|
if not dont_care:
|
dont_care = []
|
+ output = ''
|
if gyp[name] != gn[name]:
|
- print ' %s differ:' % name
|
+ output += ' %s differ:\n' % name
|
gyp_set = set(gyp[name]) - set(dont_care)
|
gn_set = set(gn[name]) - set(dont_care)
|
- print ' In gyp, but not in GN:\n %s' % '\n '.join(
|
- sorted(gyp_set - gn_set))
|
- print ' In GN, but not in gyp:\n %s' % '\n '.join(
|
- sorted(gn_set - gyp_set))
|
- print
|
- return True
|
- return False
|
+ output += ' In gyp, but not in GN:\n %s' % '\n '.join(
|
+ sorted(gyp_set - gn_set)) + '\n'
|
+ output += ' In GN, but not in gyp:\n %s' % '\n '.join(
|
+ sorted(gn_set - gyp_set)) + '\n\n'
|
+ return output
|
|
|
def main():
|
@@ -107,32 +113,38 @@ def main():
|
all_gn_flags = GetFlags(gn)
|
gyp_files = set(all_gyp_flags.keys())
|
gn_files = set(all_gn_flags.keys())
|
- differences = False
|
- if gyp_files != gn_files:
|
+ different_source_list = gyp_files != gn_files
|
+ if different_source_list:
|
print 'Different set of sources files:'
|
print ' In gyp, not in GN:\n %s' % '\n '.join(
|
sorted(gyp_files - gn_files))
|
print ' In GN, not in gyp:\n %s' % '\n '.join(
|
sorted(gn_files - gyp_files))
|
print '\nNote that flags will only be compared for files in both sets.\n'
|
- differences |= True
|
file_list = gyp_files & gn_files
|
+ files_with_given_differences = {}
|
for filename in sorted(file_list):
|
gyp_flags = all_gyp_flags[filename]
|
gn_flags = all_gn_flags[filename]
|
- print filename
|
- differences |= CompareLists(gyp_flags, gn_flags, 'dash_f')
|
- differences |= CompareLists(gyp_flags, gn_flags, 'defines', dont_care=[
|
+ differences = CompareLists(gyp_flags, gn_flags, 'dash_f')
|
+ differences += CompareLists(gyp_flags, gn_flags, 'defines', dont_care=[
|
'-DENABLE_PRE_SYNC_BACKUP',
|
'-DENABLE_WEBRTC=1',
|
'-DUSE_LIBJPEG_TURBO=1',
|
'-DUSE_PANGO=1',
|
'-DUSE_SYMBOLIZE',
|
])
|
- differences |= CompareLists(gyp_flags, gn_flags, 'include_dirs')
|
- differences |= CompareLists(gyp_flags, gn_flags, 'warnings')
|
- differences |= CompareLists(gyp_flags, gn_flags, 'other')
|
- return 1 if differences else 0
|
+ differences += CompareLists(gyp_flags, gn_flags, 'include_dirs')
|
+ differences += CompareLists(gyp_flags, gn_flags, 'warnings')
|
+ differences += CompareLists(gyp_flags, gn_flags, 'other')
|
+ if differences:
|
+ files_with_given_differences.setdefault(differences, []).append(filename)
|
+
|
+ for diff, files in files_with_given_differences.iteritems():
|
+ print '\n'.join(sorted(files))
|
+ print diff
|
+
|
+ return 1 if files_with_given_differences or different_source_list else 0
|
|
|
if __name__ == '__main__':
|
|