skia2/tools/BUILD.bazel

694 lines
19 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")
[canvaskit] Add Freetype/Fonts to Bazel Build This re-works src/ports/BUILD.bazel to work like our other BUILD files, i.e. one rule "srcs" that brings in the necessary private filegroups. To work around an abort with LLVM [1], we have to go back to an earlier version of emscripten (temporarily?). Future work should look at using transitions [2] to allow various executables (e.g. CanvasKit, DM) to set their own set of Bazel flags, w/o the build invokers having to specify them. These transitions might be able to handle more complex cases that we currently use if statements in GN to deal with. The Freetype build rule was created by taking the BUILD.gn rule, adding in all the sources listed there and then playing compile-whack-a-mole to add in all the headers and included .c files. Suggested Review Order: - third_party/BUILD.bazel to see freetype build rules - bazel/common_config_settings/ to see treatment of fontmgr like codecs (many possible) and fontmgr_factory (only one). - src/ports/BUILD.bazel - BUILD.bazel - modules/canvaskit/BUILD.bazel. Take note of the gen_rule that calls tools/embed_resources.py to produce the .cpp file containing the embedded font data. - Everything else. [1] https://github.com/emscripten-core/emscripten/issues/15528 [2] https://github.com/bazelbuild/examples/tree/main/rules/starlark_configurations/cc_binary_selectable_copts Bug: skia:12541 Change-Id: I08dab82a901d80507007b354ca20cbfad2c2388f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/471636 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2021-11-16 19:09:44 +00:00
load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "embed_resources",
srcs = ["embed_resources.py"],
[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
visibility = ["//:__subpackages__"],
)
[bazel] Compile gms for wasm and WebGL PS 1 is re-generating existing BUILD.bazel files PS 2 is generating BUILD.bazel files for tests/gms PS 3+ makes modifications to build all of the gms and tests. It is recommended to view this CL with just a diff between PS 2 and the end, due to the large amount of generated changes in PS 1 and 2. We make a filegroup for the gms and tests because they need to be compiled as one large blob in order for the registries to work. Maybe in the future we will break these up, but at least for WASM/JS, the overhead of starting a browser for each new test would likely grind things to a halt, so we just group them all together for now. It's also the most similar to what we currently do. In gm/BUILD.bazel and tests/BUILD.bazel, we add a cc_library that encapsulates all of the deps of the tests, so we can easily include that the build. These were discovered via trial and error, not anything automatic or systematic. The is_skia_dev_build config_setting is very similar to the GN equivalent from which it was based. The list of gms and tests to skip (e.g. which are incompatible with WASM) was determined by building the wasm bundle: modules/canvaskit$ make bazel_gms_release tools/run-wasm-gm-tests$ make run_local_debug # Don't forget to click the button on the screen after the # browser loads This way of invoking the tests will be replace soon with `bazel test <something>`. As such, I didn't bother fully documenting the current way. Suggested review order: - modules/canvaskit/BUILD.bazel taking note that we always use profiling-funcs to make the stacktraces human readable. - gm/BUILD.bazel and tests/BUILD.bazel to see the lists of gms/tests. Notice the tests are roughly partitioned because we don't support things like vulkan/PDF in the wasm build and we will want a way to not build certain tests for certain configurations - tools/* noting some of the cc_libraries added to make dependencies easier to add when needed. - All other files. Change-Id: I43059cd93c28af1c4c12b93d6ebd9c46a12d381f Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506256 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-02-09 18:14:25 +00:00
cc_library(
name = "hash_and_encode",
testonly = True,
hdrs = [
":HashAndEncode_hdr",
],
visibility = ["//:__subpackages__"],
deps = [
":HashAndEncode_src",
"//tools/flags:CommandLineFlags_src",
],
)
cc_library(
name = "resource_factory",
testonly = True,
hdrs = [
":ResourceFactory_hdr",
],
visibility = ["//:__subpackages__"],
deps = [
":Resources_src",
],
)
[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
generated_cc_atom(
name = "AndroidSkDebugToStdOut_src",
srcs = ["AndroidSkDebugToStdOut.cpp"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkTypes_hdr"],
)
generated_cc_atom(
name = "AutoreleasePool_hdr",
hdrs = ["AutoreleasePool.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "CrashHandler_hdr",
hdrs = ["CrashHandler.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "CrashHandler_src",
srcs = ["CrashHandler.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":CrashHandler_hdr",
"//base:config_hdr",
"//base:process_state_hdr",
"//include/private:SkMalloc_hdr",
"//src/core:SkLeanWindows_hdr",
],
)
generated_cc_atom(
name = "DDLPromiseImageHelper_hdr",
hdrs = ["DDLPromiseImageHelper.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkBitmap_hdr",
"//include/core:SkDeferredDisplayListRecorder_hdr",
"//include/core:SkPromiseImageTexture_hdr",
"//include/core:SkRefCnt_hdr",
"//include/core:SkYUVAPixmaps_hdr",
"//include/gpu:GrBackendSurface_hdr",
"//include/private:SkTArray_hdr",
"//src/core:SkCachedData_hdr",
"//src/core:SkTLazy_hdr",
],
)
generated_cc_atom(
name = "DDLPromiseImageHelper_src",
srcs = ["DDLPromiseImageHelper.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":DDLPromiseImageHelper_hdr",
"//include/core:SkDeferredDisplayListRecorder_hdr",
"//include/core:SkPicture_hdr",
"//include/core:SkSerialProcs_hdr",
"//include/gpu:GrDirectContext_hdr",
"//include/gpu:GrYUVABackendTextures_hdr",
"//src/codec:SkCodecImageGenerator_hdr",
"//src/core:SkCachedData_hdr",
"//src/core:SkMipmap_hdr",
"//src/core:SkTaskGroup_hdr",
"//src/gpu/ganesh:GrDirectContextPriv_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
"//src/image:SkImage_Base_hdr",
"//src/image:SkImage_GpuYUVA_hdr",
],
)
generated_cc_atom(
name = "DDLTileHelper_hdr",
hdrs = ["DDLTileHelper.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkDeferredDisplayList_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkRefCnt_hdr",
"//include/core:SkSpan_hdr",
"//include/core:SkSurfaceCharacterization_hdr",
],
)
generated_cc_atom(
name = "DDLTileHelper_src",
srcs = ["DDLTileHelper.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":DDLPromiseImageHelper_hdr",
":DDLTileHelper_hdr",
"//include/core:SkCanvas_hdr",
"//include/core:SkDeferredDisplayListRecorder_hdr",
"//include/core:SkPicture_hdr",
"//include/core:SkSurfaceCharacterization_hdr",
"//include/core:SkSurface_hdr",
"//include/gpu:GrDirectContext_hdr",
"//src/core:SkDeferredDisplayListPriv_hdr",
"//src/core:SkTaskGroup_hdr",
"//src/gpu/ganesh:GrDirectContextPriv_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
"//src/image:SkImage_Gpu_hdr",
],
)
generated_cc_atom(
name = "HashAndEncode_hdr",
hdrs = ["HashAndEncode.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkBitmap_hdr",
"//include/core:SkStream_hdr",
"//tools/flags:CommandLineFlags_hdr",
],
)
generated_cc_atom(
name = "HashAndEncode_src",
srcs = ["HashAndEncode.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":HashAndEncode_hdr",
"//include/core:SkColorSpace_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
"//include/core:SkICC_hdr",
"//include/core:SkString_hdr",
"//include/third_party/skcms:skcms_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
"//third_party:libpng",
],
)
generated_cc_atom(
name = "LsanSuppressions_src",
srcs = ["LsanSuppressions.cpp"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkTypes_hdr"],
)
generated_cc_atom(
name = "MSKPPlayer_hdr",
hdrs = ["MSKPPlayer.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkRefCnt_hdr",
"//include/core:SkSize_hdr",
],
)
generated_cc_atom(
name = "MSKPPlayer_src",
srcs = ["MSKPPlayer.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":MSKPPlayer_hdr",
":SkSharingProc_hdr",
"//include/core:SkCanvasVirtualEnforcer_hdr",
"//include/core:SkCanvas_hdr",
"//include/core:SkPictureRecorder_hdr",
"//include/core:SkPicture_hdr",
"//include/core:SkSurface_hdr",
"//include/gpu:GrDirectContext_hdr",
"//include/private:SkTArray_hdr",
"//include/utils:SkNoDrawCanvas_hdr",
"//src/core:SkCanvasPriv_hdr",
"//src/core:SkTLazy_hdr",
"//src/utils:SkMultiPictureDocument_hdr",
],
)
generated_cc_atom(
name = "OverwriteLine_hdr",
hdrs = ["OverwriteLine.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "ProcStats_hdr",
hdrs = ["ProcStats.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "ProcStats_src",
srcs = ["ProcStats.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":ProcStats_hdr",
"//include/core:SkTypes_hdr",
],
)
generated_cc_atom(
name = "Registry_hdr",
hdrs = ["Registry.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkTypes_hdr",
"//include/private:SkNoncopyable_hdr",
],
)
generated_cc_atom(
name = "ResourceFactory_hdr",
hdrs = ["ResourceFactory.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkData_hdr"],
)
generated_cc_atom(
name = "Resources_hdr",
hdrs = ["Resources.h"],
visibility = ["//:__subpackages__"],
deps = [
[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
"//include/core:SkBitmap_hdr",
"//include/core:SkData_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
"//include/core:SkImage_hdr",
"//include/core:SkString_hdr",
],
)
generated_cc_atom(
name = "Resources_src",
srcs = ["Resources.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":ResourceFactory_hdr",
":Resources_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkColorSpace_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
"//include/core:SkData_hdr",
"//include/core:SkImageGenerator_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkTypeface_hdr",
"//src/core:SkOSFile_hdr",
"//src/utils:SkOSPath_hdr",
"//tools/flags:CommandLineFlags_hdr",
],
)
generated_cc_atom(
name = "RuntimeBlendUtils_hdr",
hdrs = ["RuntimeBlendUtils.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkBlendMode_hdr",
"//include/core:SkRefCnt_hdr",
],
)
generated_cc_atom(
name = "RuntimeBlendUtils_src",
srcs = ["RuntimeBlendUtils.cpp"],
visibility = ["//:__subpackages__"],
deps = [
[bazel] Compile gms for wasm and WebGL PS 1 is re-generating existing BUILD.bazel files PS 2 is generating BUILD.bazel files for tests/gms PS 3+ makes modifications to build all of the gms and tests. It is recommended to view this CL with just a diff between PS 2 and the end, due to the large amount of generated changes in PS 1 and 2. We make a filegroup for the gms and tests because they need to be compiled as one large blob in order for the registries to work. Maybe in the future we will break these up, but at least for WASM/JS, the overhead of starting a browser for each new test would likely grind things to a halt, so we just group them all together for now. It's also the most similar to what we currently do. In gm/BUILD.bazel and tests/BUILD.bazel, we add a cc_library that encapsulates all of the deps of the tests, so we can easily include that the build. These were discovered via trial and error, not anything automatic or systematic. The is_skia_dev_build config_setting is very similar to the GN equivalent from which it was based. The list of gms and tests to skip (e.g. which are incompatible with WASM) was determined by building the wasm bundle: modules/canvaskit$ make bazel_gms_release tools/run-wasm-gm-tests$ make run_local_debug # Don't forget to click the button on the screen after the # browser loads This way of invoking the tests will be replace soon with `bazel test <something>`. As such, I didn't bother fully documenting the current way. Suggested review order: - modules/canvaskit/BUILD.bazel taking note that we always use profiling-funcs to make the stacktraces human readable. - gm/BUILD.bazel and tests/BUILD.bazel to see the lists of gms/tests. Notice the tests are roughly partitioned because we don't support things like vulkan/PDF in the wasm build and we will want a way to not build certain tests for certain configurations - tools/* noting some of the cc_libraries added to make dependencies easier to add when needed. - All other files. Change-Id: I43059cd93c28af1c4c12b93d6ebd9c46a12d381f Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506256 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-02-09 18:14:25 +00:00
":RuntimeBlendUtils_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
"//include/core:SkBlendMode_hdr",
"//include/core:SkRefCnt_hdr",
"//include/effects:SkRuntimeEffect_hdr",
],
)
generated_cc_atom(
name = "SkMetaData_hdr",
hdrs = ["SkMetaData.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkScalar_hdr"],
)
generated_cc_atom(
name = "SkMetaData_src",
srcs = ["SkMetaData.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":SkMetaData_hdr",
"//include/private:SkMalloc_hdr",
"//include/private:SkTo_hdr",
],
)
generated_cc_atom(
name = "SkSharingProc_hdr",
hdrs = ["SkSharingProc.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkData_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkSerialProcs_hdr",
],
)
generated_cc_atom(
name = "SkSharingProc_src",
srcs = ["SkSharingProc.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":SkSharingProc_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkData_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkSerialProcs_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
"//include/core:SkStream_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
],
)
generated_cc_atom(
name = "Stats_hdr",
hdrs = ["Stats.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkString_hdr",
"//include/private:SkFloatingPoint_hdr",
],
)
generated_cc_atom(
name = "ToolUtils_hdr",
hdrs = ["ToolUtils.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkColor_hdr",
"//include/core:SkData_hdr",
"//include/core:SkEncodedImageFormat_hdr",
"//include/core:SkFontStyle_hdr",
"//include/core:SkFontTypes_hdr",
"//include/core:SkFont_hdr",
"//include/core:SkImageEncoder_hdr",
"//include/core:SkImageInfo_hdr",
"//include/core:SkPixmap_hdr",
"//include/core:SkRect_hdr",
"//include/core:SkRefCnt_hdr",
"//include/core:SkScalar_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkSurface_hdr",
"//include/core:SkTypeface_hdr",
"//include/core:SkTypes_hdr",
"//include/private:SkTArray_hdr",
"//include/private:SkTDArray_hdr",
"//include/utils:SkRandom_hdr",
"//src/core:SkTInternalLList_hdr",
],
)
generated_cc_atom(
name = "ToolUtils_src",
srcs = ["ToolUtils.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":ToolUtils_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkBlendMode_hdr",
"//include/core:SkCanvas_hdr",
"//include/core:SkColorPriv_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkMatrix_hdr",
"//include/core:SkPaint_hdr",
"//include/core:SkPathBuilder_hdr",
"//include/core:SkPicture_hdr",
"//include/core:SkPixelRef_hdr",
"//include/core:SkPixmap_hdr",
"//include/core:SkPoint3_hdr",
"//include/core:SkRRect_hdr",
"//include/core:SkShader_hdr",
"//include/core:SkSurface_hdr",
"//include/core:SkTextBlob_hdr",
"//include/ports:SkTypeface_win_hdr",
"//include/private:SkColorData_hdr",
"//include/private:SkFloatingPoint_hdr",
"//modules/svg/include:SkSVGDOM_hdr",
"//modules/svg/include:SkSVGNode_hdr",
"//src/core:SkFontPriv_hdr",
"//src/xml:SkDOM_hdr",
],
)
generated_cc_atom(
name = "UrlDataManager_hdr",
hdrs = ["UrlDataManager.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkData_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkString_hdr",
"//src/core:SkOpts_hdr",
"//src/core:SkTDynamicHash_hdr",
],
)
generated_cc_atom(
name = "UrlDataManager_src",
srcs = ["UrlDataManager.cpp"],
visibility = ["//:__subpackages__"],
deps = [":UrlDataManager_hdr"],
)
generated_cc_atom(
name = "blob_cache_sim_src",
srcs = ["blob_cache_sim.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkColor_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkSurface_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_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
"//src/core:SkScalerContext_hdr",
"//src/core:SkTextBlobTrace_hdr",
],
)
generated_cc_atom(
name = "chrome_fuzz_src",
srcs = ["chrome_fuzz.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkCanvas_hdr",
"//include/core:SkImageFilter_hdr",
"//include/core:SkString_hdr",
"//src/core:SkOSFile_hdr",
],
)
generated_cc_atom(
name = "convert-to-nia_src",
srcs = ["convert-to-nia.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/codec:SkCodec_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkData_hdr",
"//src/core:SkAutoMalloc_hdr",
],
)
generated_cc_atom(
name = "cpu_modules_src",
srcs = ["cpu_modules.cpp"],
visibility = ["//:__subpackages__"],
deps = ["//modules/particles/include:SkParticleEffect_hdr"],
)
generated_cc_atom(
name = "dump_record_src",
srcs = ["dump_record.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkBitmap_hdr",
"//include/core:SkPictureRecorder_hdr",
"//include/core:SkPicture_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkTime_hdr",
"//src/core:SkPicturePriv_hdr",
"//src/core:SkRecordDraw_hdr",
"//src/core:SkRecordOpts_hdr",
"//src/core:SkRecord_hdr",
"//src/core:SkRecorder_hdr",
"//tools/flags:CommandLineFlags_hdr",
],
)
generated_cc_atom(
name = "force_older_glibc_math_hdr",
hdrs = ["force_older_glibc_math.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "get_current_monitor_profile_src",
srcs = ["get_current_monitor_profile.cpp"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkStream_hdr"],
)
generated_cc_atom(
name = "get_images_from_skps_src",
srcs = ["get_images_from_skps.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/codec:SkCodec_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkColorSpace_hdr",
"//include/core:SkData_hdr",
"//include/core:SkPicture_hdr",
"//include/core:SkSerialProcs_hdr",
"//include/core:SkStream_hdr",
"//include/private:SkTHash_hdr",
"//src/core:SkMD5_hdr",
"//src/core:SkOSFile_hdr",
"//src/utils:SkJSONWriter_hdr",
"//src/utils:SkOSPath_hdr",
"//tools/flags:CommandLineFlags_hdr",
],
)
generated_cc_atom(
name = "image_diff_metric_src",
srcs = ["image_diff_metric.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/codec:SkCodec_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkData_hdr",
"//include/core:SkPixmap_hdr",
"//include/core:SkSize_hdr",
],
)
generated_cc_atom(
name = "imgcvt_src",
srcs = ["imgcvt.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkCanvas_hdr",
"//include/core:SkData_hdr",
"//include/core:SkImage_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkSurface_hdr",
"//include/third_party/skcms:skcms_hdr",
"//src/core:SkColorSpacePriv_hdr",
],
)
generated_cc_atom(
name = "ios_utils_hdr",
hdrs = ["ios_utils.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "list_gms_src",
srcs = ["list_gms.cpp"],
visibility = ["//:__subpackages__"],
deps = ["//gm:gm_hdr"],
)
generated_cc_atom(
name = "list_gpu_unit_tests_src",
srcs = ["list_gpu_unit_tests.cpp"],
visibility = ["//:__subpackages__"],
[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
deps = [
"//tests:TestHarness_hdr",
"//tests:Test_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
)
generated_cc_atom(
name = "public_headers_warnings_check_src",
srcs = ["public_headers_warnings_check.cpp"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "random_parse_path_hdr",
hdrs = ["random_parse_path.h"],
visibility = ["//:__subpackages__"],
deps = ["//include/core:SkString_hdr"],
)
generated_cc_atom(
name = "random_parse_path_src",
srcs = ["random_parse_path.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":random_parse_path_hdr",
"//include/utils:SkRandom_hdr",
],
)
generated_cc_atom(
name = "remote_demo_src",
srcs = ["remote_demo.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkColorSpace_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
"//include/core:SkGraphics_hdr",
"//include/core:SkSurface_hdr",
"//include/private/chromium:SkChromeRemoteGlyphCache_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
"//src/core:SkScalerContext_hdr",
],
)
generated_cc_atom(
name = "skottie2movie_src",
srcs = ["skottie2movie.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//experimental/ffmpeg:SkVideoEncoder_hdr",
"//include/core:SkCanvas_hdr",
"//include/core:SkGraphics_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkSurface_hdr",
"//include/core:SkTime_hdr",
"//include/gpu:GrContextOptions_hdr",
"//include/private:SkTPin_hdr",
"//modules/skottie/include:Skottie_hdr",
"//modules/skresources/include:SkResources_hdr",
"//src/utils:SkOSPath_hdr",
"//tools/flags:CommandLineFlags_hdr",
"//tools/gpu:GrContextFactory_hdr",
],
)
generated_cc_atom(
name = "skp_parser_src",
srcs = ["skp_parser.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":UrlDataManager_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
"//include/core:SkPicture_hdr",
"//include/core:SkStream_hdr",
"//include/utils:SkNullCanvas_hdr",
"//src/utils:SkJSONWriter_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
"//tools/debugger:DebugCanvas_hdr",
],
)
generated_cc_atom(
name = "skpinfo_src",
srcs = ["skpinfo.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkPicture_hdr",
"//include/core:SkStream_hdr",
"//include/private:SkTo_hdr",
"//src/core:SkFontDescriptor_hdr",
"//src/core:SkPictureCommon_hdr",
"//src/core:SkPictureData_hdr",
"//tools/flags:CommandLineFlags_hdr",
],
)
generated_cc_atom(
name = "using_skia_and_harfbuzz_src",
srcs = ["using_skia_and_harfbuzz.cpp"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkCanvas_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkTextBlob_hdr",
"//include/core:SkTypeface_hdr",
"//include/docs:SkPDFDocument_hdr",
"//modules/skshaper/include:SkShaper_hdr",
],
)
generated_cc_atom(
name = "win_dbghelp_hdr",
hdrs = ["win_dbghelp.h"],
visibility = ["//:__subpackages__"],
)
generated_cc_atom(
name = "win_dbghelp_src",
srcs = ["win_dbghelp.cpp"],
visibility = ["//:__subpackages__"],
deps = [":win_dbghelp_hdr"],
)
generated_cc_atom(
name = "win_lcid_src",
srcs = ["win_lcid.cpp"],
visibility = ["//:__subpackages__"],
[canvaskit] Add Freetype/Fonts to Bazel Build This re-works src/ports/BUILD.bazel to work like our other BUILD files, i.e. one rule "srcs" that brings in the necessary private filegroups. To work around an abort with LLVM [1], we have to go back to an earlier version of emscripten (temporarily?). Future work should look at using transitions [2] to allow various executables (e.g. CanvasKit, DM) to set their own set of Bazel flags, w/o the build invokers having to specify them. These transitions might be able to handle more complex cases that we currently use if statements in GN to deal with. The Freetype build rule was created by taking the BUILD.gn rule, adding in all the sources listed there and then playing compile-whack-a-mole to add in all the headers and included .c files. Suggested Review Order: - third_party/BUILD.bazel to see freetype build rules - bazel/common_config_settings/ to see treatment of fontmgr like codecs (many possible) and fontmgr_factory (only one). - src/ports/BUILD.bazel - BUILD.bazel - modules/canvaskit/BUILD.bazel. Take note of the gen_rule that calls tools/embed_resources.py to produce the .cpp file containing the embedded font data. - Everything else. [1] https://github.com/emscripten-core/emscripten/issues/15528 [2] https://github.com/bazelbuild/examples/tree/main/rules/starlark_configurations/cc_binary_selectable_copts Bug: skia:12541 Change-Id: I08dab82a901d80507007b354ca20cbfad2c2388f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/471636 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2021-11-16 19:09:44 +00:00
)