aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn/find_headers.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn/find_headers.py')
-rwxr-xr-xgn/find_headers.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/gn/find_headers.py b/gn/find_headers.py
index cbb59b5d95..d02bd906b7 100755
--- a/gn/find_headers.py
+++ b/gn/find_headers.py
@@ -27,27 +27,35 @@ include_dirs = [os.path.join(os.path.normpath(include_dir), '')
for include_dir in include_dirs]
include_dirs.sort(key=len, reverse=True)
-# If skia ever uses 'public' that will need to be considered as well or instead.
-gn_sources_cmd = [gn, 'desc', '.', '--root=%s' % absolute_source,
- '--format=json', '*', 'sources']
+gn_desc_cmd = [gn, 'desc', '.', '--root=%s' % absolute_source, '--format=json',
+ '*']
-sources_json_txt = ''
+desc_json_txt = ''
try:
- sources_json_txt = subprocess.check_output(gn_sources_cmd)
+ desc_json_txt = subprocess.check_output(gn_desc_cmd)
except subprocess.CalledProcessError as e:
print e.output
raise
-sources_json = {}
+desc_json = {}
try:
- sources_json = json.loads(sources_json_txt)
+ desc_json = json.loads(desc_json_txt)
except ValueError:
- print sources_json_txt
+ print desc_json_txt
raise
-sources = {os.path.join(absolute_source, os.path.normpath(source[2:]))
- for target in sources_json.itervalues()
- for source in target.get('sources', [])}
+sources = set()
+
+for target in desc_json.itervalues():
+ # We'll use `public` headers if they're listed, or pull them from `sources`
+ # if not. GN sneaks in a default "public": "*" into the JSON if you don't
+ # set one explicitly.
+ search_list = target.get('public')
+ if search_list == '*':
+ search_list = target.get('sources', [])
+
+ for name in search_list:
+ sources.add(os.path.join(absolute_source, os.path.normpath(name[2:])))
Header = collections.namedtuple('Header', ['absolute', 'include'])
headers = {}