Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Find header files missing in GN. | 6 """Find header files missing in GN. |
| 7 | 7 |
| 8 This script gets all the header files from ninja_deps, which is from the true | 8 This script gets all the header files from ninja_deps, which is from the true |
| 9 dependency generated by the compiler, and report if they don't exist in GN. | 9 dependency generated by the compiler, and report if they don't exist in GN. |
| 10 """ | 10 """ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 subprocess.check_call(['gn', 'gen', out_dir, '--ide=json', '-q']) | 69 subprocess.check_call(['gn', 'gen', out_dir, '--ide=json', '-q']) |
| 70 gn_json = json.load(open(os.path.join(out_dir, 'project.json'))) | 70 gn_json = json.load(open(os.path.join(out_dir, 'project.json'))) |
| 71 q.put(ParseGNProjectJSON(gn_json)) | 71 q.put(ParseGNProjectJSON(gn_json)) |
| 72 | 72 |
| 73 | 73 |
| 74 def ParseGNProjectJSON(gn): | 74 def ParseGNProjectJSON(gn): |
| 75 """Parse GN output and get the header files""" | 75 """Parse GN output and get the header files""" |
| 76 all_headers = set() | 76 all_headers = set() |
| 77 | 77 |
| 78 for _target, properties in gn['targets'].iteritems(): | 78 for _target, properties in gn['targets'].iteritems(): |
| 79 for f in properties.get('sources', []): | 79 sources = properties.get('sources', []) |
| 80 public = properties.get('public', []) | |
| 81 if type(public) is list: | |
|
Nico
2017/04/27 14:14:50
isn't that always true?
wychen
2017/04/27 16:20:56
It could be "*" in some cases. I'll add this in th
| |
| 82 sources += public | |
| 83 for f in sources: | |
| 80 if f.endswith('.h') or f.endswith('.hh'): | 84 if f.endswith('.h') or f.endswith('.hh'): |
| 81 if f.startswith('//'): | 85 if f.startswith('//'): |
| 82 f = f[2:] # Strip the '//' prefix. | 86 f = f[2:] # Strip the '//' prefix. |
| 83 all_headers.add(f) | 87 all_headers.add(f) |
| 84 | 88 |
| 85 return all_headers | 89 return all_headers |
| 86 | 90 |
| 87 | 91 |
| 88 def GetDepsPrefixes(q): | 92 def GetDepsPrefixes(q): |
| 89 """Return all the folders controlled by DEPS file""" | 93 """Return all the folders controlled by DEPS file""" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 return 0 | 157 return 0 |
| 154 | 158 |
| 155 print 'The following files should be included in gn files:' | 159 print 'The following files should be included in gn files:' |
| 156 for i in missing: | 160 for i in missing: |
| 157 print i | 161 print i |
| 158 return 1 | 162 return 1 |
| 159 | 163 |
| 160 | 164 |
| 161 if __name__ == '__main__': | 165 if __name__ == '__main__': |
| 162 sys.exit(main()) | 166 sys.exit(main()) |
| OLD | NEW |