From 8f480d91eea1421c1f9d7251699b710fd0cf2197 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Wed, 30 May 2018 13:17:49 -0400 Subject: 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 Reviewed-by: Ben Wagner Commit-Queue: Florin Malita --- gn/find_headers.py | 30 +++++++++++++++++++----------- modules/skottie/BUILD.gn | 5 +++-- 2 files changed, 22 insertions(+), 13 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 = {} diff --git a/modules/skottie/BUILD.gn b/modules/skottie/BUILD.gn index 1e8ccb2df8..59223de916 100644 --- a/modules/skottie/BUILD.gn +++ b/modules/skottie/BUILD.gn @@ -17,9 +17,10 @@ config("public_config") { 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", -- cgit v1.2.3