blob: 995d371a4c76f24b5adc4835ff812ff105e9f260 [file] [log] [blame]
# https://github.com/bazelbuild/bazel-toolchains/blob/master/rules/exec_properties/exec_properties.bzl
load("@bazel_toolchains//rules/exec_properties:exec_properties.bzl", "create_rbe_exec_properties_dict")
# https://bazel.build/concepts/platforms-intro
# https://bazel.build/docs/platforms
platform(
name = "linux_x64_hermetic",
constraint_values = [
"@platforms//os:linux", # https://github.com/bazelbuild/platforms/blob/main/os/BUILD
"@platforms//cpu:x86_64", # https://github.com/bazelbuild/platforms/blob/main/cpu/BUILD
":use_hermetic_toolchain",
],
# We specify exec_properties because we have an RBE instance that matches this platform.
# exec_properties specify some information that is passed along the Remote Execution API
# (REAPI) to the dispatcher which will use it to direct the request to the appropriate
# machine/worker, using the Remote Worker API (RWAPI).
# http://go/skolo-rbe
# These properties will be ignored when running locally, but we must specify them if we want
# the action cache to treat things built on a local Linux machine to be the same as built on
# a Linux RBE worker (which they should, assuming our hermetic toolchain *is* hermetic).
# See https://github.com/bazelbuild/bazel/blob/f28209df2b0ebeff1de0b8b7f6b9e215d890e753/src/main/java/com/google/devtools/build/lib/actions/ActionKeyCacher.java#L67-L73
# for how the exec_properties and execution platform impact the action cache.
exec_properties = create_rbe_exec_properties_dict(
container_image = "docker://gcr.io/skia-public/rbe_linux@sha256:654139e5cecb163f80a7d18e2b2da6c758ebe6325d2d9c41d9facf58e1b3f799",
os_family = "Linux",
pool = "gce_linux",
),
)
platform(
name = "mac_x64_hermetic",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
":use_hermetic_toolchain",
],
)
platform(
name = "mac_arm64_hermetic",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
":use_hermetic_toolchain",
],
)
platform(
name = "host_with_hermetic_toolchain",
constraint_values = [
":use_hermetic_toolchain",
],
parents = ["@local_config_platform//:host"],
)
# This constraint allows us to force Bazel to resolve our hermetic toolchain to build
# the target and not a default one (e.g. on the Linux RBE instance). We do this by
# adding the constraint to our platforms that describe the target we want Bazel to build for.
# https://bazel.build/reference/be/platform#constraint_setting
constraint_setting(name = "skia_hermetic_toolchain")
constraint_value(
name = "use_hermetic_toolchain",
constraint_setting = ":skia_hermetic_toolchain",
visibility = ["//visibility:public"],
)