blob: f02ebc93ab07b1607267c649a4a28a922ebb8386 [file] [log] [blame]
Mike Klein89eda8a2016-11-02 09:14:55 -04001#!/usr/bin/env python
2#
3# Copyright 2016 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8import os
9import sys
10
11# We'll recursively search each include directory for headers,
12# then write them to skia.h with a small blacklist.
13
14# We'll also write skia.h.deps, which Ninja uses to track dependencies. It's the
15# very same mechanism Ninja uses to know which .h files affect which .cpp files.
16
17skia_h = sys.argv[1]
Greg Daniel50130e42017-04-12 13:29:50 -040018use_vulkan = eval(sys.argv[2])
19include_dirs = sys.argv[3:]
Mike Klein89eda8a2016-11-02 09:14:55 -040020
21blacklist = {
22 "GrGLConfig_chrome.h",
Mike Klein89eda8a2016-11-02 09:14:55 -040023 "SkFontMgr_fontconfig.h",
24}
25
26headers = []
27for directory in include_dirs:
28 for d, _, files in os.walk(directory):
29 for f in files:
Greg Daniel50130e42017-04-12 13:29:50 -040030 if not d.endswith('vk') or use_vulkan:
31 if f.endswith('.h') and f not in blacklist:
32 headers.append(os.path.join(d,f))
Mike Klein89eda8a2016-11-02 09:14:55 -040033headers.sort()
34
35with open(skia_h, "w") as f:
36 f.write('// skia.h generated by GN.\n')
37 f.write('#ifndef skia_h_DEFINED\n')
38 f.write('#define skia_h_DEFINED\n')
39 for h in headers:
40 f.write('#include "' + h + '"\n')
41 f.write('#endif//skia_h_DEFINED\n')
42
43with open(skia_h + '.deps', "w") as f:
44 f.write(skia_h + ':')
45 for h in headers:
46 f.write(' ' + h)
47 f.write('\n')
48
49# Temporary: during development this file wrote skia.h.d, not skia.h.deps,
50# and I think we have some bad versions of those files laying around.
51if os.path.exists(skia_h + '.d'):
52 os.remove(skia_h + '.d')