Mike Klein | 89eda8a | 2016-11-02 09:14:55 -0400 | [diff] [blame] | 1 | #!/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 | |
| 8 | import os |
| 9 | import 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 | |
| 17 | skia_h = sys.argv[1] |
Greg Daniel | c819e66 | 2017-04-19 16:39:45 -0400 | [diff] [blame] | 18 | include_dirs = sys.argv[2:] |
Mike Klein | 89eda8a | 2016-11-02 09:14:55 -0400 | [diff] [blame] | 19 | |
| 20 | blacklist = { |
| 21 | "GrGLConfig_chrome.h", |
Mike Klein | 89eda8a | 2016-11-02 09:14:55 -0400 | [diff] [blame] | 22 | "SkFontMgr_fontconfig.h", |
| 23 | } |
| 24 | |
| 25 | headers = [] |
| 26 | for directory in include_dirs: |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame^] | 27 | for d, _, files in os.walk(directory): |
| 28 | for f in files: |
Greg Daniel | c819e66 | 2017-04-19 16:39:45 -0400 | [diff] [blame] | 29 | if f.endswith('.h') and f not in blacklist: |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame^] | 30 | headers.append(os.path.join(d,f)) |
Mike Klein | 89eda8a | 2016-11-02 09:14:55 -0400 | [diff] [blame] | 31 | headers.sort() |
| 32 | |
| 33 | with 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: |
| 38 | f.write('#include "' + h + '"\n') |
| 39 | f.write('#endif//skia_h_DEFINED\n') |
| 40 | |
| 41 | with 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. |
| 49 | if os.path.exists(skia_h + '.d'): |
| 50 | os.remove(skia_h + '.d') |