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

Side by Side Diff: tools/gyp_flag_compare.py

Issue 2274713005: GN: Fix Windows Clang errors (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: It works! Created 4 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/winsdk_samples/BUILD.gn ('k') | webrtc/base/BUILD.gn » ('j') | 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
kjellander_webrtc 2016/08/25 11:07:19 Updating this script is good, but let's do that in
2 2
3 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license 5 # Use of this source code is governed by a BSD-style license
6 # that can be found in the LICENSE file in the root of the source 6 # that can be found in the LICENSE file in the root of the source
7 # tree. An additional intellectual property rights grant can be found 7 # tree. An additional intellectual property rights grant can be found
8 # in the file PATENTS. All contributing project authors may 8 # in the file PATENTS. All contributing project authors may
9 # be found in the AUTHORS file in the root of the source tree. 9 # be found in the AUTHORS file in the root of the source tree.
10 10
11 """Given the output of -t commands from a ninja build for a gyp and GN generated 11 """Given the output of -t commands from a ninja build for a gyp and GN generated
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 for path in dict_of_list: 106 for path in dict_of_list:
107 dirname = os.path.dirname(path) 107 dirname = os.path.dirname(path)
108 r.setdefault(dirname, 0) 108 r.setdefault(dirname, 0)
109 r[dirname] += 1 109 r[dirname] += 1
110 return r 110 return r
111 111
112 112
113 class Comparison(object): 113 class Comparison(object):
114 """A comparison of the currently-configured build for a target.""" 114 """A comparison of the currently-configured build for a target."""
115 115
116 def __init__(self, gyp_target, gn_target=None, gyp_dir=_DEFAULT_GYP_DIR, 116 def __init__(self, gyp_target=None, gn_target=None, gyp_dir=_DEFAULT_GYP_DIR,
117 gn_dir=_DEFAULT_GN_DIR): 117 gn_dir=_DEFAULT_GN_DIR):
118 """Creates a comparison of a GN and GYP target. If the target names differ 118 """Creates a comparison of a GN and GYP target. If the target names differ
119 between the two build systems, then two names may be passed. 119 between the two build systems, then two names may be passed.
120 """ 120 """
121 if gn_target is None: 121 if gn_target is None:
122 gn_target = gyp_target 122 gn_target = gyp_target
123 self._gyp_target = gyp_target 123 self._gyp_target = gyp_target
124 self._gn_target = gn_target 124 self._gn_target = gn_target
125 125
126 self._gyp_dir = gyp_dir 126 self._gyp_dir = gyp_dir
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 def _CompareFiles(self): 189 def _CompareFiles(self):
190 """Performs the actual target comparison.""" 190 """Performs the actual target comparison."""
191 if sys.platform == 'win32': 191 if sys.platform == 'win32':
192 # On Windows flags are stored in .rsp files which are created by building. 192 # On Windows flags are stored in .rsp files which are created by building.
193 print >> sys.stderr, 'Building in %s...' % self._gn_dir 193 print >> sys.stderr, 'Building in %s...' % self._gn_dir
194 Run('ninja -C %s -d keeprsp %s' % (self._gn_dir, self._gn_target)) 194 Run('ninja -C %s -d keeprsp %s' % (self._gn_dir, self._gn_target))
195 print >> sys.stderr, 'Building in %s...' % self._gyp_dir 195 print >> sys.stderr, 'Building in %s...' % self._gyp_dir
196 Run('ninja -C %s -d keeprsp %s' % (self._gyp_dir, self._gn_target)) 196 Run('ninja -C %s -d keeprsp %s' % (self._gyp_dir, self._gn_target))
197 197
198 gn = Run('ninja -C %s -t commands %s' % (self._gn_dir, self._gn_target)) 198 if self._gn_target is not None:
199 gyp = Run('ninja -C %s -t commands %s' % (self._gyp_dir, self._gyp_target)) 199 gn = Run('ninja -C %s -t commands %s' % (self._gn_dir, self._gn_target))
200 gyp = Run('ninja -C %s -t commands %s' % (self._gyp_dir,
201 self._gyp_target))
202 else:
203 gn = Run('ninja -C %s -t commands' % (self._gn_dir))
204 gyp = Run('ninja -C %s -t commands' % (self._gyp_dir))
200 205
201 self._gn_flags = self._GetFlags(gn.splitlines(), 206 self._gn_flags = self._GetFlags(gn.splitlines(),
202 os.path.join(os.getcwd(), self._gn_dir)) 207 os.path.join(os.getcwd(), self._gn_dir))
203 self._gyp_flags = self._GetFlags(gyp.splitlines(), 208 self._gyp_flags = self._GetFlags(gyp.splitlines(),
204 os.path.join(os.getcwd(), self._gyp_dir)) 209 os.path.join(os.getcwd(), self._gyp_dir))
205 210
206 self._gn_flags = dict((FilterChromium(filename), value) 211 self._gn_flags = dict((FilterChromium(filename), value)
207 for filename, value in self._gn_flags.iteritems()) 212 for filename, value in self._gn_flags.iteritems())
208 self._gyp_flags = dict((FilterChromium(filename), value) 213 self._gyp_flags = dict((FilterChromium(filename), value)
209 for filename, value in self._gyp_flags.iteritems()) 214 for filename, value in self._gyp_flags.iteritems())
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return result 387 return result
383 388
384 389
385 def Run(command_line): 390 def Run(command_line):
386 """Run |command_line| as a subprocess and return stdout. Raises on error.""" 391 """Run |command_line| as a subprocess and return stdout. Raises on error."""
387 print >> sys.stderr, command_line 392 print >> sys.stderr, command_line
388 return subprocess.check_output(command_line, shell=True) 393 return subprocess.check_output(command_line, shell=True)
389 394
390 395
391 def main(): 396 def main():
392 if len(sys.argv) < 4: 397 if len(sys.argv) < 3:
393 print 'usage: %s gyp_dir gn_dir target' % __file__ 398 print 'usage: %s gyp_dir gn_dir target' % __file__
394 print ' or: %s gyp_dir gn_dir gyp_target gn_target' % __file__ 399 print ' or: %s gyp_dir gn_dir gyp_target gn_target' % __file__
395 return 1 400 return 1
396 401
397 gyp_dir = sys.argv[1] 402 gyp_dir = sys.argv[1]
398 gn_dir = sys.argv[2] 403 gn_dir = sys.argv[2]
399 404
400 gyp_target = sys.argv[3] 405 gyp_target = gn_target = None
406
401 if len(sys.argv) == 4: 407 if len(sys.argv) == 4:
408 gyp_target = sys.argv[3]
402 gn_target = gyp_target 409 gn_target = gyp_target
403 else: 410 elif len(sys.argv) == 5:
411 gyp_target = sys.argv[3]
404 gn_target = sys.argv[4] 412 gn_target = sys.argv[4]
405 413
406 print 'GYP output directory is %s' % gyp_dir 414 print 'GYP output directory is %s' % gyp_dir
407 print 'GN output directory is %s' % gn_dir 415 print 'GN output directory is %s' % gn_dir
408 416
409 comparison = Comparison(gyp_target, gn_target, gyp_dir, gn_dir) 417 comparison = Comparison(gyp_target, gn_target, gyp_dir, gn_dir)
410 418
411 gyp_files = comparison.gyp_files 419 gyp_files = comparison.gyp_files
412 gn_files = comparison.gn_files 420 gn_files = comparison.gn_files
413 different_source_list = comparison.gyp_files != comparison.gn_files 421 different_source_list = comparison.gyp_files != comparison.gn_files
(...skipping 28 matching lines...) Expand all
442 print '\n'.join(sorted(files)) 450 print '\n'.join(sorted(files))
443 print diff 451 print diff
444 452
445 print 'Total differences:', comparison.total_differences 453 print 'Total differences:', comparison.total_differences
446 # TODO(scottmg): Return failure on difference once we're closer to identical. 454 # TODO(scottmg): Return failure on difference once we're closer to identical.
447 return 0 455 return 0
448 456
449 457
450 if __name__ == '__main__': 458 if __name__ == '__main__':
451 sys.exit(main()) 459 sys.exit(main())
OLDNEW
« no previous file with comments | « third_party/winsdk_samples/BUILD.gn ('k') | webrtc/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698