Go to file
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
bazel [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
bench Reduce SkGlyphRunPainter.h includes 2022-05-26 14:32:19 +00:00
bin Update SKPs documentation link 2022-05-18 15:21:44 +00:00
build/fuchsia
build_overrides Set dawn_vulkan_tools_dir in Dawn's GN overrides 2022-04-14 17:05:33 +00:00
client_utils/android Revert "Move SkCamera.h to client_utils/android" 2022-04-25 12:33:01 +00:00
demos.skia.org [canvaskit] Add in fillText to spreadsheet demo for comparison 2022-02-15 15:35:43 +00:00
dm [graphite] Add SkCombinationBuilder.h 2022-05-23 20:26:17 +00:00
docker Force removal of broken symlink that ships with Perfetto 2022-05-25 21:27:30 +00:00
docs/examples Reland "Add kR8_unorm_SkColorType" 2022-02-10 18:00:19 +00:00
example [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
experimental [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
fuzz Run SkSL unit tests with optimizations disabled. 2022-05-11 14:38:07 +00:00
gm [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
gn implement animatable particle drawables 2022-05-26 19:03:31 +00:00
include [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
infra [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
modules [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
platform_tools Fix bug where SkQP test that are always to be excluded are not. 2022-04-29 20:26:54 +00:00
resources implement animatable particle drawables 2022-05-26 19:03:31 +00:00
samplecode Remove SkNx entirely 2022-05-24 15:57:57 +00:00
site [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
specs [infra] Port serve.py from Python2 to 3 2021-08-31 15:28:19 +00:00
src [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
tests [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
third_party [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
toolchain set up tools for building Skia on Mac semi hermetically 2022-05-04 16:56:46 +00:00
tools [bazel] Delete gazelle-based BUILD.bazel files 2022-05-31 14:14:54 +00:00
.bazelrc [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
.bazelversion [canvaskit] Add skottie to Bazel build 2022-02-04 19:18:27 +00:00
.clang-format
.clang-tidy
.gitignore [infra] Add BazelBuild task to build CanvasKit on the CI with Bazel 2022-05-06 17:54:08 +00:00
.gn Add support for ANGLE's Metal backend 2022-04-28 19:53:18 +00:00
.vpython [python3] Reland recipes -> python3 changes 2021-12-01 13:04:03 +00:00
AUTHORS Add mike@reedtribe.org to AUTHORS 2022-05-19 12:49:11 +00:00
BUILD.bazel [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
BUILD.gn Revert "Add Perfetto library (gn & bazel) and bare-bones SkPerfTrace class" 2022-05-26 16:21:27 +00:00
codereview.settings
CONTRIBUTING
CQ_COMMITTERS
DEPS Roll ANGLE from a2fe4445dce5 to 0b533e64cf61 (7 revisions) 2022-05-31 05:51:45 +00:00
DIR_METADATA
go_repositories.bzl [infra] Update dep of infra repo 2022-04-28 13:20:10 +00:00
go.mod [infra] Update dep of infra repo 2022-04-28 13:20:10 +00:00
go.sum [infra] Fix go.sum 2022-04-28 18:01:34 +00:00
LICENSE
OWNERS
OWNERS.android Update OWNERS.android with more details 2022-03-16 18:13:33 +00:00
package-lock.json [bazel] Make custom karma_test rule 2022-02-23 14:53:01 +00:00
package.json [bazel] Make custom karma_test rule 2022-02-23 14:53:01 +00:00
PRESUBMIT.py [bazel] Add in hierarchical filegroup Bazel rules. 2022-05-31 14:14:54 +00:00
public.bzl Remove SkNx entirely 2022-05-24 15:57:57 +00:00
README
README.chromium
RELEASE_NOTES.txt Make float color versions of SkBitmap::clear 2022-05-19 23:25:06 +00:00
requirements.txt Added expected hash for MarkupSafe for the MacOS platform with the M1 chip 2022-05-19 17:54:32 +00:00
whitespace.txt Push shaders.skia.org. 2022-01-19 21:46:16 +00:00
WORKSPACE.bazel Revert "Add Perfetto library (gn & bazel) and bare-bones SkPerfTrace class" 2022-05-26 16:21:27 +00:00

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.

See full details, and build instructions, at https://skia.org.