Skip to content
Open
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
16 changes: 11 additions & 5 deletions rust/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ def _rust_impl(module_ctx):

toolchain_triples = dict(DEFAULT_TOOLCHAIN_TRIPLES)

repository_sets = root.tags.repository_set

grouped_repository_sets = {}
for repository_set in repository_sets:
for repository_set in root.tags.repository_set:
if repository_set.name not in grouped_repository_sets:
grouped_repository_sets[repository_set.name] = {
"allocator_library": repository_set.allocator_library,
Expand All @@ -62,6 +60,7 @@ def _rust_impl(module_ctx):
"exec_triple": repository_set.exec_triple,
"extra_target_triples": {repository_set.target_triple: [str(v) for v in repository_set.target_compatible_with]},
"name": repository_set.name,
"opt_level": {repository_set.target_triple: repository_set.opt_level} if repository_set.opt_level else None,
"rustfmt_version": repository_set.rustfmt_version,
"sha256s": repository_set.sha256s,
"target_settings": [str(v) for v in repository_set.target_settings],
Expand All @@ -70,14 +69,18 @@ def _rust_impl(module_ctx):
}
else:
for attr_name in _RUST_REPOSITORY_SET_TAG_ATTRS.keys():
if attr_name in ["extra_target_triples", "name", "target_compatible_with", "target_triple"]:
if attr_name in ["extra_target_triples", "name", "target_compatible_with", "target_triple", "opt_level"]:
continue
attr_value = getattr(repository_set, attr_name, None)
if attr_value:
default_value = _COMMON_TAG_DEFAULTS.get(attr_name, None)
if not default_value or attr_value != default_value:
fail("You must only set {} on the first call to repository_set for a particular name but it was set multiple times for {}".format(attr_name, repository_set.name))
fail("You must only set `{}` on the first call to `repository_set` for a particular name but it was set multiple times for `{}`".format(attr_name, repository_set.name))
grouped_repository_sets[repository_set.name]["extra_target_triples"][repository_set.target_triple] = [str(v) for v in repository_set.target_compatible_with]
if repository_set.opt_level:
if grouped_repository_sets[repository_set.name]["opt_level"] == None:
grouped_repository_sets[repository_set.name]["opt_level"] = {}
grouped_repository_sets[repository_set.name]["opt_level"][repository_set.target_triple] = repository_set.opt_level

extra_toolchain_infos = {}

Expand Down Expand Up @@ -169,6 +172,9 @@ _RUST_REPOSITORY_SET_TAG_ATTRS = {
"name": attr.string(
doc = "Name of the repository_set - if you're looking to replace default toolchains you must use the exact name you're replacing.",
),
"opt_level": attr.string_dict(
doc = "Rustc optimization levels. For more details see the documentation for `rust_toolchain.opt_level`.",
),
"target_compatible_with": attr.label_list(
doc = "List of platform constraints this toolchain produces, for the particular target_triple this call is for.",
),
Expand Down