skia2/infra/bots/BUILD.bazel
Kevin Lubick 5fb37db69f [bazel] Use bazel to build task drivers
One very important, but agonizing to discover, change was
to go_repositories.bzl. Without it, we see cryptic errors like:
external/org_chromium_go_luci/cipd/api/cipd/v1/BUILD.bazel:22:17: no such package '@org_chromium_go_luci//go.chromium.org/luci/cipd/api/cipd/v1': BUILD file not found in directory 'go.chromium.org/luci/cipd/api/cipd/v1' of external repository @org_chromium_go_luci. Add a BUILD file to a directory to mark it as a package. and referenced by '@org_chromium_go_luci//cipd/api/cipd/v1:api_go_proto'

The rest of these changes are very similar to
https://skia-review.googlesource.com/c/buildbot/+/514074
which also has justification for the use of task drivers,
even in a Bazel-driven world.

All the BUILD.bazel files under infra/bots/task_drivers were
generated by Gazelle.

Note that the infra/bots/BUILD.bazel can happily build and
package up the task drivers from the infra repo. The old
build_task_drivers tasks did this too, because we have some
task drivers that are used in both repos.

Change-Id: I13c46c62bc7a6a4bfe7935b28efbfb34caabb6f2
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/515296
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-03 16:12:18 +00:00

44 lines
2.6 KiB
Python

# This rule is a convenient way to build all the task drivers and copy them all into a single
# place as a tar folder. Otherwise, we would need to run many separate bazel build commands and
# then fish the executables out of a deep folder structure like:
# _bazel_bin/infra/bots/task_drivers/bazel_build_all/bazel_build_all_/bazel_build_all
# After this runs, the executables will all be in //_bazel_bin/built_task_drivers.tar
# Why the tar file? Windows binaries are created with .exe and other platforms are not. However,
# outs *must* be static, thus we cannot use a select. Bazel requires us to define all outputs
# exactly, so the only way to support files with different names on different platforms is to
# package them up into a file with the same name.
# Cross compilation is handled as per https://github.com/bazelbuild/rules_go#how-do-i-cross-compile
genrule(
name = "all_task_drivers",
srcs = [
"//infra/bots/task_drivers/codesize",
"//infra/bots/task_drivers/compile_wasm_gm_tests",
"//infra/bots/task_drivers/fm_driver",
"//infra/bots/task_drivers/g3_canary",
"//infra/bots/task_drivers/perf_puppeteer_canvas",
"//infra/bots/task_drivers/perf_puppeteer_render_skps",
"//infra/bots/task_drivers/perf_puppeteer_skottie_frames",
"//infra/bots/task_drivers/push_apps_from_skia_image",
"//infra/bots/task_drivers/push_bazel_apps_from_wasm_image",
"//infra/bots/task_drivers/recreate_skps",
"//infra/bots/task_drivers/run_gn_to_bp",
"//infra/bots/task_drivers/run_wasm_gm_tests",
"@org_skia_go_infra//infra/bots/task_drivers/build_push_docker_image",
"@org_skia_go_infra//infra/bots/task_drivers/canary",
"@org_skia_go_infra//infra/bots/task_drivers/update_go_deps",
],
outs = ["built_task_drivers.tar"],
# Make a temporary directory in the output directory, as recommended by
# https://bazel.build/reference/be/make-variables#predefined_genrule_variables
# Reminder that $(@D) refers to that output directory and $(SRCS) refers to all
# the input files, in a space separated list.
cmd = "mkdir -p $(@D)/tmp_task_drivers && " +
# Copy all the task drivers to the same folder
"cp $(SRCS) $(@D)/tmp_task_drivers && " +
# Tar them up from that folder (so they will be in the top level of the tar directory)
# The parent directory of our temp directory is where the output tar file should go.
"cd $(@D)/tmp_task_drivers && tar --file ../built_task_drivers.tar --create . && " +
# Delete the temp folder (as per the recommendation above)
"cd .. && rm -rf tmp_task_drivers",
)