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

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

Issue 559853002: Make gyp_flag_compare.py regenerate and take a target name to make it more usable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | 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
11 import os
12 import subprocess
11 import sys 13 import sys
12 14
13 15
14 def FindAndRemoveArgWithValue(command_line, argname): 16 def FindAndRemoveArgWithValue(command_line, argname):
15 """Given a command line as a list, remove and return the value of an option 17 """Given a command line as a list, remove and return the value of an option
16 that takes a value as a separate entry. 18 that takes a value as a separate entry.
17 19
18 Modifies |command_line| in place. 20 Modifies |command_line| in place.
19 """ 21 """
20 if argname not in command_line: 22 if argname not in command_line:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 output += ' %s differ:\n' % name 96 output += ' %s differ:\n' % name
95 gyp_set = set(gyp[name]) - set(dont_care) 97 gyp_set = set(gyp[name]) - set(dont_care)
96 gn_set = set(gn[name]) - set(dont_care) 98 gn_set = set(gn[name]) - set(dont_care)
97 output += ' In gyp, but not in GN:\n %s' % '\n '.join( 99 output += ' In gyp, but not in GN:\n %s' % '\n '.join(
98 sorted(gyp_set - gn_set)) + '\n' 100 sorted(gyp_set - gn_set)) + '\n'
99 output += ' In GN, but not in gyp:\n %s' % '\n '.join( 101 output += ' In GN, but not in gyp:\n %s' % '\n '.join(
100 sorted(gn_set - gyp_set)) + '\n\n' 102 sorted(gn_set - gyp_set)) + '\n\n'
101 return output 103 return output
102 104
103 105
106 def Run(command_line):
107 """Run |command_line| as a subprocess and return stdout. Raises on error."""
108 return subprocess.check_output(command_line, shell=True)
109
110
104 def main(): 111 def main():
105 if len(sys.argv) != 3: 112 if len(sys.argv) != 2 and len(sys.argv) != 3:
106 print 'usage: %s gyp_commands.txt gn_commands.txt' % __file__ 113 print 'usage: %s gyp_target gn_target' % __file__
114 print ' or: %s target' % __file__
107 return 1 115 return 1
108 with open(sys.argv[1], 'rb') as f: 116
109 gyp = f.readlines() 117 if len(sys.argv) == 2:
110 with open(sys.argv[2], 'rb') as f: 118 sys.argv.append(sys.argv[1])
111 gn = f.readlines() 119
112 all_gyp_flags = GetFlags(gyp) 120 print >>sys.stderr, 'Regenerating...'
113 all_gn_flags = GetFlags(gn) 121 # Currently only Release, non-component.
122 Run('gn gen out/gn_flags --args="is_debug=false is_component_build=false"')
123 del os.environ['GYP_DEFINES']
124 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])
126 gyp = Run('ninja -C out_gyp_flags/Release -t commands %s' % sys.argv[1])
127 all_gyp_flags = GetFlags(gyp.splitlines())
128 all_gn_flags = GetFlags(gn.splitlines())
114 gyp_files = set(all_gyp_flags.keys()) 129 gyp_files = set(all_gyp_flags.keys())
115 gn_files = set(all_gn_flags.keys()) 130 gn_files = set(all_gn_flags.keys())
116 different_source_list = gyp_files != gn_files 131 different_source_list = gyp_files != gn_files
117 if different_source_list: 132 if different_source_list:
118 print 'Different set of sources files:' 133 print 'Different set of sources files:'
119 print ' In gyp, not in GN:\n %s' % '\n '.join( 134 print ' In gyp, not in GN:\n %s' % '\n '.join(
120 sorted(gyp_files - gn_files)) 135 sorted(gyp_files - gn_files))
121 print ' In GN, not in gyp:\n %s' % '\n '.join( 136 print ' In GN, not in gyp:\n %s' % '\n '.join(
122 sorted(gn_files - gyp_files)) 137 sorted(gn_files - gyp_files))
123 print '\nNote that flags will only be compared for files in both sets.\n' 138 print '\nNote that flags will only be compared for files in both sets.\n'
(...skipping 18 matching lines...) Expand all
142 157
143 for diff, files in files_with_given_differences.iteritems(): 158 for diff, files in files_with_given_differences.iteritems():
144 print '\n'.join(sorted(files)) 159 print '\n'.join(sorted(files))
145 print diff 160 print diff
146 161
147 return 1 if files_with_given_differences or different_source_list else 0 162 return 1 if files_with_given_differences or different_source_list else 0
148 163
149 164
150 if __name__ == '__main__': 165 if __name__ == '__main__':
151 sys.exit(main()) 166 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698