[bazel] Test enforcement of IWYU on SkSVG backend.

This will use the recently added Bazel toolchain feature
to enforce proper includes for all files in //src/svg/...

In the future, I envision a CI/CQ job that will run
bazel build with a few different configurations and the
--feature skia_enforce_iwyu on to make sure we don't
regress.

Change-Id: Ibb9f816ab626415c11bd2b9b74c503297c4b0723
Bug: skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521036
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
Kevin Lubick 2022-03-15 14:18:53 -04:00 committed by SkCQ
parent e253cc3e55
commit 9301fe3779
7 changed files with 125 additions and 16 deletions

View File

@ -17,9 +17,19 @@ gazelle_update_repo:
# Run this target to test all known working Bazel builds
known_good_builds:
bazelisk build //experimental/bazel_test/... --config=clang --sandbox_base=/dev/shm --features skia_enforce_iwyu
bazelisk build //experimental/bazel_test/... --config=clang --sandbox_base=/dev/shm
bazelisk run //experimental/bazel_test:bazel_test_exe --config=clang --sandbox_base=/dev/shm
bazelisk build //:skia_core --config=clang --sandbox_base=/dev/shm
bazelisk build //src/sksl/lex:sksllex --config=clang --sandbox_base=/dev/shm
bazelisk build //tools/skdiff --config=clang --sandbox_base=/dev/shm
bazelisk build //example:hello_world_gl --config=clang --sandbox_base=/dev/shm
# Test the enforcement of include what you use
bazelisk build //experimental/bazel_test/... --config=clang --sandbox_base=/dev/shm \
--features skia_enforce_iwyu
# Both with and without a GPU backend should be error free (i.e. IWYU should let us
# conditionally import things.
bazelisk build //src/svg/... --config=clang --sandbox_base=/dev/shm \
--features skia_enforce_iwyu --gpu_backend=gl_backend --include_decoder=jpeg_decode_codec
bazelisk build //src/svg/... --config=clang --sandbox_base=/dev/shm \
--features skia_enforce_iwyu

View File

@ -4,5 +4,5 @@ generated_cc_atom(
name = "SkSVGCanvas_hdr",
hdrs = ["SkSVGCanvas.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkCanvas_hdr"],
deps = ["//include/core:SkTypes_hdr"],
)

View File

@ -8,9 +8,13 @@
#ifndef SkSVGCanvas_DEFINED
#define SkSVGCanvas_DEFINED
#include "include/core/SkCanvas.h"
#include "include/core/SkTypes.h"
#include <memory>
class SkCanvas;
class SkWStream;
struct SkRect;
class SK_API SkSVGCanvas {
public:

View File

@ -1,4 +1,6 @@
load("//bazel:macros.bzl", "generated_cc_atom")
load("//bazel:macros.bzl", "enforce_iwyu_on_package", "generated_cc_atom")
enforce_iwyu_on_package()
generated_cc_atom(
name = "SkSVGCanvas_src",
@ -6,6 +8,10 @@ generated_cc_atom(
visibility = ["//:__subpackages__"],
deps = [
":SkSVGDevice_hdr",
"//include/core:SkCanvas_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkRefCnt_hdr",
"//include/private:SkTo_hdr",
"//include/svg:SkSVGCanvas_hdr",
"//src/xml:SkXMLWriter_hdr",
],
@ -16,8 +22,10 @@ generated_cc_atom(
hdrs = ["SkSVGDevice.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkCanvas_hdr",
"//include/core:SkRefCnt_hdr",
"//include/core:SkTypes_hdr",
"//include/private:SkTArray_hdr",
"//include/private:SkTemplates_hdr",
"//include/utils:SkParsePath_hdr",
"//src/core:SkClipStackDevice_hdr",
],
@ -31,27 +39,49 @@ generated_cc_atom(
":SkSVGDevice_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkBlendMode_hdr",
"//include/core:SkClipOp_hdr",
"//include/core:SkColorFilter_hdr",
"//include/core:SkColor_hdr",
"//include/core:SkCustomMesh_hdr",
"//include/core:SkData_hdr",
"//include/core:SkEncodedImageFormat_hdr",
"//include/core:SkFontStyle_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkImageEncoder_hdr",
"//include/core:SkImageInfo_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkMatrix_hdr",
"//include/core:SkPaint_hdr",
"//include/core:SkPathBuilder_hdr",
"//include/core:SkPathEffect_hdr",
"//include/core:SkPathTypes_hdr",
"//include/core:SkPath_hdr",
"//include/core:SkPoint_hdr",
"//include/core:SkRRect_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkScalar_hdr",
"//include/core:SkShader_hdr",
"//include/core:SkSize_hdr",
"//include/core:SkSpan_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkString_hdr",
"//include/core:SkSurfaceProps_hdr",
"//include/core:SkTileMode_hdr",
"//include/core:SkTypeface_hdr",
"//include/private:SkChecksum_hdr",
"//include/private:SkNoncopyable_hdr",
"//include/private:SkTHash_hdr",
"//include/private:SkTPin_hdr",
"//include/private:SkTemplates_hdr",
"//include/private:SkTo_hdr",
"//include/svg:SkSVGCanvas_hdr",
"//include/utils:SkBase64_hdr",
"//src/codec:SkJpegCodec_hdr",
"//src/core:SkAnnotationKeys_hdr",
"//src/core:SkClipStack_hdr",
"//src/core:SkDraw_hdr",
"//src/core:SkDevice_hdr",
"//src/core:SkFontPriv_hdr",
"//src/core:SkUtils_hdr",
"//src/core:SkGlyphRun_hdr",
"//src/core:SkTLazy_hdr",
"//src/image:SkImage_Base_hdr",
"//src/shaders:SkShaderBase_hdr",
"//src/xml:SkXMLWriter_hdr",

View File

@ -6,9 +6,16 @@
*/
#include "include/svg/SkSVGCanvas.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/private/SkTo.h"
#include "src/svg/SkSVGDevice.h"
#include "src/xml/SkXMLWriter.h"
#include <utility>
std::unique_ptr<SkCanvas> SkSVGCanvas::Make(const SkRect& bounds, SkWStream* writer,
uint32_t flags) {
// TODO: pass full bounds to the device

View File

@ -7,35 +7,68 @@
#include "src/svg/SkSVGDevice.h"
#include <memory>
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkClipOp.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkData.h"
#include "include/core/SkEncodedImageFormat.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontStyle.h"
#include "include/core/SkImage.h"
#include "include/core/SkImageEncoder.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkSpan.h"
#include "include/core/SkStream.h"
#include "include/core/SkString.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypeface.h"
#include "include/private/SkChecksum.h"
#include "include/private/SkNoncopyable.h"
#include "include/private/SkTHash.h"
#include "include/private/SkTPin.h"
#include "include/private/SkTemplates.h"
#include "include/private/SkTo.h"
#include "include/svg/SkSVGCanvas.h"
#include "include/utils/SkBase64.h"
#include "src/codec/SkJpegCodec.h"
#include "src/core/SkAnnotationKeys.h"
#include "src/core/SkClipStack.h"
#include "src/core/SkDraw.h"
#include "src/core/SkDevice.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkUtils.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkTLazy.h"
#include "src/image/SkImage_Base.h"
#include "src/shaders/SkShaderBase.h"
#include "src/xml/SkXMLWriter.h"
#include <string>
#include <memory>
#include <utility>
class SkBlender;
class SkVertices;
struct SkSamplingOptions;
#ifdef SK_ENABLE_SKSL
#include "include/core/SkCustomMesh.h"
#endif
#ifdef SK_CODEC_DECODES_JPEG
#include "src/codec/SkJpegCodec.h"
#endif
namespace {
static SkString svg_color(SkColor color) {
@ -1106,6 +1139,8 @@ void SkSVGDevice::drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPain
// todo
}
#ifdef SK_ENABLE_SKSL
void SkSVGDevice::drawCustomMesh(SkCustomMesh, sk_sp<SkBlender>, const SkPaint&) {
// todo
}
#endif

View File

@ -8,12 +8,34 @@
#ifndef SkSVGDevice_DEFINED
#define SkSVGDevice_DEFINED
#include "include/core/SkCanvas.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypes.h"
#include "include/private/SkTArray.h"
#include "include/private/SkTemplates.h"
#include "include/utils/SkParsePath.h"
#include "src/core/SkClipStackDevice.h"
#include <memory>
class SkBaseDevice;
class SkBitmap;
class SkBlender;
class SkClipStack;
class SkData;
class SkGlyphRunList;
class SkImage;
class SkPaint;
class SkPath;
class SkRRect;
class SkVertices;
class SkXMLWriter;
struct SkISize;
struct SkPoint;
struct SkRect;
struct SkSamplingOptions;
#ifdef SK_ENABLE_SKSL
struct SkCustomMesh;
#endif
class SkSVGDevice final : public SkClipStackDevice {
public:
@ -37,8 +59,9 @@ protected:
void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override;
void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&) override;
#ifdef SK_ENABLE_SKSL
void drawCustomMesh(SkCustomMesh, sk_sp<SkBlender>, const SkPaint&) override;
#endif
private:
SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>, uint32_t);
~SkSVGDevice() override;