skia2/tools/fm/BUILD.bazel

44 lines
1.5 KiB
Python
Raw Normal View History

[bazel] Try adding cc_binary rules that use generated rules To make the atomic rules a bit easier to work with, in many of the folders, this adds in cc_library rules to group together the sources from that folder (and subfolders where prudent). We only needs sources because those atoms should have their headers as deps. One issue that was pointed out is that there is currently no way to restrict the inclusion of certain packages, a la, `gn check`. For example, there is no mechanism from stopping a dev from adding #include "modules/canvaskit/WasmCommon.h" to something in //src/core (except circular dependencies). We can probably address that using Bazel's visibility rules as needed: https://docs.bazel.build/versions/main/visibility.html https://docs.bazel.build/versions/main/be/functions.html#package_group It is recommended to look at this CL patchset by patchset. PS1: Update gazelle command to generate rules in more folders. PS2: A few changes to make generation work better. PS3: The result of running make generate in //bazel PS4: Adding the rules to build sksllex, the simplest binary I could find in the Skia repo. PS5: Adding the rules to build skdiff, a more complex binary. I tried a few approaches, but ended up gravitating back towards the layout where we have each folder/package group up the sources. I imagine at some point, we'll have skdiff depend on skia_core or something, which will have things like //src/core, //src/codecs, //src/pathops all bundled together. PS7: Added in the groupings of sources, similar to what we had earlier. I liked these for readability. These helped fix up the //:skia_core build, and by extension, the CanvasKit build. Change-Id: I3faa7c4e821c876b243617aacf0246efa524cbde Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/476219 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2021-11-30 13:15:24 +00:00
load("//bazel:macros.bzl", "generated_cc_atom")
generated_cc_atom(
name = "fm_src",
srcs = ["fm.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//gm:gm_hdr",
"//include/codec:SkCodec_hdr",
"//include/core:SkCanvas_hdr",
"//include/core:SkColorSpace_hdr",
"//include/core:SkGraphics_hdr",
"//include/core:SkPictureRecorder_hdr",
"//include/core:SkPicture_hdr",
"//include/docs:SkPDFDocument_hdr",
"//include/gpu:GrContextOptions_hdr",
"//include/gpu:GrDirectContext_hdr",
"//include/private:SkTHash_hdr",
"//modules/skottie/include:Skottie_hdr",
"//modules/skresources/include:SkResources_hdr",
"//modules/svg/include:SkSVGDOM_hdr",
"//modules/svg/include:SkSVGNode_hdr",
"//src/core:SkColorSpacePriv_hdr",
"//src/core:SkMD5_hdr",
"//src/core:SkOSFile_hdr",
"//src/core:SkTaskGroup_hdr",
"//src/gpu:GrDirectContextPriv_hdr",
"//src/gpu:GrGpu_hdr",
"//src/utils:SkOSPath_hdr",
[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 12:33:44 +00:00
"//tests:TestHarness_hdr",
[bazel] Try adding cc_binary rules that use generated rules To make the atomic rules a bit easier to work with, in many of the folders, this adds in cc_library rules to group together the sources from that folder (and subfolders where prudent). We only needs sources because those atoms should have their headers as deps. One issue that was pointed out is that there is currently no way to restrict the inclusion of certain packages, a la, `gn check`. For example, there is no mechanism from stopping a dev from adding #include "modules/canvaskit/WasmCommon.h" to something in //src/core (except circular dependencies). We can probably address that using Bazel's visibility rules as needed: https://docs.bazel.build/versions/main/visibility.html https://docs.bazel.build/versions/main/be/functions.html#package_group It is recommended to look at this CL patchset by patchset. PS1: Update gazelle command to generate rules in more folders. PS2: A few changes to make generation work better. PS3: The result of running make generate in //bazel PS4: Adding the rules to build sksllex, the simplest binary I could find in the Skia repo. PS5: Adding the rules to build skdiff, a more complex binary. I tried a few approaches, but ended up gravitating back towards the layout where we have each folder/package group up the sources. I imagine at some point, we'll have skdiff depend on skia_core or something, which will have things like //src/core, //src/codecs, //src/pathops all bundled together. PS7: Added in the groupings of sources, similar to what we had earlier. I liked these for readability. These helped fix up the //:skia_core build, and by extension, the CanvasKit build. Change-Id: I3faa7c4e821c876b243617aacf0246efa524cbde Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/476219 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2021-11-30 13:15:24 +00:00
"//tests:Test_hdr",
"//tools:AutoreleasePool_hdr",
"//tools:CrashHandler_hdr",
"//tools:HashAndEncode_hdr",
"//tools:ToolUtils_hdr",
"//tools/flags:CommandLineFlags_hdr",
"//tools/flags:CommonFlags_hdr",
"//tools/gpu:BackendSurfaceFactory_hdr",
"//tools/gpu:GrContextFactory_hdr",
"//tools/gpu:MemoryCache_hdr",
"//tools/trace:EventTracingPriv_hdr",
],
)