OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2016 the V8 project authors. All rights reserved. | 3 # Copyright 2016 the V8 project authors. All rights reserved. |
4 # Copyright 2014 The Chromium Authors. All rights reserved. | 4 # Copyright 2014 The Chromium Authors. All rights reserved. |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 """Given the output of -t commands from a ninja build for a gyp and GN generated | 8 """Given the output of -t commands from a ninja build for a gyp and GN generated |
9 build, report on differences between the command lines.""" | 9 build, report on differences between the command lines.""" |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if len(cc_file) != 1: | 91 if len(cc_file) != 1: |
92 print 'Skipping %s' % command_line | 92 print 'Skipping %s' % command_line |
93 continue | 93 continue |
94 assert len(cc_file) == 1 | 94 assert len(cc_file) == 1 |
95 | 95 |
96 if is_win: | 96 if is_win: |
97 rsp_file = [x for x in command_line if x.endswith('.rsp')] | 97 rsp_file = [x for x in command_line if x.endswith('.rsp')] |
98 assert len(rsp_file) <= 1 | 98 assert len(rsp_file) <= 1 |
99 if rsp_file: | 99 if rsp_file: |
100 rsp_file = os.path.join(build_dir, rsp_file[0][1:]) | 100 rsp_file = os.path.join(build_dir, rsp_file[0][1:]) |
| 101 if not os.path.exists(rsp_file): |
| 102 print 'Warning: Skipping %s' % rsp_file |
| 103 continue |
101 with open(rsp_file, "r") as open_rsp_file: | 104 with open(rsp_file, "r") as open_rsp_file: |
102 command_line = shlex.split(open_rsp_file, posix=False) | 105 command_line = shlex.split(open_rsp_file, posix=False) |
103 | 106 |
104 defines = [x for x in command_line if x.startswith('-D')] | 107 defines = [x for x in command_line if x.startswith('-D')] |
105 include_dirs = [x for x in command_line if x.startswith('-I')] | 108 include_dirs = [x for x in command_line if x.startswith('-I')] |
106 dash_f = [x for x in command_line if x.startswith('-f')] | 109 dash_f = [x for x in command_line if x.startswith('-f')] |
107 warnings = \ | 110 warnings = \ |
108 [x for x in command_line if x.startswith('/wd' if is_win else '-W')] | 111 [x for x in command_line if x.startswith('/wd' if is_win else '-W')] |
109 others = [x for x in command_line if x not in defines and \ | 112 others = [x for x in command_line if x not in defines and \ |
110 x not in include_dirs and \ | 113 x not in include_dirs and \ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 output += ' In gyp, but not in GN:\n %s' % '\n '.join( | 181 output += ' In gyp, but not in GN:\n %s' % '\n '.join( |
179 sorted(missing_in_gyp)) + '\n' | 182 sorted(missing_in_gyp)) + '\n' |
180 g_total_differences += len(missing_in_gyp) | 183 g_total_differences += len(missing_in_gyp) |
181 if missing_in_gn: | 184 if missing_in_gn: |
182 output += ' In GN, but not in gyp:\n %s' % '\n '.join( | 185 output += ' In GN, but not in gyp:\n %s' % '\n '.join( |
183 sorted(missing_in_gn)) + '\n\n' | 186 sorted(missing_in_gn)) + '\n\n' |
184 g_total_differences += len(missing_in_gn) | 187 g_total_differences += len(missing_in_gn) |
185 return output | 188 return output |
186 | 189 |
187 | 190 |
188 def Run(command_line): | 191 def Run(command_line, **kwargs): |
189 """Run |command_line| as a subprocess and return stdout. Raises on error.""" | 192 """Run |command_line| as a subprocess and return stdout. Raises on error.""" |
190 try: | 193 try: |
191 return subprocess.check_output(command_line, shell=True) | 194 return subprocess.check_output(command_line, shell=True,**kwargs) |
192 except subprocess.CalledProcessError as e: | 195 except subprocess.CalledProcessError as e: |
193 # Rescue the output we got until the exception happened. | 196 # Rescue the output we got until the exception happened. |
194 print '#### Stdout: ####################################################' | 197 print '#### Stdout: ####################################################' |
195 print e.output | 198 print e.output |
196 print '#################################################################' | 199 print '#################################################################' |
197 raise | 200 raise |
198 | 201 |
199 | 202 |
| 203 def compile(build_type, src_dir): |
| 204 args = "python -u E:/b/build/scripts/tools/runit.py --show-path python E:/b/bu
ild/scripts/slave/compile.py --build-args=-d --build-args=keeprsp --gsutil-py-pa
th E:/b/build/scripts/slave/.recipe_deps/depot_tools/gsutil.py --ninja-path E:/b
/build/scripts/slave/.recipe_deps/depot_tools/ninja.exe --target %s --src-dir %s
--goma-cache-dir E:/b/build/slave/goma_cache --compiler goma --goma-service-acc
ount-json-file C:/creds/service_accounts/service-account-goma-client.json --goma
-dir E:/b/build/slave/cache/cipd/goma --goma-fail-fast --goma-disable-local-fall
back -- all".replace('/', '\\') |
| 205 return Run(args % (build_type, src_dir)) |
| 206 |
200 def main(): | 207 def main(): |
201 if len(sys.argv) < 4: | 208 if len(sys.argv) < 4: |
202 print ('usage: %s gn_outdir gyp_outdir gn_target ' | 209 print ('usage: %s gn_outdir gyp_outdir gn_target ' |
203 '[gyp_target1, gyp_target2, ...]' % __file__) | 210 '[gyp_target1, gyp_target2, ...]' % __file__) |
204 return 1 | 211 return 1 |
205 | 212 |
206 if len(sys.argv) == 4: | 213 if len(sys.argv) == 4: |
207 sys.argv.append(sys.argv[3]) | 214 sys.argv.append(sys.argv[3]) |
208 gn_out_dir = sys.argv[1] | 215 gn_out_dir = sys.argv[1] |
| 216 gyp_out_dir = sys.argv[2] |
| 217 |
| 218 build_type = os.path.basename(gyp_out_dir) |
| 219 src_dir = os.path.dirname(os.path.dirname(gyp_out_dir)) |
| 220 print >> sys.stderr, 'Expecting gyp outdir in %s...' % gyp_out_dir |
| 221 if sys.platform == 'win32': |
| 222 # On Windows flags are stored in .rsp files which are created during build. |
| 223 print >> sys.stderr, 'Building in %s...' % gyp_out_dir |
| 224 # Run('ninja -C %s -d keeprsp %s' % (gyp_out_dir, " ".join(sys.argv[4:]))) |
| 225 compile(build_type, src_dir) |
| 226 |
| 227 gyp = Run('ninja -C %s -t commands %s' % (gyp_out_dir, " ".join(sys.argv[4:]))
) |
| 228 |
| 229 build_type = 'gn' |
209 print >> sys.stderr, 'Expecting gn outdir in %s...' % gn_out_dir | 230 print >> sys.stderr, 'Expecting gn outdir in %s...' % gn_out_dir |
210 gn = Run('ninja -C %s -t commands %s' % (gn_out_dir, sys.argv[3])) | |
211 if sys.platform == 'win32': | 231 if sys.platform == 'win32': |
212 # On Windows flags are stored in .rsp files which are created during build. | 232 # On Windows flags are stored in .rsp files which are created during build. |
213 print >> sys.stderr, 'Building in %s...' % gn_out_dir | 233 print >> sys.stderr, 'Building in %s...' % gn_out_dir |
214 Run('ninja -C %s -d keeprsp %s' % (gn_out_dir, sys.argv[3])) | 234 # Run('ninja -C %s -d keeprsp %s' % (gn_out_dir, sys.argv[3])) |
215 | 235 compile(build_type, src_dir) |
216 gyp_out_dir = sys.argv[2] | 236 gn = Run('ninja -C %s -t commands %s' % (gn_out_dir, sys.argv[3])) |
217 print >> sys.stderr, 'Expecting gyp outdir in %s...' % gyp_out_dir | |
218 gyp = Run('ninja -C %s -t commands %s' % (gyp_out_dir, " ".join(sys.argv[4:]))
) | |
219 if sys.platform == 'win32': | |
220 # On Windows flags are stored in .rsp files which are created during build. | |
221 print >> sys.stderr, 'Building in %s...' % gyp_out_dir | |
222 Run('ninja -C %s -d keeprsp %s' % (gyp_out_dir, " ".join(sys.argv[4:]))) | |
223 | 237 |
224 all_gyp_flags = GetFlags(gyp.splitlines(), | 238 all_gyp_flags = GetFlags(gyp.splitlines(), |
225 os.path.join(os.getcwd(), gyp_out_dir)) | 239 os.path.join(os.getcwd(), gyp_out_dir)) |
226 all_gn_flags = GetFlags(gn.splitlines(), | 240 all_gn_flags = GetFlags(gn.splitlines(), |
227 os.path.join(os.getcwd(), gn_out_dir)) | 241 os.path.join(os.getcwd(), gn_out_dir)) |
228 gyp_files = set(all_gyp_flags.keys()) | 242 gyp_files = set(all_gyp_flags.keys()) |
229 gn_files = set(all_gn_flags.keys()) | 243 gn_files = set(all_gn_flags.keys()) |
230 different_source_list = gyp_files != gn_files | 244 different_source_list = gyp_files != gn_files |
231 if different_source_list: | 245 if different_source_list: |
232 print 'Different set of sources files:' | 246 print 'Different set of sources files:' |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 print '\n'.join(sorted(files)) | 285 print '\n'.join(sorted(files)) |
272 print diff | 286 print diff |
273 | 287 |
274 print 'Total differences:', g_total_differences | 288 print 'Total differences:', g_total_differences |
275 # TODO(scottmg): Return failure on difference once we're closer to identical. | 289 # TODO(scottmg): Return failure on difference once we're closer to identical. |
276 return 0 | 290 return 0 |
277 | 291 |
278 | 292 |
279 if __name__ == '__main__': | 293 if __name__ == '__main__': |
280 sys.exit(main()) | 294 sys.exit(main()) |
OLD | NEW |