Skip to content

Commit

Permalink
Revert "Revert "Move toolchain registration into WORKSPACE (#5070)"" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sluongng authored Oct 27, 2023
1 parent 0417fe2 commit 7f88f02
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 42 deletions.
31 changes: 6 additions & 25 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ build:remote-shared --remote_download_minimal
build:remote-shared --jobs=100
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:remote-shared --extra_execution_platforms=@buildbuddy_toolchain//:platform_linux

build --incompatible_enable_cc_toolchain_resolution

# Build with --config=remote to use BuildBuddy RBE.
build:remote --config=remote-shared
Expand All @@ -53,27 +52,9 @@ build:remote-dev --config=remote-shared
build:remote-dev --config=cache-dev
build:remote-dev --remote_executor=grpcs://buildbuddy.buildbuddy.dev

# Build with --config=target-linux to
# - Tell Bazel to build binaries for linux
# - Tell Bazel to use Linux-compatible toolchains to build
build:target-linux --cpu=k8
build:target-linux --host_cpu=k8
# Write linux-target build outputs in a separate directory from host build outputs.
build:target-linux --experimental_platform_in_output_dir

# Build with --config=remote-target-linux* to build on remote Linux Executors.
# from non-Linux machines (e.g. MacOS).
#
# Example usage in user.bazelrc:
# build --remote_header=x-buildbuddy-api-key=<foo>
# build:x --config=remote-target-linux
#
# Then you could start building/testing remotely with MacOS with:
# bazel test --config=x //...
build:remote-target-linux --config=target-linux
build:remote-target-linux --config=remote
build:remote-target-linux-dev --config=target-linux
build:remote-target-linux-dev --config=remote-dev
# Write build outputs in a platform-specific directory,
# avoid outputs being wiped and rewritten when switching between platforms.
build --experimental_platform_in_output_dir

# Configuration used for GitHub actions-based CI
build:ci --config=remote
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 7f88f02

Please sign in to comment.