Skip to content

Commit

Permalink
Move toolchain registration into WORKSPACE
Browse files Browse the repository at this point in the history
Register our toolchains inside WORKSPACE.
Then enable automatic cc toolchain resolution for auto selection based
on platform compatibility.
  • Loading branch information
sluongng committed Oct 20, 2023
1 parent 0ed6076 commit 33b3d1e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ build:remote-shared --verbose_failures
build:remote-shared --platforms=@buildbuddy_toolchain//:platform_linux
build:remote-shared --host_platform=@buildbuddy_toolchain//:platform_linux
build:remote-shared --crosstool_top=@buildbuddy_toolchain//:ubuntu_cc_toolchain_suite
build:remote-shared --extra_toolchains=@buildbuddy_toolchain//:ubuntu_cc_toolchain
build:remote-shared --extra_toolchains=//:sh_toolchain

build --incompatible_enable_cc_toolchain_resolution

# Build with --config=remote to use BuildBuddy RBE.
build:remote --config=remote-shared
Expand Down
17 changes: 0 additions & 17 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,3 @@ platform(
"enable-vfs": "true",
},
)

# TODO(bduffany): The sh_toolchain config here is a workaround for
# https://github.com/aspect-build/rules_swc/issues/20
# We should probably either move these to the buildbuddy-toolchain repo
# or add a symlink from /usr/bin/bash -> /bin/bash to remove the need for these.
load("@bazel_tools//tools/sh:sh_toolchain.bzl", "sh_toolchain")

sh_toolchain(
name = "bash_rbe_ubuntu1604",
path = "/bin/bash",
)

toolchain(
name = "sh_toolchain",
toolchain = ":bash_rbe_ubuntu1604",
toolchain_type = "@bazel_tools//tools/sh:toolchain_type",
)
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,8 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_
rules_proto_dependencies()

rules_proto_toolchains()

register_toolchains(
"//toolchains:sh_toolchain",
"@buildbuddy_toolchain//:ubuntu_cc_toolchain",
)
19 changes: 19 additions & 0 deletions toolchains/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# TODO(bduffany): The sh_toolchain config here is a workaround for
# https://github.com/aspect-build/rules_swc/issues/20
# We should probably either move these to the buildbuddy-toolchain repo
# or add a symlink from /usr/bin/bash -> /bin/bash to remove the need for these.
load("@bazel_tools//tools/sh:sh_toolchain.bzl", "sh_toolchain")

sh_toolchain(
name = "bash_rbe_ubuntu1604",
path = "/bin/bash",
)

toolchain(
name = "sh_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
],
toolchain = ":bash_rbe_ubuntu1604",
toolchain_type = "@bazel_tools//tools/sh:toolchain_type",
)

0 comments on commit 33b3d1e

Please sign in to comment.