Commit 0e597a71 authored by scottmg's avatar scottmg Committed by Commit bot

Group GN/gyp flag comparison output by file

Looks like this now: https://gist.github.com/sgraham/1996522958b09077fd92

(vs. very redundant for each file before)

R=awong@chromium.org
TBR=brettw@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/533413002

Cr-Commit-Position: refs/heads/master@{#293311}
parent aa52ced2
...@@ -17,6 +17,8 @@ def FindAndRemoveArgWithValue(command_line, argname): ...@@ -17,6 +17,8 @@ def FindAndRemoveArgWithValue(command_line, argname):
Modifies |command_line| in place. Modifies |command_line| in place.
""" """
if argname not in command_line:
return ''
location = command_line.index(argname) location = command_line.index(argname)
value = command_line[location + 1] value = command_line[location + 1]
command_line[location:location + 2] = [] command_line[location:location + 2] = []
...@@ -58,7 +60,12 @@ def GetFlags(lines): ...@@ -58,7 +60,12 @@ def GetFlags(lines):
include_dirs = [x for x in command_line if x.startswith('-I')] include_dirs = [x for x in command_line if x.startswith('-I')]
dash_f = [x for x in command_line if x.startswith('-f')] dash_f = [x for x in command_line if x.startswith('-f')]
warnings = [x for x in command_line if x.startswith('-W')] 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 assert len(cc_file) == 1
others = [x for x in command_line if x not in defines and \ others = [x for x in command_line if x not in defines and \
x not in include_dirs and \ x not in include_dirs and \
...@@ -78,21 +85,20 @@ def GetFlags(lines): ...@@ -78,21 +85,20 @@ def GetFlags(lines):
def CompareLists(gyp, gn, name, dont_care=None): def CompareLists(gyp, gn, name, dont_care=None):
"""Output any differences between to lists, ignoring anything in """Return a report of any differences between two lists, ignoring anything
|dont_care|.""" in |dont_care|."""
if not dont_care: if not dont_care:
dont_care = [] dont_care = []
output = ''
if gyp[name] != gn[name]: if gyp[name] != gn[name]:
print ' %s differ:' % name output += ' %s differ:\n' % name
gyp_set = set(gyp[name]) - set(dont_care) gyp_set = set(gyp[name]) - set(dont_care)
gn_set = set(gn[name]) - set(dont_care) gn_set = set(gn[name]) - set(dont_care)
print ' In gyp, but not in GN:\n %s' % '\n '.join( output += ' In gyp, but not in GN:\n %s' % '\n '.join(
sorted(gyp_set - gn_set)) sorted(gyp_set - gn_set)) + '\n'
print ' In GN, but not in gyp:\n %s' % '\n '.join( output += ' In GN, but not in gyp:\n %s' % '\n '.join(
sorted(gn_set - gyp_set)) sorted(gn_set - gyp_set)) + '\n\n'
print return output
return True
return False
def main(): def main():
...@@ -107,32 +113,38 @@ def main(): ...@@ -107,32 +113,38 @@ def main():
all_gn_flags = GetFlags(gn) all_gn_flags = GetFlags(gn)
gyp_files = set(all_gyp_flags.keys()) gyp_files = set(all_gyp_flags.keys())
gn_files = set(all_gn_flags.keys()) gn_files = set(all_gn_flags.keys())
differences = False different_source_list = gyp_files != gn_files
if gyp_files != gn_files: if different_source_list:
print 'Different set of sources files:' print 'Different set of sources files:'
print ' In gyp, not in GN:\n %s' % '\n '.join( print ' In gyp, not in GN:\n %s' % '\n '.join(
sorted(gyp_files - gn_files)) sorted(gyp_files - gn_files))
print ' In GN, not in gyp:\n %s' % '\n '.join( print ' In GN, not in gyp:\n %s' % '\n '.join(
sorted(gn_files - gyp_files)) sorted(gn_files - gyp_files))
print '\nNote that flags will only be compared for files in both sets.\n' print '\nNote that flags will only be compared for files in both sets.\n'
differences |= True
file_list = gyp_files & gn_files file_list = gyp_files & gn_files
files_with_given_differences = {}
for filename in sorted(file_list): for filename in sorted(file_list):
gyp_flags = all_gyp_flags[filename] gyp_flags = all_gyp_flags[filename]
gn_flags = all_gn_flags[filename] gn_flags = all_gn_flags[filename]
print filename differences = CompareLists(gyp_flags, gn_flags, 'dash_f')
differences |= CompareLists(gyp_flags, gn_flags, 'dash_f') differences += CompareLists(gyp_flags, gn_flags, 'defines', dont_care=[
differences |= CompareLists(gyp_flags, gn_flags, 'defines', dont_care=[
'-DENABLE_PRE_SYNC_BACKUP', '-DENABLE_PRE_SYNC_BACKUP',
'-DENABLE_WEBRTC=1', '-DENABLE_WEBRTC=1',
'-DUSE_LIBJPEG_TURBO=1', '-DUSE_LIBJPEG_TURBO=1',
'-DUSE_PANGO=1', '-DUSE_PANGO=1',
'-DUSE_SYMBOLIZE', '-DUSE_SYMBOLIZE',
]) ])
differences |= CompareLists(gyp_flags, gn_flags, 'include_dirs') differences += CompareLists(gyp_flags, gn_flags, 'include_dirs')
differences |= CompareLists(gyp_flags, gn_flags, 'warnings') differences += CompareLists(gyp_flags, gn_flags, 'warnings')
differences |= CompareLists(gyp_flags, gn_flags, 'other') differences += CompareLists(gyp_flags, gn_flags, 'other')
return 1 if differences else 0 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__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment