diff options
author | Mike Klein <mtklein@chromium.org> | 2016-11-02 09:14:55 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-03 17:28:39 +0000 |
commit | 89eda8a5e3f9023a4ee4648627101d7b4e60b4c8 (patch) | |
tree | fbaed5d530b26fbacf83fe89c05ed62123e678bc | |
parent | 6193568fed3983e406544a46a5e1fd292729ca84 (diff) |
Streamline skia.h construction.
This moves the work of finding headers from `gn gen` time into the action itself. We can do this safely now because we're constructing a skia.h.d deps file, which Ninja uses to track if-these-are-dirty-then-this-is-dirty relationships. Everything can now live in one handy find_headers.py.
Upshot is, `gn gen` runs ~50ms faster, and I think the code's clearer this way too.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4065
Change-Id: I2f1e7adf68be8e961eb77596786a795134bbb9a6
Reviewed-on: https://skia-review.googlesource.com/4065
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r-- | BUILD.gn | 24 | ||||
-rwxr-xr-x | gn/echo_headers.py | 16 | ||||
-rw-r--r-- | gn/find_headers.py | 54 |
3 files changed, 60 insertions, 34 deletions
@@ -667,26 +667,14 @@ component("skia") { } } -skia_h_headers = exec_script("gyp/find.py", - [ "*.h" ] + rebase_path(skia_public_includes), - "list lines", - []) - - [ - rebase_path("include/gpu/gl/GrGLConfig_chrome.h"), - rebase_path("include/gpu/vk/GrVkBackendContext.h"), - rebase_path("include/gpu/vk/GrVkDefines.h"), - rebase_path("include/gpu/vk/GrVkInterface.h"), - rebase_path("include/gpu/vk/GrVkTypes.h"), - rebase_path("include/ports/SkFontMgr_fontconfig.h"), - ] - action("skia.h") { - script = "gn/echo_headers.py" - args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] + - rebase_path(skia_h_headers, target_gen_dir) - inputs = skia_h_headers + skia_h = "$target_gen_dir/skia.h" + script = "gn/find_headers.py" + args = [ rebase_path(skia_h, root_build_dir) ] + + rebase_path(skia_public_includes) + depfile = "$skia_h.deps" outputs = [ - "$target_gen_dir/skia.h", + skia_h, ] } diff --git a/gn/echo_headers.py b/gn/echo_headers.py deleted file mode 100755 index 059838a6ff..0000000000 --- a/gn/echo_headers.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2016 Google Inc. -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import sys - -with open(sys.argv[1], "w") as f: - f.write('// skia.h generated by GN.\n') - f.write('#ifndef skia_h_DEFINED\n') - f.write('#define skia_h_DEFINED\n') - for h in sys.argv[2:]: - f.write('#include "' + h + '"\n') - f.write('#endif//skia_h_DEFINED\n') diff --git a/gn/find_headers.py b/gn/find_headers.py new file mode 100644 index 0000000000..4ade28de71 --- /dev/null +++ b/gn/find_headers.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys + +# We'll recursively search each include directory for headers, +# then write them to skia.h with a small blacklist. + +# We'll also write skia.h.deps, which Ninja uses to track dependencies. It's the +# very same mechanism Ninja uses to know which .h files affect which .cpp files. + +skia_h = sys.argv[1] +include_dirs = sys.argv[2:] + +blacklist = { + "GrGLConfig_chrome.h", + "GrVkBackendContext.h", + "GrVkDefines.h", + "GrVkInterface.h", + "GrVkTypes.h", + "SkFontMgr_fontconfig.h", +} + +headers = [] +for directory in include_dirs: + for d, _, files in os.walk(directory): + for f in files: + if f.endswith('.h') and f not in blacklist: + headers.append(os.path.join(d,f)) +headers.sort() + +with open(skia_h, "w") as f: + f.write('// skia.h generated by GN.\n') + f.write('#ifndef skia_h_DEFINED\n') + f.write('#define skia_h_DEFINED\n') + for h in headers: + f.write('#include "' + h + '"\n') + f.write('#endif//skia_h_DEFINED\n') + +with open(skia_h + '.deps', "w") as f: + f.write(skia_h + ':') + for h in headers: + f.write(' ' + h) + f.write('\n') + +# Temporary: during development this file wrote skia.h.d, not skia.h.deps, +# and I think we have some bad versions of those files laying around. +if os.path.exists(skia_h + '.d'): + os.remove(skia_h + '.d') |