.bazelrc: include platform in output directory
This change enables the --experimental_platform_in_output_dir flag,
which changes output directory names to includes the platform instead of
the legacy --cpu flag.
This fixes two problems: The first is that builds of the OS image for
two architectures use the same directory name "k8-fastbuild", so they
overwrite each other. The second problem is that when the OS image is
built as a depencency of metroctl, where metrocl is built for a
different platform, then the OS image is built in an output directory
like "k8-fastbuild-ST-12f4ce3d1c3f" and thus is not shared with the
direct build of the OS image.
After this change, the OS image is built under a path such as
"linux-x86_64-fastbuild", and this doesn't change when it is built as a
dependency of metroctl.
Change-Id: I74b91c927a633c1ce05226e035fb92cf7a8f3b04
Reviewed-on: https://review.monogon.dev/c/monogon/+/4205
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/.bazelrc b/.bazelrc
index a62c64d..0615477 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -50,6 +50,20 @@
build --action_env=MONOGON_SANDBOX_DIGEST
import %workspace%/.bazelrc.sandbox
+# Include platform in output directory name. For each platform we use, a short
+# name should be assigned here, otherwise Bazel uses a hash.
+build --experimental_platform_in_output_dir
+build --noexperimental_use_platforms_in_output_dir_legacy_heuristic
+build --experimental_override_name_platform_in_output_dir=//build/platforms:linux_x86_64=linux-x86_64
+build --experimental_override_name_platform_in_output_dir=//build/platforms:linux_aarch64=linux-aarch64
+build --experimental_override_name_platform_in_output_dir=//build/platforms:uefi_x86_64=uefi-x86_64
+build --experimental_override_name_platform_in_output_dir=//build/platforms:uefi_aarch64=uefi-aarch64
+build --experimental_override_name_platform_in_output_dir=//build/platforms:remote_x86_64=remote-x86_64
+build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:darwin_amd64=go-darwin-amd64
+build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:darwin_arm64=go-darwin-arm64
+build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:windows_amd64=go-windows-amd64
+build --experimental_override_name_platform_in_output_dir=@io_bazel_rules_go//go/toolchain:windows_arm64=go-windows-arm64
+
# Enable path mapping to improve cache hit rate.
# Actions in custom rules can opt in with supports-path-mapping.
# See https://github.com/bazelbuild/bazel/discussions/22658