Make header files idempotent; script to check

Change-Id: I960ded854e6bc7cdee029a7393cac2a686c41754
Reviewed-on: https://skia-review.googlesource.com/8308
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Hal Canary 2017-02-10 09:06:38 -05:00 committed by Skia Commit-Bot
parent 9119de64aa
commit 03a7f5fe2d
20 changed files with 168 additions and 1 deletions

View File

@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
#ifndef SkFrontBufferedStream_DEFINED
#define SkFrontBufferedStream_DEFINED
#include "SkTypes.h"
class SkStream;
@ -35,3 +38,4 @@ public:
*/
static SkStreamRewindable* Create(SkStream* stream, size_t minBufferSize);
};
#endif // SkFrontBufferedStream_DEFINED

View File

@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
#ifndef DecodeFile_DEFINED
#define DecodeFile_DEFINED
#include "SkBitmap.h"
#include "SkCodec.h"
#include "SkData.h"
@ -36,3 +39,4 @@ static inline sk_sp<SkImage> decode_file(const char filename[]) {
sk_sp<SkData> data(SkData::MakeFromFileName(filename));
return data ? SkImage::MakeFromEncoded(data) : nullptr;
}
#endif // DecodeFile_DEFINED

View File

@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
#ifndef SkBitmapRegionCodec_DEFINED
#define SkBitmapRegionCodec_DEFINED
#include "SkBitmap.h"
#include "SkBitmapRegionDecoder.h"
#include "SkAndroidCodec.h"
@ -35,3 +38,4 @@ private:
typedef SkBitmapRegionDecoder INHERITED;
};
#endif // SkBitmapRegionCodec_DEFINED

View File

@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
#ifndef SkBmpMaskCodec_DEFINED
#define SkBmpMaskCodec_DEFINED
#include "SkBmpCodec.h"
#include "SkImageInfo.h"
#include "SkMaskSwizzler.h"
@ -58,3 +61,4 @@ private:
typedef SkBmpCodec INHERITED;
};
#endif // SkBmpMaskCodec_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBmpRLECodec_DEFINED
#define SkBmpRLECodec_DEFINED
#include "SkBmpCodec.h"
#include "SkColorTable.h"
@ -114,3 +116,4 @@ private:
typedef SkBmpCodec INHERITED;
};
#endif // SkBmpRLECodec_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBmpStandardCodec_DEFINED
#define SkBmpStandardCodec_DEFINED
#include "SkBmpCodec.h"
#include "SkColorTable.h"
@ -98,3 +100,4 @@ private:
typedef SkBmpCodec INHERITED;
};
#endif // SkBmpStandardCodec_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkCodecImageGenerator_DEFINED
#define SkCodecImageGenerator_DEFINED
#include "SkCodec.h"
#include "SkColorTable.h"
@ -47,3 +49,4 @@ private:
typedef SkImageGenerator INHERITED;
};
#endif // SkCodecImageGenerator_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkGifCodec_DEFINED
#define SkGifCodec_DEFINED
#include "SkCodec.h"
#include "SkCodecAnimation.h"
@ -152,3 +154,4 @@ private:
typedef SkCodec INHERITED;
};
#endif // SkGifCodec_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkIcoCodec_DEFINED
#define SkIcoCodec_DEFINED
#include "SkCodec.h"
#include "SkImageInfo.h"
@ -99,3 +101,4 @@ private:
typedef SkCodec INHERITED;
};
#endif // SkIcoCodec_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPngCodec_DEFINED
#define SkPngCodec_DEFINED
#include "SkCodec.h"
#include "SkColorSpaceXform.h"
@ -138,3 +140,4 @@ private:
typedef SkCodec INHERITED;
};
#endif // SkPngCodec_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkColorSpacePriv_DEFINED
#define SkColorSpacePriv_DEFINED
#include <math.h>
@ -192,3 +194,4 @@ static inline bool named_to_parametric(SkColorSpaceTransferFn* coeffs,
return false;
}
}
#endif // SkColorSpacePriv_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPictureCommon_DEFINED
#define SkPictureCommon_DEFINED
// Some shared code used by both SkBigPicture and SkMiniPicture.
// SkTextHunter -- SkRecord visitor that returns true when the op draws text.
@ -138,3 +140,4 @@ struct SkPathCounter {
int fNumSlowPathsAndDashEffects;
};
#endif // SkPictureCommon_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkRecordedDrawable_DEFINED
#define SkRecordedDrawable_DEFINED
#include "SkBBoxHierarchy.h"
#include "SkDrawable.h"
@ -39,3 +41,4 @@ private:
std::unique_ptr<SkDrawableList> fDrawableList;
const SkRect fBounds;
};
#endif // SkRecordedDrawable_DEFINED

View File

@ -1,6 +1,8 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SkTraceEventCommon_DEFINED
#define SkTraceEventCommon_DEFINED
// This header file defines the set of trace_event macros without specifying
// how the events actually get collected and stored. If you need to expose trace
@ -1037,3 +1039,4 @@
#define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g')
#define TRACE_EVENT_SCOPE_NAME_PROCESS ('p')
#define TRACE_EVENT_SCOPE_NAME_THREAD ('t')
#endif // SkTraceEventCommon_DEFINED

View File

@ -4,7 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkEmbossMask_Table_DEFINED
#define SkEmbossMask_Table_DEFINED
#include "SkTypes.h"
@ -1035,3 +1036,4 @@ static const uint16_t gInvSqrtTable[128 * 128] = {
0x00C0, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 0x00B7, 0x00B6
};
#define kDeltaUsedToBuildTable 32
#endif // SkEmbossMask_Table_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef transform_scanline_DEFINED
#define transform_scanline_DEFINED
/**
* Functions to transform scanlines between packed-pixel formats.
@ -271,3 +273,4 @@ static inline void transform_scanline_F16_premul_to_8888(char* SK_RESTRICT dst,
p.append(SkRasterPipeline::store_8888, (void**) &dst);
p.run(0, width);
}
#endif // transform_scanline_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef CodecPriv_DEFINED
#define CodecPriv_DEFINED
#include "SkBitmap.h"
#include "SkCodec.h"
@ -32,3 +34,4 @@ inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) {
bm->rowBytes(), nullptr, colorPtr, colorCountPtr);
return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput;
}
#endif // CodecPriv_DEFINED

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef PathOpsTSectDebug_DEFINED
#define PathOpsTSectDebug_DEFINED
#include "SkPathOpsTSect.h"
@ -219,3 +221,4 @@ void SkTSpan<TCurve, OppCurve>::dumpID() const {
SkDebugf("%c", cE);
}
}
#endif // PathOpsTSectDebug_DEFINED

View File

@ -0,0 +1,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

View File

@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef UrlHandler_DEFINED
#define UrlHandler_DEFINED
#include "SkColor.h"
@ -162,3 +164,4 @@ public:
const char* upload_data, size_t* upload_data_size) override;
};
#endif // UrlHandler_DEFINED