blob: 2f20e1e7d0fadfcba5c58ef34c6b8e12d75eed78 [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 Danielc819e662017-04-19 16:39:45 -040018include_dirs = sys.argv[2:]
Mike Klein89eda8a2016-11-02 09:14:55 -040019
20blacklist = {
21 "GrGLConfig_chrome.h",
Mike Klein89eda8a2016-11-02 09:14:55 -040022 "SkFontMgr_fontconfig.h",
23}
24
25headers = []
26for directory in include_dirs:
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000027 for f in os.listdir(directory):
28 if os.path.isfile(os.path.join(directory, f)):
Greg Danielc819e662017-04-19 16:39:45 -040029 if f.endswith('.h') and f not in blacklist:
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000030 headers.append(os.path.join(directory,f))
Mike Klein89eda8a2016-11-02 09:14:55 -040031headers.sort()
32
33with open(skia_h, "w") as f:
34 f.write('// skia.h generated by GN.\n')
35 f.write('#ifndef skia_h_DEFINED\n')
36 f.write('#define skia_h_DEFINED\n')
37 for h in headers:
Ben Wagner3f39bf82017-12-08 13:56:54 -050038 f.write('#include "' + os.path.basename(h) + '"\n')
Mike Klein89eda8a2016-11-02 09:14:55 -040039 f.write('#endif//skia_h_DEFINED\n')
40
41with open(skia_h + '.deps', "w") as f:
42 f.write(skia_h + ':')
43 for h in headers:
44 f.write(' ' + h)
45 f.write('\n')
46
47# Temporary: during development this file wrote skia.h.d, not skia.h.deps,
48# and I think we have some bad versions of those files laying around.
49if os.path.exists(skia_h + '.d'):
50 os.remove(skia_h + '.d')