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

Side by Side Diff: build/check_gn_headers.py

Issue 2841323003: Handle |public| in check_gn_headers.py (Closed)
Patch Set: add tests Created 3 years, 7 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 | build/check_gn_headers_unittest.py » ('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
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
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 # Exclude '"public": "*"'.
82 if type(public) is list:
83 sources += public
84 for f in sources:
80 if f.endswith('.h') or f.endswith('.hh'): 85 if f.endswith('.h') or f.endswith('.hh'):
81 if f.startswith('//'): 86 if f.startswith('//'):
82 f = f[2:] # Strip the '//' prefix. 87 f = f[2:] # Strip the '//' prefix.
83 all_headers.add(f) 88 all_headers.add(f)
84 89
85 return all_headers 90 return all_headers
86 91
87 92
88 def GetDepsPrefixes(q): 93 def GetDepsPrefixes(q):
89 """Return all the folders controlled by DEPS file""" 94 """Return all the folders controlled by DEPS file"""
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return 0 158 return 0
154 159
155 print 'The following files should be included in gn files:' 160 print 'The following files should be included in gn files:'
156 for i in missing: 161 for i in missing:
157 print i 162 print i
158 return 1 163 return 1
159 164
160 165
161 if __name__ == '__main__': 166 if __name__ == '__main__':
162 sys.exit(main()) 167 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/check_gn_headers_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698