aboutsummaryrefslogtreecommitdiffhomepage
path: root/gn/find_headers.py
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2018-05-30 13:17:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-30 18:00:09 +0000
commit8f480d91eea1421c1f9d7251699b710fd0cf2197 (patch)
tree9826b61adf458b7f76bcdf21193c97c3b0472774 /gn/find_headers.py
parent8dc68c67f827b5b98e05946da251d0f2b2c27e98 (diff)
Add 'public' headers support to find_headers.py
Update the script to search for headers in both 'sources' and 'public'. Change-Id: I195c6e3720f3d3d99dea04628388821a58fa791b Reviewed-on: https://skia-review.googlesource.com/130823 Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
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 = {}