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>
gazelle ended up being more liability than asset for our C++ rules.
It required devs to manually run the command frequently (and was
easy to forget until the CQ failed). The fact that we still had to
edit the source files (e.g. the "srcs" cc_libraries) meant that
the mixture between generated and hand-written caused some
tension (see include/third_party/vulkan for a good example).
The combination of gazelle and our IWYU enforcement added several
bits of churn without any real benefit. The generated rules
also didn't help identify cases where we were not keeping tight
boundaries (e.g. non-gpu code and gpu code).
Identifying third_party deps automatically ended up being trickier
than anticipated (see the deleted //third_party/file_map_for_bazel.json)
Using the "maximum set of dependencies" worked ok, but ended up
increasing build time unnecessarily. For example, compiling
CanvasKit for WebGL always needed to compile Dawn because
SkSLCompiler.cpp sometimes needs to include tint/tint.h.
Follow-up CLs will rebuild the BUILD.bazel rules without gazelle.
Note to Reviewers:
- The only file worth manually reviewing here is bazel/Makefile.
Change-Id: I36d6fc3747487fabaf699690780c95f1f6765770
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543976
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
We disable Control-Flow Integrity sanitization (go/cfi) when updating
the item-array buffer. CFI flags this code as dangerous because we are
casting `buffer` to a T* while the buffer's contents might still be
uninitialized memory. When T has a vtable, this is especially risky
because we could hypothetically access a virtual method on fItemArray
and jump to an unpredictable location in memory. Of course, SkTArray
won't actually use fItemArray in this way, and we don't want to
construct a T before the user requests one. There's no real risk here,
so disable CFI when doing these casts.
Change-Id: I5708053339f4a600b12c841fcd38880f9932f7d6
Bug: skia:13339
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542643
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
The `make -C bazel generate` command doesn't function properly on
Windows builders because Windows uses backslashes as the path separator.
Fortunately, adding quotes around the path is enough to concince
Windows to run the executable, allowing the `generate` target to
complete successfully, and doing so doesn't impact Linux builders.
Bug: skia:13366
Change-Id: I50c461635b70cc59cd6e79bf17a6945c80df1986
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544756
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Change-Id: I7ef9d50eeb49076dbd71fd7070a0f849085c4dc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543978
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This change introduces the use of "Android12" as an OS, so
many checks had to be changed from b.os("Android") to
b.matchOs("Android") which treats "Android" and "Android12"
the same.
Bug: skia:12912
Change-Id: Ib0a5f9d8f1a06b62e529a1567efcde52c7bb44d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/527496
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
This reverts commit bfc9b94840.
Reason for revert: new dependency causing Android build error
Original change's description:
> Add Perfetto library (gn & bazel) and bare-bones SkPerfTrace class
>
> First incremental step to incorporating Perfetto tracing into Skia, more CLs to follow
>
> NOTE: The presubmit check is failing. This appears to be due to the known issue where the presubmit check bugs out if the DEPS file is edited, which it was on this CL (modified to include Perfetto).
>
> Bug: skia:13303
> Change-Id: I908be0392b520e8da14b34588b842bf6d955bd93
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543081
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Nicolette Prevost <nicolettep@google.com>
Bug: skia:13303
Change-Id: Ia2b883bbab1f8fb4f3914b63104a39240cc60e86
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544239
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Auto-Submit: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Nicolette Prevost <nicolettep@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
This reverts commit 35ef74b7a4.
Reason for revert: causing chrome roll failure?
Original change's description:
> Reland "Create updateResourceLabel method."
>
> This is a reland of commit 605f92c7d7
>
> Original change's description:
> > Create updateResourceLabel method.
> >
> > In this CL, the GrSurfaceProxy's and GrDrawOpAtlas's label strings
> > are plumbed so that it can be stored in the label string of
> > GrGpuResource. updateResourceLabel method, which is called from
> > setLabel method, will add labels to Skia OpenGL backend using ANGLE's
> > labeling API.
> >
> > Bug: chromium:1164111
> > Change-Id: I370715d186357e920d260d624d77586cdddd11e8
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541230
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> Bug: chromium:1164111
> Change-Id: Ia20a81d22e320813cbc4ad1d41e06e47dc3827bb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544058
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
Bug: chromium:1164111
Change-Id: Icacb3a0f2f2ee03afc09e03c2ee59b03d5bdd811
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544241
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Tyler Denniston <tdenniston@google.com>
This is a reland of commit 605f92c7d7
Original change's description:
> Create updateResourceLabel method.
>
> In this CL, the GrSurfaceProxy's and GrDrawOpAtlas's label strings
> are plumbed so that it can be stored in the label string of
> GrGpuResource. updateResourceLabel method, which is called from
> setLabel method, will add labels to Skia OpenGL backend using ANGLE's
> labeling API.
>
> Bug: chromium:1164111
> Change-Id: I370715d186357e920d260d624d77586cdddd11e8
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541230
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
Bug: chromium:1164111
Change-Id: Ia20a81d22e320813cbc4ad1d41e06e47dc3827bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/544058
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
As the CommandEncoder class is added we'll need this structs there as
well and I don't want to have to include CommandBuffer.h to get them.
Bug: skia:13357
Change-Id: I6071ac31214b891f09e9565b05e726e141b56f37
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543919
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
SkGlyphRunPainter will soon disappear. Move the
SkGlyphPositionRoundingSpec helper class to a better location.
Change-Id: Id6d3db9b149d5c904964552b662b3b85f4a66218
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543918
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
At this point all the SlugImpl::process* and TextBlob::process*
routines are the same. Inline the process{DeviceMask|SourcePaths
|SourceDrawables|SourceSDFT|SourceMask} into CategorizeGlyphRunList.
Change-Id: I963033250b2d096a58bc1bc29feed35307643b31
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543916
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Replace unnecessary includes with what's actually needed to reduce the
build cost.
Change-Id: Ib5b30652f82a34b79ebaa85550dbe5b3ebfae01b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543696
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Lei Zhang <thestig@chromium.org>
First incremental step to incorporating Perfetto tracing into Skia, more CLs to follow
NOTE: The presubmit check is failing. This appears to be due to the known issue where the presubmit check bugs out if the DEPS file is edited, which it was on this CL (modified to include Perfetto).
Bug: skia:13303
Change-Id: I908be0392b520e8da14b34588b842bf6d955bd93
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543081
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Nicolette Prevost <nicolettep@google.com>
This reverts commit 605f92c7d7.
Reason for revert: breaking bots on CQ
Original change's description:
> Create updateResourceLabel method.
>
> In this CL, the GrSurfaceProxy's and GrDrawOpAtlas's label strings
> are plumbed so that it can be stored in the label string of
> GrGpuResource. updateResourceLabel method, which is called from
> setLabel method, will add labels to Skia OpenGL backend using ANGLE's
> labeling API.
>
> Bug: chromium:1164111
> Change-Id: I370715d186357e920d260d624d77586cdddd11e8
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541230
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
Bug: chromium:1164111
Change-Id: I1f2d8585fefde6b74d23f2ea14d91ee6d3e1e60d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543486
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Tyler Denniston <tdenniston@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
In this CL, the GrSurfaceProxy's and GrDrawOpAtlas's label strings
are plumbed so that it can be stored in the label string of
GrGpuResource. updateResourceLabel method, which is called from
setLabel method, will add labels to Skia OpenGL backend using ANGLE's
labeling API.
Bug: chromium:1164111
Change-Id: I370715d186357e920d260d624d77586cdddd11e8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541230
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Change-Id: I7ff3cd59401392c55ac27c9da9183fe9a3f62e4f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543083
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>