skia2/tools/gpu
Kevin Lubick e253cc3e55 [bazel] Use toolchain features to opt files into being IWYU compliant.
PS1 regenerates the Bazel files.

It is recommended to review this CL with a diff from PS1.

Example output when a file does not pass the test:
    tools/sk_app/CommandSet.h should add these lines:
    #include "include/core/SkTypes.h"
    #include "include/private/SkTArray.h"
    #include "tools/skui/InputState.h"
    #include "tools/skui/Key.h"
    #include "tools/skui/ModifierKey.h"
    namespace sk_app { class Window; }

    tools/sk_app/CommandSet.h should remove these lines:
    - #include "tools/sk_app/Window.h"

    The full include-list for tools/sk_app/CommandSet.h:
    #include "include/core/SkString.h"
    #include "include/core/SkTypes.h"
    #include "include/private/SkTArray.h"
    #include "tools/skui/InputState.h"
    #include "tools/skui/Key.h"
    #include "tools/skui/ModifierKey.h"
    #include <functional>
    #include <vector>
    class SkCanvas;
    namespace sk_app { class Window; }
    ---

This makes use of Bazel's toolchain features
https://bazel.build/docs/cc-toolchain-config-reference#features
to allow us to configure compiler flags when compiling
individual files. This analysis is off by default, and can
be turned on with --features skia_enforce_iwyu. When enabled,
it will only be run for files that have opted in.
Example:
    bazelisk build //example:hello_world_gl --config=clang \
       --sandbox_base=/dev/shm --features skia_enforce_iwyu

There are two ways to opt files in:
 - Add enforce_iwyu = True to a generated_cc_atom rule
 - Add enforce_iwyu_on_package() to a BUILD.bazel file
   (which enforces IWYU for all rules in that file)

Note that Bazel does not propagate features to dependencies
or dependents, so trying to enable the feature on cc_library
or cc_executable targets will only impact any files listed in
srcs or hdrs, not deps. This may be counter-intuitive when
compared to things like defines.

IWYU supports a mapping file, which we supply to help properly
handle things system headers (//toolchain/IWYU_mapping.imp)

Suggested Review Order:
 - toolchain/build_toolchain.bzl to see how we get the IWYU
   binaries into the toolchain
 - toolchain/BUILD.bazel and toolchain/IWYU_mapping.imp
   to see how the mapping file is made available for
   all compile steps
 - toolchain/clang_toolchain_config.bzl, where we define the
   skia_enforce_iwyu feature to turn on any verification at
   all and skia_opt_file_into_iwyu to enable the check for
   specific files using a define.
 - toolchain/clang_trampoline.sh, which is the toolchain is
   configured to call instead of clang directly (see line 83
   of clang_toolchain_config.bzl). This bash script used to
   just forward all arguments directly onto clang. Now it
   inspects them and either calls clang directly (if
   it does not find the define in the arguments or we are
   linking [bazel sometimes links with clang instead of ld])
   or calls clang and then include-what-you-use. In all cases,
   the trampoline sends the arguments to clang and IWYU
   unchanged).
 - //tools/sk_app/... to see enforcement enabled (and fixed)
   for select files, as an example of that method.
 - //experimental/bazel_test/... to see enforcement enabled
   for all rules in a BUILD.bazel file.
 - all other files.

Change-Id: I60a2ea9d5dc9955b6a8f166bd449de9e2b81a233
Bug: skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/519776
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-16 13:09:46 +00:00
..
d3d [bazel] Try adding cc_binary rules that use generated rules 2021-11-30 18:18:53 +00:00
dawn [bazel] Support Vulkan 2022-03-08 21:21:17 +00:00
gl Convert 0 and NULL to nullptr. 2022-02-09 14:20:57 +00:00
mock [bazel] Try adding cc_binary rules that use generated rules 2021-11-30 18:18:53 +00:00
mtl [bazel] Try adding cc_binary rules that use generated rules 2021-11-30 18:18:53 +00:00
vk [bazel] Support Vulkan 2022-03-08 21:21:17 +00:00
BackendSurfaceFactory.cpp Revert "Revert "Reland "asyncRescaleAndRead supports unpremul results on GPU""" 2021-01-22 14:21:01 +00:00
BackendSurfaceFactory.h [includes] Prepare to remove SkColor<->SkImageInfo 2022-03-09 18:40:44 +00:00
BackendTextureImageFactory.cpp Take origin when creating/updating backend texture using pixmaps. 2020-12-07 20:31:10 +00:00
BackendTextureImageFactory.h [includes] Prepare to remove SkColor<->SkImageInfo 2022-03-09 18:40:44 +00:00
BUILD.bazel [bazel] Use toolchain features to opt files into being IWYU compliant. 2022-03-16 13:09:46 +00:00
FenceSync.h rewrite includes to not need so much -Ifoo 2019-04-24 16:27:11 +00:00
FlushFinishTracker.cpp Update additional tools to take a GrDirectContext 2020-07-01 20:42:25 +00:00
FlushFinishTracker.h Update additional tools to take a GrDirectContext 2020-07-01 20:42:25 +00:00
GpuTimer.h Replace skstd::exchange with std::exchange 2020-04-30 11:14:20 +00:00
GrContextFactory.cpp Reland "[fuzzer] Remove GL from (now-Vulkan) build" 2022-02-03 18:07:47 +00:00
GrContextFactory.h Reland "[fuzzer] Remove GL from (now-Vulkan) build" 2022-02-03 18:07:47 +00:00
GrTest.cpp Reland "drawVertices in GPU backend uses drawVustomMesh implementation." 2022-01-10 23:06:15 +00:00
ManagedBackendTexture.cpp Bitmap.asImage() 2020-12-23 15:54:57 +00:00
ManagedBackendTexture.h Use the ManagedBackendTexture helper in fiddle_main 2020-12-08 17:39:12 +00:00
MemoryCache.cpp Remove SkSL::String class. 2022-02-03 14:59:16 +00:00
MemoryCache.h Reland "Redesign program key construction" 2021-03-03 17:44:00 +00:00
ProxyUtils.cpp [graphite] Add isGaneshBacked and isGraphiteBacked 2022-03-02 23:35:16 +00:00
ProxyUtils.h Store the correct number of samples in GrProgramInfo 2021-08-26 17:24:47 +00:00
TestContext.cpp Enable ClangTidy check llvm-namespace-comment. 2020-08-06 19:07:52 +00:00
TestContext.h Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'. 2020-09-03 03:41:26 +00:00
TestOps.cpp [graphite] Replace GrSLType with SkSLType 2022-01-26 17:30:12 +00:00
TestOps.h Switch GrMeshDrawOp::Target to be the stand alone GrMeshDrawTarget class 2021-06-17 19:57:43 +00:00
YUVUtils.cpp YUVUtils function for splitting image into yuva planes. 2021-05-24 14:10:39 +00:00
YUVUtils.h YUVUtils function for splitting image into yuva planes. 2021-05-24 14:10:39 +00:00