Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mylang/private/resolved_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Workaround for https://github.com/bazelbuild/bazel/issues/14009

# Forward all the providers
def _resolved_toolchain_impl(ctx):
toolchain_info = ctx.toolchains["//mylang:/toolchain/toolchain_type"]
toolchain_info = ctx.toolchains["//mylang/toolchain:execution_type"]
return [
toolchain_info,
toolchain_info.default,
Expand All @@ -21,6 +21,6 @@ def _resolved_toolchain_impl(ctx):
# https://cs.opensource.google/bazel/bazel/+/master:tools/jdk/java_toolchain_alias.bzl
resolved_toolchain = rule(
implementation = _resolved_toolchain_impl,
toolchains = ["//mylang/toolchain:toolchain_type"],
toolchains = ["//mylang/toolchain:execution_type"],
doc = DOC,
)
9 changes: 8 additions & 1 deletion mylang/private/toolchains_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ toolchain(
name = "{platform}_toolchain",
exec_compatible_with = {compatible_with},
toolchain = "@{user_repository_name}_{platform}//:mylang_toolchain",
toolchain_type = "@com_myorg_rules_mylang//mylang/toolchain:toolchain_type",
toolchain_type = "@com_myorg_rules_mylang//mylang/toolchain:execution_type",
)

toolchain(
name = "{platform}_target_toolchain",
target_compatible_with = {compatible_with},
toolchain = "@{user_repository_name}_{platform}//:mylang_toolchain",
toolchain_type = "@com_myorg_rules_mylang//mylang/toolchain:target_type",
)
""".format(
platform = platform,
Expand Down
20 changes: 13 additions & 7 deletions mylang/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# This is the target rule authors should put in their "toolchains"
# attribute in order to get a runtime for the correct platform.
# See https://docs.bazel.build/versions/main/toolchains.html#writing-rules-that-use-toolchains
toolchain_type(
name = "toolchain_type",
visibility = ["//visibility:public"],
)
"""
These are the targets rule authors should put in their "toolchains"
attribute in order to get a runtime for the correct platform.
See https://docs.bazel.build/versions/main/toolchains.html
"""

package(default_visibility = ["//visibility:public"])

# Resolve the mylang tool for the execution platform.
toolchain_type(name = "execution_type")

# Less frequently needed: give a diff tool for the target platform.
toolchain_type(name = "target_type")
Loading