@@ -1115,6 +1115,17 @@ def _get_toolchain_repositories(
1115
1115
1116
1116
return toolchain_repos .values ()
1117
1117
1118
+ def _get_flags_for_triple (name , flags , target_triple ):
1119
+ """Infer toolchain-specific flags depending on the type (list, dict, optional)."""
1120
+ if flags == None :
1121
+ return None
1122
+ elif type (flags ) == "list" :
1123
+ return flags
1124
+ elif type (flags ) == "dict" :
1125
+ return flags .get (target_triple )
1126
+ else :
1127
+ fail (name + " should be a list or a dict" )
1128
+
1118
1129
def rust_repository_set (
1119
1130
* ,
1120
1131
name ,
@@ -1162,7 +1173,7 @@ def rust_repository_set(
1162
1173
dev_components (bool, optional): Whether to download the rustc-dev components.
1163
1174
Requires version to be "nightly".
1164
1175
extra_rustc_flags (dict, list, optional): Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration.
1165
- extra_exec_rustc_flags (list, optional): Extra flags to pass to rustc in exec configuration.
1176
+ extra_exec_rustc_flags (dict, list, optional): Dictionary of target triples to list of extra flags to pass to rustc in exec configuration.
1166
1177
opt_level (dict, dict, optional): Dictionary of target triples to optimization config.
1167
1178
strip_level (dict, dict, optional): Dictionary of target triples to strip config.
1168
1179
sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. See
@@ -1196,15 +1207,16 @@ def rust_repository_set(
1196
1207
aliases = aliases ,
1197
1208
compact_windows_names = compact_windows_names ,
1198
1209
):
1199
- # Infer toolchain-specific rustc flags depending on the type (list, dict, optional) of extra_rustc_flags
1200
- if extra_rustc_flags == None :
1201
- toolchain_extra_rustc_flags = []
1202
- elif type (extra_rustc_flags ) == "list" :
1203
- toolchain_extra_rustc_flags = extra_rustc_flags
1204
- elif type (extra_rustc_flags ) == "dict" :
1205
- toolchain_extra_rustc_flags = extra_rustc_flags .get (toolchain .target_triple )
1206
- else :
1207
- fail ("extra_rustc_flags should be a list or a dict" )
1210
+ toolchain_extra_exec_rustc_flags = _get_flags_for_triple (
1211
+ "extra_exec_rustc_flags" ,
1212
+ extra_exec_rustc_flags ,
1213
+ toolchain .target_triple ,
1214
+ )
1215
+ toolchain_extra_rustc_flags = _get_flags_for_triple (
1216
+ "extra_rustc_flags" ,
1217
+ extra_rustc_flags ,
1218
+ toolchain .target_triple ,
1219
+ )
1208
1220
1209
1221
toolchain_info = rust_toolchain_repository (
1210
1222
name = toolchain .name ,
@@ -1217,7 +1229,7 @@ def rust_repository_set(
1217
1229
dev_components = dev_components ,
1218
1230
edition = edition ,
1219
1231
exec_triple = exec_triple ,
1220
- extra_exec_rustc_flags = extra_exec_rustc_flags ,
1232
+ extra_exec_rustc_flags = toolchain_extra_exec_rustc_flags ,
1221
1233
extra_rustc_flags = toolchain_extra_rustc_flags ,
1222
1234
opt_level = opt_level .get (toolchain .target_triple ) if opt_level != None else None ,
1223
1235
strip_level = strip_level .get (toolchain .target_triple ) if strip_level != None else None ,
0 commit comments