@@ -250,20 +250,20 @@ def get_preferred_artifact(library_to_link, use_pic):
250
250
# We do this to work around a potential crash, see
251
251
# https://github.com/bazelbuild/bazel/issues/16664
252
252
def dedup_expand_location (ctx , input , targets = []):
253
- return ctx .expand_location (input , _deduplicate (targets ))
253
+ return ctx .expand_location (input , deduplicate (targets ))
254
254
255
- def _deduplicate (xs ):
255
+ def deduplicate (xs ):
256
256
return {x : True for x in xs }.keys ()
257
257
258
258
def concat (xss ):
259
259
return [x for xs in xss for x in xs ]
260
260
261
- def _expand_location_for_build_script_runner (ctx , env , data , known_variables ):
261
+ def _expand_location_for_build_script_runner (ctx , v , data , known_variables ):
262
262
"""A trivial helper for `expand_dict_value_locations` and `expand_list_element_locations`
263
263
264
264
Args:
265
265
ctx (ctx): The rule's context object
266
- env (str): The value possibly containing location macros to expand.
266
+ v (str): The value possibly containing location macros to expand.
267
267
data (sequence of Targets): See one of the parent functions.
268
268
known_variables (dict): Make variables (probably from toolchains) to substitute in when doing make variable expansion.
269
269
@@ -272,16 +272,16 @@ def _expand_location_for_build_script_runner(ctx, env, data, known_variables):
272
272
"""
273
273
274
274
# Fast-path - both location expansions and make vars have a `$` so we can short-circuit everything.
275
- if "$" not in env :
276
- return env
275
+ if "$" not in v :
276
+ return v
277
277
278
278
for directive in ("$(execpath " , "$(location " ):
279
- if directive in env :
279
+ if directive in v :
280
280
# build script runner will expand pwd to execroot for us
281
- env = env .replace (directive , "$${pwd}/" + directive )
281
+ v = v .replace (directive , "$${pwd}/" + directive )
282
282
return ctx .expand_make_variables (
283
- env ,
284
- dedup_expand_location ( ctx , env , data ),
283
+ v ,
284
+ ctx . expand_location ( v , data ),
285
285
known_variables ,
286
286
)
287
287
@@ -315,7 +315,7 @@ def expand_dict_value_locations(ctx, env, data, known_variables):
315
315
Returns:
316
316
dict: A dict of environment variables with expanded location macros
317
317
"""
318
- return dict ([( k , _expand_location_for_build_script_runner (ctx , v , data , known_variables )) for (k , v ) in env .items ()])
318
+ return { k : _expand_location_for_build_script_runner (ctx , v , data , known_variables ) for (k , v ) in env .items ()}
319
319
320
320
def expand_list_element_locations (ctx , args , data , known_variables ):
321
321
"""Performs location-macro expansion on a list of string values.
0 commit comments