aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/check-headers-self-sufficient
blob: 8e5ced47dd2935f47fd5c15e28afe772c6cd8721 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh

# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

cd "$(dirname "$0")/.."

compile_header() {
    # test each header for self-sufficiency and idempotency.
    printf '#include "%s"\n#include "%s"\n' "$1" "$1" | \
        c++ --std=c++11 \
        -Iinclude/core \
        -Iinclude/config \
        -Iinclude/android \
        -Iinclude/c \
        -Iinclude/codec \
        -Iinclude/effects \
        -Iinclude/gpu \
        -Iinclude/gpu/gl \
        -Iinclude/pathops \
        -Iinclude/ports \
        -Iinclude/private \
        -Iinclude/svg \
        -Iinclude/utils \
        -Iinclude/utils/mac \
        -Iinclude/views \
        -Iinclude/xml \
        -Isrc/codec \
        -Isrc/core \
        -Isrc/effects \
        -Isrc/effects/gradients \
        -Isrc/fonts \
        -Isrc/gpu \
        -Isrc/image \
        -Isrc/images \
        -Isrc/lazy \
        -Isrc/opts \
        -Isrc/pathops \
        -Isrc/ports \
        -Isrc/sfnt \
        -Isrc/sksl \
        -Isrc/utils \
        -Isrc/utils/win \
        -Igm \
        -Itests \
        -Itools \
        -Itools/debugger \
        -Itools/flags \
        -Itools/gpu \
        -Itools/timer \
        -Ithird_party/etc1 \
        -Ithird_party/externals/jsoncpp/include \
        -Ithird_party/externals/sfntly/cpp/src \
        -Ithird_party/externals/zlib \
        -Ithird_party/gif \
        -o /dev/null -c -x c++ -
}

FAIL=0
for header in $(git ls-files | grep '\.h$'); do
    # The following headers don't pass this test for one reason or another.
    case $header in
        */osmesa_wrapper.h)                   continue;;
        debugger/QT/*)                        continue;;
        example/*)                            continue;;
        experimental/*)                       continue;;
        include/config/*)                     continue;;
        include/core/SkPostConfig.h)          continue;;
        include/gpu/vk/*)                     continue;;
        include/ports/SkFontMgr_android.h)    continue;;
        include/ports/SkFontMgr_fontconfig.h) continue;;
        include/ports/SkTypeface_win.h)       continue;;
        include/private/*_impl.h)             continue;;
        include/utils/mac/SkCGUtils.h)        continue;;
        include/views/SkOSWindow_*.h)         continue;;
        src/c/sk_c_from_to.h)                 continue;;
        src/codec/SkJpegDecoderMgr.h)         continue;;
        src/codec/SkJpegUtility.h)            continue;;
        src/core/*Template.h)                 continue;;
        src/core/SkBitmapProcState_*.h)       continue;;
        src/core/SkFDot6Constants.h)          continue;;
        src/core/SkLinearBitmapPipeline.h)    continue;;
        src/core/SkLinearBitmapPipeline_*.h)  continue;;
        src/core/SkUnPreMultiplyPriv.h)       continue;;
        src/gpu/vk/*.h)                       continue;;
        src/images/SkJPEGWriteUtility.h)      continue;;
        src/opts/*_SSE2.h)                    continue;;
        src/opts/*_SSSE3.h)                   continue;;
        src/opts/*_neon.h)                    continue;;
        src/opts/*_sse.h)                     continue;;
        src/opts/Sk4px_*.h)                   continue;;
        src/ports/*)                          continue;;
        src/utils/*_win.h)                    continue;;
        src/utils/win/*)                      continue;;
        src/views/*)                          continue;;
        third_party/*)                        continue;;
        tools/fiddle/*)                       continue;;
        tools/viewer/*)                       continue;;
    esac
    if ! compile_header "$header"; then
        echo "FAILURE: $header"
        FAIL=1
    fi
done
exit $FAIL