skia2/include/sksl
Kevin Lubick 2c65579aad [bazel] Add in hierarchical filegroup Bazel rules.
The primary goal of this organization structure is to keep
our top level BUILD.bazel file short, with as little logic
as feasible. The logic required to control which files to
include, which third_party deps are needed, what system libraries
should be linked again, etc, should be in the BUILD.bazel
file best should be as close to the affected files as feasible.

In essence, we use filegroup() rules to bubble up the files
needed to build Skia (all as one big cc_library call) and
cc_library rules to bubble up the other components needed to build.

For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType,
but only if we are compiling Skia with that type of font
support. With the new organization structure in this CL,
//src/ports/BUILD.bazel should have the logic that determines
if the cpp file should be included in the build of Skia and
if it is, that the Skia build should depend on //third_party:freetype2

Another example is //src/gpu/ganesh/BUILD.bazel, which
chooses which of the dawn, gl, vulkan, etc backend sources,
and the associated dependencies to include in the build.
It does not specify what those are, but delegates to the
BUILD.bazel files in the subdirectories housing the
backend-specific code.

The structure guidelines for BUILD.bazel files are as follows:
 - Have a filegroup() called "hdrs" (for public headers) or
   "srcs" (for private headers and all .cpp files) that is
   visible to the parent directory. This should list the
   files from the containing directory to include in the
   build.
   See //include/core/BUILD.bazel and //src/effects/BUILD.bazel
   as examples.
 - filegroup() rules can list a child directory's "hdrs"
   or "srcs" in their "srcs" attributes, but should not contain
   select statements pertaining to child directory files.
   See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel
   as examples.
 - May have a cc_library() called "deps". This can specify
   dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1]
   See //src/codec/BUILD.bazel as an example. These should
   be visible to the parent directory.
 - "hdrs", "srcs", and "deps" for the primary Skia build
   (currently called "skia_core") should bubble up through
   //include/BUILD.bazel and //src/BUILD.bazel, one directory
   at a time.

This CL demonstrates a very basic build of Skia with many features
turned off (CPU only, no fonts, no codecs). Follow-on CLs will
add to these rules as more targets are supported. See bazel/Makefile
for the builds that work with just this CL.

Suggested Review Order:
 - //BUILD.bazel to see the very small skia_core rule which
   delegates all the logic down stack. Note that it has a
   dependency on //bazel:defines_from_flags which will set
   all the defines listed there when compiling all the
   .cpp and .h files in skia_core *and* anything that depends
   on skia_core, but *not* //src:deps.
 - //include/BUILD.bazel and other BUILD.bazel files in the
   subdirectories of that folder. Note that the filegroups in
   //include/private/... are called "srcs" to be similar to
   how Bazel wants "private headers" to be in the "srcs" of
   cc_library, cc_binary, etc. and only public headers are
   to be in "hdrs" [2].
 - //src/BUILD.bazel and other BUILD.bazel files in the
   subdirectories of that folder. //src/gpu/ganesh/...
   will be filled in for dawn, vulkan, and GL in the next CL.
 - //PRESUBMIT.py, which adds a check that runs buildifier [3]
   on modified BUILD.bazel files to make sure they stay
   consistently formatted.
 - //bazel/... to see the new option I added to make sksl
   opt-in or opt-out, so one could build Skia with sksl,
   but not with a gpu backend.
 - Misc .h and .cpp files, whose includes were removed if
   unnecessary or #ifdef'd out to make the minimal build
   work without GPU or SkSL includes.
 - //bazel/Makefile to see the builds that work with this CL.

[1] Setting srcs or hdrs is error-prone at best, because those
   files will be compiled with a different set of defines than
   the rest of skia_core, because they wouldn't depend on
   //bazel:defines_from_flags.
[2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs
[3] https://github.com/bazelbuild/buildtools/releases
Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-31 14:14:54 +00:00
..
BUILD.bazel [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
DSL.h Reland "Remove DSLWrapper helper class." 2022-05-19 14:49:56 +00:00
DSLBlock.h Remove C++14 workaround code. 2022-05-18 13:53:00 +00:00
DSLCase.h Remove C++14 workaround code. 2022-05-18 13:53:00 +00:00
DSLCore.h Improved positions of for loop errors 2022-04-21 16:56:12 +00:00
DSLExpression.h Revert "Eliminate DSLPossibleExpression." 2022-05-23 15:04:00 +00:00
DSLFunction.h Reland "Remove DSLWrapper helper class." 2022-05-19 14:49:56 +00:00
DSLLayout.h Removed Position::Capture 2022-04-08 17:26:24 +00:00
DSLModifiers.h Removed Position::Capture 2022-04-08 17:26:24 +00:00
DSLStatement.h Revert "Eliminate DSLPossibleExpression." 2022-05-23 15:04:00 +00:00
DSLSymbols.h Removed Position::Capture 2022-04-08 17:26:24 +00:00
DSLType.h Revert "Eliminate DSLPossibleExpression." 2022-05-23 15:04:00 +00:00
DSLVar.h Revert "Eliminate DSLPossibleExpression." 2022-05-23 15:04:00 +00:00
OWNERS Add Ethan and John to OWNERS for include/sksl/. 2022-04-26 23:38:58 +00:00
SkSLDebugTrace.h Add SkRuntimeEffect::MakeTraced API for SkShader debugging. 2021-12-07 22:34:00 +00:00
SkSLErrorReporter.h [includes] Enforce IWYU on sksl code 2022-03-21 12:43:02 +00:00
SkSLOperator.h Added an SkSL Operator enum 2022-03-31 13:20:57 +00:00
SkSLPosition.h Fit Position in 4 bytes. 2022-04-27 00:01:06 +00:00
SkSLVersion.h Reland "Add SkCapabilities object" 2022-05-17 13:15:06 +00:00