OLD | NEW |
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 | 11 import os |
| 12 import shlex |
12 import subprocess | 13 import subprocess |
13 import sys | 14 import sys |
14 | 15 |
15 | 16 |
16 # Must be in src/. | 17 # Must be in src/. |
17 os.chdir(os.path.join(os.path.dirname(__file__), '..', '..', '..')) | 18 os.chdir(os.path.join(os.path.dirname(__file__), '..', '..', '..')) |
18 | 19 |
19 | 20 |
20 g_total_differences = 0 | 21 g_total_differences = 0 |
21 | 22 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 70 |
70 | 71 |
71 def GetFlags(lines): | 72 def GetFlags(lines): |
72 """Turn a list of command lines into a semi-structured dict.""" | 73 """Turn a list of command lines into a semi-structured dict.""" |
73 flags_by_output = {} | 74 flags_by_output = {} |
74 for line in lines: | 75 for line in lines: |
75 # TODO(scottmg): Hacky way of getting only cc for now. | 76 # TODO(scottmg): Hacky way of getting only cc for now. |
76 if 'clang' not in line: | 77 if 'clang' not in line: |
77 continue | 78 continue |
78 | 79 |
79 # TODO(scottmg): Proper escapes. | 80 command_line = shlex.split(line.strip())[1:] |
80 command_line = line.strip().split()[1:] | |
81 | 81 |
82 output_name = FindAndRemoveArgWithValue(command_line, '-o') | 82 output_name = FindAndRemoveArgWithValue(command_line, '-o') |
83 dep_name = FindAndRemoveArgWithValue(command_line, '-MF') | 83 dep_name = FindAndRemoveArgWithValue(command_line, '-MF') |
84 | 84 |
85 NormalizeSymbolArguments(command_line) | 85 NormalizeSymbolArguments(command_line) |
86 | 86 |
87 command_line = MergeSpacedArgs(command_line, '-Xclang') | 87 command_line = MergeSpacedArgs(command_line, '-Xclang') |
88 | 88 |
89 defines = [x for x in command_line if x.startswith('-D')] | 89 defines = [x for x in command_line if x.startswith('-D')] |
90 include_dirs = [x for x in command_line if x.startswith('-I')] | 90 include_dirs = [x for x in command_line if x.startswith('-I')] |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 print '\n'.join(sorted(files)) | 218 print '\n'.join(sorted(files)) |
219 print diff | 219 print diff |
220 | 220 |
221 print 'Total differences:', g_total_differences | 221 print 'Total differences:', g_total_differences |
222 # TODO(scottmg): Return failure on difference once we're closer to identical. | 222 # TODO(scottmg): Return failure on difference once we're closer to identical. |
223 return 0 | 223 return 0 |
224 | 224 |
225 | 225 |
226 if __name__ == '__main__': | 226 if __name__ == '__main__': |
227 sys.exit(main()) | 227 sys.exit(main()) |
OLD | NEW |