skia2/infra/bots/BUILD.bazel
Kevin Lubick 3413ca474b [infra] Add BazelBuild task to build CanvasKit on the CI with Bazel
For additional context, see "Codifying Certain Build Options"
and "Building on the CI" in the design doc go/skia-bazel

Suggested review order:
 - builder_name_schema.json to see the three required and
   one optional part of BazelBuild jobs.
 - jobs.json to see one new BazelBuild job added. In an
   ideal world, this job would have been named
   BazelBuild-//modules/canvaskit:canvaskit_wasm-debug-linux_x64
   but Buildbucket (?) requires jobs match the regex
   ^[a-zA-Z0-9\\-_.\\(\\) ]{1,128}$
   so we use spaces instead of slashes or colons.
 - gen_tasks_logic.go; noting the makeBazelLabel function
   expands most of the spaces to / and the last one to a
   colon to make a single-target label. If there are three
   dots, then it is a multi-target label, and we do not
   need to add a colon.
 - bazel_build.go; This is a very simple task driver, and
   I do not anticipate getting too much more complex.
   The place where we decide which args to augment
   a build with depend on the host platform and thus
   should be set in gen_tasks_logic.go.
 - bazel/buildrc to see some initial configurations set,
   one of which, "debug", is used by the new job.
   The "release" version of CanvasKit probably works on
   3.1.10 which had a bugfix, but we are still on
   3.1.9
 - .bazelrc to see a rename of the linux-rbe config to
   linux_rbe (our configs should have no dashes if
   we want to specify them verbatim in our Job names).
   It also imports the Skia-specified build configs
   from //bazel/buildrc and supports the user-specified
   //bazel/user/buildrc file if it exists.
 - All other files in any order.

Change-Id: Ib954dd6045100eadcbbf4ffee0888f6fbce65fa7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/537797
Reviewed-by: Eric Boren <borenet@google.com>
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
2022-05-06 17:54:08 +00:00

52 lines
2.8 KiB
Python

load("//bazel:macros.bzl", "exports_files_legacy")
licenses(["notice"])
exports_files_legacy()
# 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/bazel_build",
"//infra/bots/task_drivers/bazel_check_includes",
"//infra/bots/task_drivers/check_generated_bazel_files",
"//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",
],
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",
)