Revert "find_headers.py to better find headers."
This reverts commit 6c8ad116d460fe892fff77b8f80e284e3487d59d.
Reason for revert:
https://chromium-swarm.appspot.com/task?id=3db0ac33aa369910&refresh=10
[981/1474] ACTION //:skia.h(//gn/toolchain:gcc_like)
FAILED: gen/skia.h
python ../../../gn/find_headers.py /mnt/pd0/s/w/ir/cache/work/skia/bin/gn /mnt/pd0/s/w/ir/cache/work/skia/ gen/skia.h /mnt/pd0/s/w/ir/cache/work/skia/include/android /mnt/pd0/s/w/ir/cache/work/skia/include/c /mnt/pd0/s/w/ir/cache/work/skia/include/codec /mnt/pd0/s/w/ir/cache/work/skia/include/config /mnt/pd0/s/w/ir/cache/work/skia/include/core /mnt/pd0/s/w/ir/cache/work/skia/include/effects /mnt/pd0/s/w/ir/cache/work/skia/include/encode /mnt/pd0/s/w/ir/cache/work/skia/include/gpu /mnt/pd0/s/w/ir/cache/work/skia/include/atlastext /mnt/pd0/s/w/ir/cache/work/skia/include/pathops /mnt/pd0/s/w/ir/cache/work/skia/include/ports /mnt/pd0/s/w/ir/cache/work/skia/include/svg /mnt/pd0/s/w/ir/cache/work/skia/include/utils /mnt/pd0/s/w/ir/cache/work/skia/include/utils/mac /mnt/pd0/s/w/ir/cache/work/skia/include/atlastext
Traceback (most recent call last):
File "../../../gn/find_headers.py", line 32, in <module>
sources_json = json.loads(subprocess.check_output(gn_sources_cmd))
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Original change's description:
> find_headers.py to better find headers.
>
> The find_headers.py script claims to "recursively search each include
> directory for headers" but the recursive part has been left out.
>
> This changes find_headers to instead find all the sources which are in
> public include directories and list them with the shortest possible
> path. This removes the need for a blacklist and also handles includes in
> subdirectories of public include directories.
>
> Change-Id: Ib59256a2059d37d4459686c421923207ac7acf38
> Reviewed-on: https://skia-review.googlesource.com/129660
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Ben Wagner <bungeman@google.com>
TBR=egdaniel@google.com,mtklein@google.com,bungeman@google.com
Change-Id: I5cca85754f1b9fde7771ab0ed1bd8117ee96a970
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/130181
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index dd509c2..1f51566 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1014,9 +1014,7 @@
public_configs = [ ":skia.h_config" ]
skia_h = "$target_gen_dir/skia.h"
script = "gn/find_headers.py"
- args = [ rebase_path("//bin/gn") ] +
- [ rebase_path("//") ] +
- [ rebase_path(skia_h, root_build_dir) ] +
+ args = [ rebase_path(skia_h, root_build_dir) ] +
rebase_path(skia_public_includes)
depfile = "$skia_h.deps"
outputs = [
diff --git a/gn/core.gni b/gn/core.gni
index 19dbcf4..5aca52c 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -392,7 +392,6 @@
"$_include/core/SkData.h",
"$_include/core/SkDeferredDisplayListRecorder.h",
"$_include/core/SkDeque.h",
- "$_include/core/SkDocument.h",
"$_include/core/SkDrawable.h",
"$_include/core/SkDrawFilter.h",
"$_include/core/SkDrawLooper.h",
diff --git a/gn/find_headers.py b/gn/find_headers.py
index ed20647..2f20e1e 100755
--- a/gn/find_headers.py
+++ b/gn/find_headers.py
@@ -5,68 +5,43 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import collections
-import json
import os
-import subprocess
import sys
-# Finds all public sources in include directories then write them to skia.h.
+# We'll recursively search each include directory for headers,
+# then write them to skia.h with a small blacklist.
-# Also write skia.h.deps, which Ninja uses to track dependencies. It's the
+# 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.
-gn = sys.argv[1]
-absolute_source = sys.argv[2]
-skia_h = sys.argv[3]
-include_dirs = sys.argv[4:]
+skia_h = sys.argv[1]
+include_dirs = sys.argv[2:]
-absolute_source = os.path.normpath(absolute_source)
+blacklist = {
+ "GrGLConfig_chrome.h",
+ "SkFontMgr_fontconfig.h",
+}
-include_dirs = [os.path.join(os.path.normpath(include_dir), '')
- for include_dir in include_dirs]
-include_dirs.sort(key=len, reverse=True)
+headers = []
+for directory in include_dirs:
+ for f in os.listdir(directory):
+ if os.path.isfile(os.path.join(directory, f)):
+ if f.endswith('.h') and f not in blacklist:
+ headers.append(os.path.join(directory,f))
+headers.sort()
-# If skia ever uses 'public' that will need to be considered as well or instead.
-gn_sources_cmd = [gn, 'desc', '.', '--format=json', '*', 'sources']
-sources_json = json.loads(subprocess.check_output(gn_sources_cmd))
-sources = {os.path.join(absolute_source, os.path.normpath(source[2:]))
- for target in sources_json.itervalues()
- for source in target.get('sources', [])}
-
-Header = collections.namedtuple('Header', ['absolute', 'include'])
-headers = {}
-for source in sources:
- source_as_include = [source[len(include_dir):]
- for include_dir in include_dirs
- if source.startswith(include_dir)]
- if not source_as_include:
- continue
- statinfo = os.stat(source)
- key = str(statinfo.st_ino) + ':' + str(statinfo.st_dev)
- # On Windows os.stat st_ino is 0 until 3.3.4 and st_dev is 0 until 3.4.0.
- if key == '0:0':
- key = source
- include_path = source_as_include[0]
- if key not in headers or len(include_path) < len(headers[key].include):
- headers[key] = Header(source, include_path)
-
-headers = headers.values()
-headers.sort(key=lambda x: x.include)
-
-with open(skia_h, 'w') as f:
+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 header in headers:
- f.write('#include "' + header.include + '"\n')
+ for h in headers:
+ f.write('#include "' + os.path.basename(h) + '"\n')
f.write('#endif//skia_h_DEFINED\n')
-with open(skia_h + '.deps', 'w') as f:
+with open(skia_h + '.deps', "w") as f:
f.write(skia_h + ':')
- for header in headers:
- f.write(' ' + header.absolute)
- f.write(' build.ninja.d')
+ for h in headers:
+ f.write(' ' + h)
f.write('\n')
# Temporary: during development this file wrote skia.h.d, not skia.h.deps,