File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 41
41
"is_exec_configuration" ,
42
42
"is_std_dylib" ,
43
43
"make_static_lib_symlink" ,
44
+ "parse_env_strings" ,
44
45
"relativize" ,
45
46
)
46
47
@@ -2344,12 +2345,7 @@ rustc_output_diagnostics = rule(
2344
2345
)
2345
2346
2346
2347
def _extra_rustc_env_impl (ctx ):
2347
- env_vars = {}
2348
- for entry in ctx .build_setting_value :
2349
- if "=" not in entry :
2350
- fail ("Invalid format for rustc env var: '{}'. Expected 'KEY=value'" .format (entry ))
2351
- key , val = entry .split ("=" , 1 )
2352
- env_vars [key ] = val
2348
+ env_vars = parse_env_strings (ctx .build_setting_value )
2353
2349
return ExtraRustcEnvInfo (extra_rustc_env = env_vars )
2354
2350
2355
2351
extra_rustc_env = rule (
@@ -2402,12 +2398,7 @@ extra_exec_rustc_flags = rule(
2402
2398
)
2403
2399
2404
2400
def _extra_exec_rustc_env_impl (ctx ):
2405
- env_vars = {}
2406
- for entry in ctx .build_setting_value :
2407
- if "=" not in entry :
2408
- fail ("Invalid format for rustc env var: '{}'. Expected 'KEY=value'" .format (entry ))
2409
- key , val = entry .split ("=" , 1 )
2410
- env_vars [key ] = val
2401
+ env_vars = parse_env_strings (ctx .build_setting_value )
2411
2402
return ExtraExecRustcEnvInfo (extra_exec_rustc_env = env_vars )
2412
2403
2413
2404
extra_exec_rustc_env = rule (
Original file line number Diff line number Diff line change @@ -33,6 +33,23 @@ UNSUPPORTED_FEATURES = [
33
33
"rules_rust_unsupported_feature" ,
34
34
]
35
35
36
+ def parse_env_strings (entries ):
37
+ """Parses a list of environment variable entries in the form 'KEY=value'.
38
+
39
+ Args:
40
+ entries(list): A list of strings, each of the form 'KEY=value'.
41
+
42
+ Returns:
43
+ A dict mapping environment variable names to their values.
44
+ """
45
+ env_vars = {}
46
+ for entry in entries :
47
+ if "=" not in entry :
48
+ fail ("Invalid format for env var: '{}'. Expected 'KEY=value'" .format (entry ))
49
+ key , val = entry .split ("=" , 1 )
50
+ env_vars [key ] = val
51
+ return env_vars
52
+
36
53
def find_toolchain (ctx ):
37
54
"""Finds the first rust toolchain that is configured.
38
55
You can’t perform that action at this time.
0 commit comments