@@ -310,13 +310,14 @@ dependencies.""",
310
310
def _is_msvc_var (var ):
311
311
return var == "INCLUDE" or var == "LIB"
312
312
313
- def get_env_prelude (ctx , installdir , data_dependencies ):
313
+ def get_env_prelude (ctx , installdir , data_dependencies , tools_env ):
314
314
"""Generate a bash snippet containing environment variable definitions
315
315
316
316
Args:
317
317
ctx (ctx): The rule's context object
318
318
installdir (str): The path from the root target's directory in the build output
319
319
data_dependencies (list): A list of targets representing dependencies
320
+ tools_env (dict): A dictionary of environment variables from toolchain
320
321
321
322
Returns:
322
323
tuple: A list of environment variables to define in the build script and a dict
@@ -330,6 +331,7 @@ def get_env_prelude(ctx, installdir, data_dependencies):
330
331
]
331
332
332
333
env = dict ()
334
+ env .update (tools_env )
333
335
334
336
# Add all environment variables from the cc_toolchain
335
337
cc_toolchain = find_cpp_toolchain (ctx )
@@ -455,15 +457,18 @@ def cc_external_rule_impl(ctx, attrs):
455
457
target_root = paths .dirname (installdir_copy .file .dirname )
456
458
457
459
data_dependencies = ctx .attr .data + ctx .attr .build_data + ctx .attr .toolchains
460
+ tools_env = {}
458
461
for tool in attrs .tools_data :
459
462
if tool .target :
460
463
data_dependencies .append (tool .target )
464
+ if tool .env :
465
+ tools_env .update (tool .env )
461
466
462
467
# Also add legacy dependencies while they're still available
463
468
data_dependencies += ctx .attr .tools_deps + ctx .attr .additional_tools
464
469
465
470
installdir = target_root + "/" + lib_name
466
- env_prelude = get_env_prelude (ctx , installdir , data_dependencies )
471
+ env_prelude = get_env_prelude (ctx , installdir , data_dependencies , tools_env )
467
472
468
473
if not attrs .postfix_script :
469
474
postfix_script = []
0 commit comments