blob: fa96cfc4ab829ce2671bc86f56bb390b469578b3 [file] [log] [blame]
load("//bazel:macros.bzl", "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
name = "all_task_drivers",
srcs = [
outs = ["built_task_drivers.tar"],
# Make a temporary directory in the output directory, as recommended by
# 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",