skia2/bazel/buildrc
Kevin Lubick 590d3cc8f7 [bazel] Re-implement IWYU enforcement
Instead of having a feature that a subpackage cc_library
would set (because the subpackage cc_libraries went away in
review.skia.org/543977), we now have a list of directories
for which all descendent files will have IWYU run on them.

As before, we have an overarching feature "skia_enforce_iwyu"
that enables this check because of the extra compilation
overhead it incurs.

We have decided to enforce IWYU on debug builds instead of
release builds because we have some code (e.g. that in
SkDEBUGCODE or SkASSERT) which is only compiled and executed
in a debug build, but we don't want to have
#if defined(SK_DEBUG)
all over the place. We make the assumption that the includes
needed to compile in debug mode are the superset of the
includes necessary for release and other modes.

Change-Id: I10254fcc162627c20eb89959e06417effa3cc396
Bug: skia:12541 skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/546607
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-06-06 14:29:47 +00:00

44 lines
3.0 KiB
Plaintext

# This file contains the build configurations of Skia that we use for testing on the CI.
# These allow a short-form reference for our supported combinations of build features.
# https://bazel.build/docs/bazelrc#config
#
# For most build configurations, we will want to set the --cc_output_directory_tag [1]
# with a unique identifier per configuration name.
#
# By default, Bazel's "unique target BuildConfiguration" [2] incorporates the compilation_mode,
# the target platform, and some suffixes to avoid Bazel-caused and user-caused conflicts. [3] [4]
# For example, a default output directory might look like "k8-fastbuild-ST-6a54c1377847".
# Inside this output directory is a subfolder for the target (e.g. executable) name.
#
# Notably, the flags that we turn on and off via //bazel/common_config_settings do not affect
# the output directory. The output directory is used to store compiled object files (.o files)
# and generated dependency files (e.g. the output of clang --write-dependencies [5]), so having
# these be overwritten unnecessarily will slow down incremental rebuilds when switching between
# building different configurations of the same targets.
#
# [1] https://bazel.build/reference/command-line-reference#flag--cc_output_directory_tag
# [2] https://bazel.build/docs/output_directories#layout-diagram
# [3] https://github.com/bazelbuild/bazel/blob/ad37a3748c78e0ee903b56366322c70ab8b22187/CODEBASE.md#the-structure-of-the-output-directory
# [4] https://github.com/bazelbuild/bazel/blob/e0e589658463beb9605030b4820dcc97e6a36f48/src/main/java/com/google/devtools/build/lib/analysis/config/OutputDirectories.java#L198-L236
# [5] https://clang.llvm.org/docs/ClangCommandLineReference.html#dependency-file-generation
# These are examples of the syntax to create build configurations. As of May 2022, our
# Bazel configurations are still being made.
build:release --compilation_mode=opt
build:debug --compilation_mode=dbg
# We use spawn_strategy=local for CanvasKit builds because emscripten assumes there
# is a cache in the home directory that it needs to fill with compiled versions of libc etc.
# https://emscripten.org/docs/tools_reference/emcc.html
# By setting spawn_strategy=local, we can avoid recompiling all of this for every compilation
# unit, by letting the cache be used (and not dropped from the sandbox), which gets expensive.
# Local testing showed using the local strategy sped up a clean build from 9.5 minutes
# to 1 minute. https://bazel.build/docs/user-manual#execution-strategy
build:ck_release --config=release --spawn_strategy=local
build:ck_debug --config=debug --spawn_strategy=local
# We only want to enforce IWYU on debug builds because we have some things that are only
# necessary to include in debug mode (e.g. SkDEBUGCODE), but very rarely something that is
# only needed in release mode. Thus our C++ debug includes should be a superset of the
# release includes.
build:enforce_iwyu --features=skia_enforce_iwyu --cc_output_directory_tag=iwyu --compilation_mode=dbg