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>
diff --git a/gn/find_headers.py b/gn/find_headers.py
index cbb59b5..d02bd90 100755
--- a/gn/find_headers.py
+++ b/gn/find_headers.py
@@ -27,27 +27,35 @@
                 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 = {}
diff --git a/modules/skottie/BUILD.gn b/modules/skottie/BUILD.gn
index 1e8ccb2..59223de 100644
--- a/modules/skottie/BUILD.gn
+++ b/modules/skottie/BUILD.gn
@@ -17,9 +17,10 @@
 source_set("skottie") {
   if (skia_enable_skottie) {
     public_configs = [ ":public_config" ]
-    sources = [
-      # TODO: move this to public
+    public = [
       "include/Skottie.h",
+    ]
+    sources = [
       "src/Skottie.cpp",
       "src/SkottieAdapter.cpp",
       "src/SkottieAdapter.h",