Commit 5523578b authored by wychen's avatar wychen Committed by Commit bot

Handle |public| in check_gn_headers.py

If |public| of a target contains files, count them as recognized
headers as well.

BUG=661774

Review-Url: https://codereview.chromium.org/2841323003
Cr-Commit-Position: refs/heads/master@{#467826}
parent 7a56b3cd
...@@ -76,7 +76,12 @@ def ParseGNProjectJSON(gn): ...@@ -76,7 +76,12 @@ def ParseGNProjectJSON(gn):
all_headers = set() all_headers = set()
for _target, properties in gn['targets'].iteritems(): for _target, properties in gn['targets'].iteritems():
for f in properties.get('sources', []): sources = properties.get('sources', [])
public = properties.get('public', [])
# Exclude '"public": "*"'.
if type(public) is list:
sources += public
for f in sources:
if f.endswith('.h') or f.endswith('.hh'): if f.endswith('.h') or f.endswith('.hh'):
if f.startswith('//'): if f.startswith('//'):
f = f[2:] # Strip the '//' prefix. f = f[2:] # Strip the '//' prefix.
......
...@@ -38,8 +38,14 @@ gn_input = json.loads(r''' ...@@ -38,8 +38,14 @@ gn_input = json.loads(r'''
"//:All": { "//:All": {
}, },
"//:base": { "//:base": {
"public": [ "//base/p.h" ],
"sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ], "sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ],
"visibility": [ "*" ] "visibility": [ "*" ]
},
"//:star_public": {
"public": "*",
"sources": [ "//base/c.h" ],
"visibility": [ "*" ]
} }
} }
} }
...@@ -88,6 +94,8 @@ class CheckGnHeadersTest(unittest.TestCase): ...@@ -88,6 +94,8 @@ class CheckGnHeadersTest(unittest.TestCase):
expected = set([ expected = set([
'base/a.h', 'base/a.h',
'base/b.hh', 'base/b.hh',
'base/c.h',
'base/p.h',
]) ])
self.assertEquals(headers, expected) self.assertEquals(headers, expected)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment