@@ -50,10 +50,8 @@ def _rust_impl(module_ctx):
5050
5151 toolchain_triples = dict (DEFAULT_TOOLCHAIN_TRIPLES )
5252
53- repository_sets = root .tags .repository_set
54-
5553 grouped_repository_sets = {}
56- for repository_set in repository_sets :
54+ for repository_set in root . tags . repository_set :
5755 if repository_set .name not in grouped_repository_sets :
5856 grouped_repository_sets [repository_set .name ] = {
5957 "allocator_library" : repository_set .allocator_library ,
@@ -62,6 +60,7 @@ def _rust_impl(module_ctx):
6260 "exec_triple" : repository_set .exec_triple ,
6361 "extra_target_triples" : {repository_set .target_triple : [str (v ) for v in repository_set .target_compatible_with ]},
6462 "name" : repository_set .name ,
63+ "opt_level" : {repository_set .target_triple : repository_set .opt_level } if repository_set .opt_level else None ,
6564 "rustfmt_version" : repository_set .rustfmt_version ,
6665 "sha256s" : repository_set .sha256s ,
6766 "target_settings" : [str (v ) for v in repository_set .target_settings ],
@@ -70,14 +69,18 @@ def _rust_impl(module_ctx):
7069 }
7170 else :
7271 for attr_name in _RUST_REPOSITORY_SET_TAG_ATTRS .keys ():
73- if attr_name in ["extra_target_triples" , "name" , "target_compatible_with" , "target_triple" ]:
72+ if attr_name in ["extra_target_triples" , "name" , "target_compatible_with" , "target_triple" , "opt_level" ]:
7473 continue
7574 attr_value = getattr (repository_set , attr_name , None )
7675 if attr_value :
7776 default_value = _COMMON_TAG_DEFAULTS .get (attr_name , None )
7877 if not default_value or attr_value != default_value :
79- 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 ))
78+ 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 ))
8079 grouped_repository_sets [repository_set .name ]["extra_target_triples" ][repository_set .target_triple ] = [str (v ) for v in repository_set .target_compatible_with ]
80+ if repository_set .opt_level :
81+ if grouped_repository_sets [repository_set .name ]["opt_level" ] == None :
82+ grouped_repository_sets [repository_set .name ]["opt_level" ] = {}
83+ grouped_repository_sets [repository_set .name ]["opt_level" ][repository_set .target_triple ] = repository_set .opt_level
8184
8285 extra_toolchain_infos = {}
8386
@@ -169,6 +172,9 @@ _RUST_REPOSITORY_SET_TAG_ATTRS = {
169172 "name" : attr .string (
170173 doc = "Name of the repository_set - if you're looking to replace default toolchains you must use the exact name you're replacing." ,
171174 ),
175+ "opt_level" : attr .string_dict (
176+ doc = "Rustc optimization levels. For more details see the documentation for `rust_toolchain.opt_level`." ,
177+ ),
172178 "target_compatible_with" : attr .label_list (
173179 doc = "List of platform constraints this toolchain produces, for the particular target_triple this call is for." ,
174180 ),
0 commit comments