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

Side by Side Diff: tools/gn/bin/gyp_flag_compare.py

Issue 555343002: gn: make some warning flags match gyp more closely (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: breakpad:minidump_dump non-chromium_code Created 6 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 unified diff | Download patch
« no previous file with comments | « third_party/cython/rules.gni ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Given the output of -t commands from a ninja build for a gyp and GN generated 7 """Given the output of -t commands from a ninja build for a gyp and GN generated
8 build, report on differences between the command lines.""" 8 build, report on differences between the command lines."""
9 9
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 'depname': dep_name, 79 'depname': dep_name,
80 'defines': sorted(defines), 80 'defines': sorted(defines),
81 'include_dirs': sorted(include_dirs), # TODO(scottmg): This is wrong. 81 'include_dirs': sorted(include_dirs), # TODO(scottmg): This is wrong.
82 'dash_f': sorted(dash_f), 82 'dash_f': sorted(dash_f),
83 'warnings': sorted(warnings), 83 'warnings': sorted(warnings),
84 'other': sorted(others), 84 'other': sorted(others),
85 } 85 }
86 return flags_by_output 86 return flags_by_output
87 87
88 88
89 def CompareLists(gyp, gn, name, dont_care=None): 89 def CompareLists(gyp, gn, name, dont_care_gyp=None, dont_care_gn=None):
90 """Return a report of any differences between two lists, ignoring anything 90 """Return a report of any differences between gyp and gn lists, ignoring
91 in |dont_care|.""" 91 anything in |dont_care_{gyp|gn}| respectively."""
92 if not dont_care: 92 if not dont_care_gyp:
93 dont_care = [] 93 dont_care_gyp = []
94 if not dont_care_gn:
95 dont_care_gn = []
94 output = '' 96 output = ''
95 if gyp[name] != gn[name]: 97 if gyp[name] != gn[name]:
96 output += ' %s differ:\n' % name 98 output += ' %s differ:\n' % name
97 gyp_set = set(gyp[name]) - set(dont_care) 99 gyp_set = set(gyp[name])
98 gn_set = set(gn[name]) - set(dont_care) 100 gn_set = set(gn[name])
99 output += ' In gyp, but not in GN:\n %s' % '\n '.join( 101 missing_in_gyp = gyp_set - gn_set
100 sorted(gyp_set - gn_set)) + '\n' 102 missing_in_gn = gn_set - gyp_set
101 output += ' In GN, but not in gyp:\n %s' % '\n '.join( 103 missing_in_gyp -= set(dont_care_gyp)
102 sorted(gn_set - gyp_set)) + '\n\n' 104 missing_in_gn -= set(dont_care_gn)
105 if missing_in_gyp:
106 output += ' In gyp, but not in GN:\n %s' % '\n '.join(
107 sorted(missing_in_gyp)) + '\n'
108 if missing_in_gn:
109 output += ' In GN, but not in gyp:\n %s' % '\n '.join(
110 sorted(missing_in_gn)) + '\n\n'
103 return output 111 return output
104 112
105 113
106 def Run(command_line): 114 def Run(command_line):
107 """Run |command_line| as a subprocess and return stdout. Raises on error.""" 115 """Run |command_line| as a subprocess and return stdout. Raises on error."""
108 return subprocess.check_output(command_line, shell=True) 116 return subprocess.check_output(command_line, shell=True)
109 117
110 118
111 def main(): 119 def main():
112 if len(sys.argv) != 2 and len(sys.argv) != 3: 120 if len(sys.argv) != 2 and len(sys.argv) != 3:
113 print 'usage: %s gyp_target gn_target' % __file__ 121 print 'usage: %s gyp_target gn_target' % __file__
114 print ' or: %s target' % __file__ 122 print ' or: %s target' % __file__
115 return 1 123 return 1
116 124
117 if len(sys.argv) == 2: 125 if len(sys.argv) == 2:
118 sys.argv.append(sys.argv[1]) 126 sys.argv.append(sys.argv[1])
119 127
120 print >>sys.stderr, 'Regenerating...' 128 print >>sys.stderr, 'Regenerating...'
121 # Currently only Release, non-component. 129 # Currently only Release, non-component.
122 Run('gn gen out/gn_flags --args="is_debug=false is_component_build=false"') 130 Run('gn gen out/gn_flags --args="is_debug=false is_component_build=false"')
123 del os.environ['GYP_DEFINES'] 131 os.environ.pop('GYP_DEFINES', None)
124 Run('python build/gyp_chromium -Goutput_dir=out_gyp_flags -Gconfig=Release') 132 Run('python build/gyp_chromium -Goutput_dir=out_gyp_flags -Gconfig=Release')
125 gn = Run('ninja -C out/gn_flags -t commands %s' % sys.argv[2]) 133 gn = Run('ninja -C out/gn_flags -t commands %s' % sys.argv[2])
126 gyp = Run('ninja -C out_gyp_flags/Release -t commands %s' % sys.argv[1]) 134 gyp = Run('ninja -C out_gyp_flags/Release -t commands %s' % sys.argv[1])
127 all_gyp_flags = GetFlags(gyp.splitlines()) 135 all_gyp_flags = GetFlags(gyp.splitlines())
128 all_gn_flags = GetFlags(gn.splitlines()) 136 all_gn_flags = GetFlags(gn.splitlines())
129 gyp_files = set(all_gyp_flags.keys()) 137 gyp_files = set(all_gyp_flags.keys())
130 gn_files = set(all_gn_flags.keys()) 138 gn_files = set(all_gn_flags.keys())
131 different_source_list = gyp_files != gn_files 139 different_source_list = gyp_files != gn_files
132 if different_source_list: 140 if different_source_list:
133 print 'Different set of sources files:' 141 print 'Different set of sources files:'
134 print ' In gyp, not in GN:\n %s' % '\n '.join( 142 print ' In gyp, not in GN:\n %s' % '\n '.join(
135 sorted(gyp_files - gn_files)) 143 sorted(gyp_files - gn_files))
136 print ' In GN, not in gyp:\n %s' % '\n '.join( 144 print ' In GN, not in gyp:\n %s' % '\n '.join(
137 sorted(gn_files - gyp_files)) 145 sorted(gn_files - gyp_files))
138 print '\nNote that flags will only be compared for files in both sets.\n' 146 print '\nNote that flags will only be compared for files in both sets.\n'
139 file_list = gyp_files & gn_files 147 file_list = gyp_files & gn_files
140 files_with_given_differences = {} 148 files_with_given_differences = {}
141 for filename in sorted(file_list): 149 for filename in sorted(file_list):
142 gyp_flags = all_gyp_flags[filename] 150 gyp_flags = all_gyp_flags[filename]
143 gn_flags = all_gn_flags[filename] 151 gn_flags = all_gn_flags[filename]
144 differences = CompareLists(gyp_flags, gn_flags, 'dash_f') 152 differences = CompareLists(gyp_flags, gn_flags, 'dash_f')
145 differences += CompareLists(gyp_flags, gn_flags, 'defines', dont_care=[ 153 differences += CompareLists(gyp_flags, gn_flags, 'defines')
146 '-DENABLE_PRE_SYNC_BACKUP', 154 differences += CompareLists(gyp_flags, gn_flags, 'include_dirs')
147 '-DENABLE_WEBRTC=1', 155 differences += CompareLists(gyp_flags, gn_flags, 'warnings', dont_care_gn=[
148 '-DUSE_LIBJPEG_TURBO=1', 156 # More conservative warnings in GN we consider to be OK.
149 '-DUSE_PANGO=1', 157 '-Wendif-labels',
150 '-DUSE_SYMBOLIZE', 158 '-Wextra',
159 '-Wsign-compare',
151 ]) 160 ])
152 differences += CompareLists(gyp_flags, gn_flags, 'include_dirs')
153 differences += CompareLists(gyp_flags, gn_flags, 'warnings')
154 differences += CompareLists(gyp_flags, gn_flags, 'other') 161 differences += CompareLists(gyp_flags, gn_flags, 'other')
155 if differences: 162 if differences:
156 files_with_given_differences.setdefault(differences, []).append(filename) 163 files_with_given_differences.setdefault(differences, []).append(filename)
157 164
158 for diff, files in files_with_given_differences.iteritems(): 165 for diff, files in files_with_given_differences.iteritems():
159 print '\n'.join(sorted(files)) 166 print '\n'.join(sorted(files))
160 print diff 167 print diff
161 168
162 return 1 if files_with_given_differences or different_source_list else 0 169 return 1 if files_with_given_differences or different_source_list else 0
163 170
164 171
165 if __name__ == '__main__': 172 if __name__ == '__main__':
166 sys.exit(main()) 173 sys.exit(main())
OLDNEW
« no previous file with comments | « third_party/cython/rules.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698