Skip to content

Commit

Permalink
Fill in TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Dec 15, 2024
1 parent 1fab7c1 commit e4b87f3
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def rust_register_toolchains(
if extra_toolchain_infos:
for name, info in extra_toolchain_infos.items():
toolchain_names.append(name)
toolchain_labels[name] = info["label"]
toolchain_labels[name] = info["tools_toolchain_label"]
exec_compatible_with_by_toolchain[name] = info["exec_compatible_with"]
target_compatible_with_by_toolchain[name] = info["target_compatible_with"]
toolchain_target_settings[name] = info["target_settings"]
Expand Down Expand Up @@ -641,7 +641,7 @@ def rust_toolchain_repository(
auth_patterns (list, optional): A list of patterns to match against urls for which the auth object should be used.
Returns:
str: The name of the registerable toolchain created by this rule.
dict[str, str]: Information about the name of the registerable toolchain created by this rule.
"""
if exec_compatible_with == None:
exec_compatible_with = triple_to_constraint_set(exec_triple)
Expand Down Expand Up @@ -673,18 +673,28 @@ def rust_toolchain_repository(

channel_target_settings = ["@rules_rust//rust/toolchain/channel:{}".format(channel)] if channel else []

tools_toolchain_label = "@{}//:rust_toolchain".format(tools_repo_name)

toolchain_type = "@rules_rust//rust:toolchain"

toolchain_repository_proxy(
name = name,
toolchain = "@{}//:rust_toolchain".format(tools_repo_name),
toolchain = tools_toolchain_label,
target_settings = channel_target_settings + target_settings,
toolchain_type = "@rules_rust//rust:toolchain",
toolchain_type = toolchain_type,
exec_compatible_with = exec_compatible_with,
target_compatible_with = target_compatible_with,
)

return "@{name}//:toolchain".format(
name = name,
)
return {
"exec_compatible_with": exec_compatible_with,
"name": name,
"target_compatible_with": target_compatible_with,
"target_settings": target_settings,
"toolchain_label": "@{name}//:toolchain".format(name = name),
"tools_toolchain_label": tools_toolchain_label,
"toolchain_type": toolchain_type,
}

_RUST_ANALYZER_TOOLCHAIN_TOOLS_REPOSITORY_ATTRS = {
"auth": attr.string_dict(
Expand Down Expand Up @@ -1170,7 +1180,7 @@ def rust_repository_set(
else:
fail("extra_rustc_flags should be a list or a dict")

toolchain_label = rust_toolchain_repository(
toolchain_info = rust_toolchain_repository(
name = toolchain.name,
allocator_library = allocator_library,
global_allocator_library = global_allocator_library,
Expand All @@ -1193,20 +1203,8 @@ def rust_repository_set(
exec_compatible_with = exec_compatible_with,
target_compatible_with = toolchain.target_constraints,
)
toolchain_labels.append(toolchain_label)
all_toolchain_details[toolchain.name] = {
# TODO: Don't duplicate the defaulting here
"exec_compatible_with": exec_compatible_with or triple_to_constraint_set(exec_triple),
# "label": toolchain_label,
# TODO: Don't duplicate
"label": "@{}_tools//:rust_toolchain".format(toolchain.name),
"name": toolchain.name,
# TODO: Don't duplicate the defaulting here
"target_compatible_with": toolchain.target_constraints or triple_to_constraint_set(toolchain.target_triple),
"target_settings": target_settings,
# TODO: Don't duplicate
"toolchain_type": "@rules_rust//rust:toolchain",
}
toolchain_labels.append(toolchain_info["toolchain_label"])
all_toolchain_details[toolchain.name] = toolchain_info

# This repository exists to allow `rust_repository_set` to work with the `maybe` wrapper.
rust_toolchain_set_repository(
Expand Down

0 comments on commit e4b87f3

Please sign in to comment.