skia2/bazel/Makefile
Kevin Lubick fed97e8f40 [bazel] Add RBE support using hermetic Linux Clang toolchain
A new RBE worker-pool called gce_linux was created in
conjunction with this CL. See
https://docs.google.com/document/d/14xMZCKews69SSTfULhE8HDUzT5XvPwZ4CvRufEvcZ74/edit#
for some details on that.

Note: everything under bazel/rbe/gce_linux was autogenerated
and can be ignored from manual review. It basically specifies
what files are on the RBE image that are necessary for running
Bazel.

Testing it out can be done by authenticating for RBE
gcloud auth application-default login --no-browser

Then, run make -C bazel rbe_known_good_builds
to test it out.

On my 4 core laptop with an empty local cache, but a
warm remote cache, the build took <2 min instead of the
10+ minutes it would have [1].

The folder structure in //bazel/rbe is meant to let us
have multiple remote configurations there, e.g.
//bazel/rbe/gce_windows.

Suggested Review Order:
 - bazel/rbe/README.md
 - bazel/rbe/gce_linux_container/Dockerfile to see the
   bare-bones RBE image.
 - bazel/rbe/BUILD.bazel to see a custom platform defined.
   It is nearly identical to the autogenerated one
   in bazel/rbe/gce_linux/config/BUILD, with one extra
   field to force the gce_linux pool to be used.
 - .bazelrc to see the settings needed to make
   --config=linux-rbe work. The naming convention was
   inspired by SkCMS's setup [2], and allows us to have
   some common RBE settings (i.e. config:remote) and
   some specialized ones for the given host machine
   (e.g. config:linux-rbe) A very important, but subtle
   configuration, is on line 86 of .bazelrc where we say
   to use our hermetic toolchain and not whatever C++
   compiler and headers are on the host machine (aka
   the RBE container).
 - toolchain/build_toolchain.bzl to see some additional
   dependencies needed in the toolchain (to run IWYU) which
   I had installed locally but didn't realize were important.
 - third_party/BUILD.bazel to see an example of how failing
   to specify all files can result in something that works
   locally, but fails remotely.
   --execution_log_json_file=/tmp/execlog.json helped debug
   these issues.
 - All other files.

[1] http://go/scrcast/NjM1ODE4MDI0NzM3MTc3Nnw3ODViZmFkMi1iOA
[2] https://skia.googlesource.com/skcms/+/30c8e303800c256febb03a09fdcda7f75d119b1b/.bazelrc#20


Change-Id: Ia0a9e6a06c1a13071949ab402dc5d897df6b12e1
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524359
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2022-03-28 13:56:16 +00:00

52 lines
2.8 KiB
Makefile

# This target should be run when new files are added or includes changed.
generate:
bazelisk build @org_skia_go_infra//bazel/gazelle:gazelle_cpp
cd .. && bazel-bin/external/org_skia_go_infra/bazel/gazelle/gazelle_cpp_/gazelle_cpp update \
--third_party_file_map="third_party/file_map_for_bazel.json" \
include src tools gm tests \
modules/skshaper modules/svg modules/skresources modules/skparagraph modules/skunicode \
modules/skottie modules/skresources modules/sksg experimental/ffmpeg \
modules/particles \
experimental/bazel_test experimental/graphite example \
modules/canvaskit/go \
infra/bots/task_drivers
# This target should be run after the go.mod file is updated (e.g. version rolls or new updates)
gazelle_update_repo:
cd .. && bazelisk run //:gazelle -- update-repos -from_file=go.mod -to_macro=go_repositories.bzl%go_repositories
# Run this target to test all known working Bazel builds
known_good_builds:
bazelisk build //experimental/bazel_test/... --config=clang --sandbox_base=/dev/shm
bazelisk run //experimental/bazel_test:bazel_test_exe --config=clang --sandbox_base=/dev/shm
bazelisk build //:skia_core --config=clang --sandbox_base=/dev/shm
bazelisk build //src/sksl/lex:sksllex --config=clang --sandbox_base=/dev/shm
bazelisk build //tools/skdiff --config=clang --sandbox_base=/dev/shm
bazelisk build //modules/canvaskit:canvaskit_wasm --compilation_mode opt --sandbox_base=/dev/shm
# Test the enforcement of include what you use
bazelisk build //example:hello_world_gl --config=clang --sandbox_base=/dev/shm \
--features skia_enforce_iwyu
# Both with and without a GPU backend should be error free (i.e. IWYU should let us
# conditionally import things.
bazelisk build //src/svg/... --config=clang --sandbox_base=/dev/shm \
--features skia_enforce_iwyu --gpu_backend=gl_backend --include_decoder=jpeg_decode_codec
bazelisk build //src/svg/... --config=clang --sandbox_base=/dev/shm \
--features skia_enforce_iwyu
rbe_known_good_builds:
bazelisk build //experimental/bazel_test/... --config=linux-rbe
bazelisk run //experimental/bazel_test:bazel_test_exe --config=linux-rbe
bazelisk build //:skia_core --config=linux-rbe
bazelisk build //src/sksl/lex:sksllex --config=linux-rbe
bazelisk build //tools/skdiff --config=linux-rbe
# TODO(kjlubick) CanvasKit does not link on RBE (closure issue)
# Test the enforcement of include what you use
bazelisk build //example:hello_world_gl --config=linux-rbe --features skia_enforce_iwyu
# Both with and without a GPU backend should be error free (i.e. IWYU should let us
# conditionally import things.
bazelisk build //src/svg/... --config=linux-rbe --features skia_enforce_iwyu \
--gpu_backend=gl_backend --include_decoder=jpeg_decode_codec
bazelisk build //src/svg/... --config=linux-rbe --features skia_enforce_iwyu