@@ -250,20 +250,20 @@ def get_preferred_artifact(library_to_link, use_pic):
250250# We do this to work around a potential crash, see
251251# https://github.com/bazelbuild/bazel/issues/16664
252252def dedup_expand_location (ctx , input , targets = []):
253- return ctx .expand_location (input , _deduplicate (targets ))
253+ return ctx .expand_location (input , deduplicate (targets ))
254254
255- def _deduplicate (xs ):
255+ def deduplicate (xs ):
256256 return {x : True for x in xs }.keys ()
257257
258258def concat (xss ):
259259 return [x for xs in xss for x in xs ]
260260
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 ):
262262 """A trivial helper for `expand_dict_value_locations` and `expand_list_element_locations`
263263
264264 Args:
265265 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.
267267 data (sequence of Targets): See one of the parent functions.
268268 known_variables (dict): Make variables (probably from toolchains) to substitute in when doing make variable expansion.
269269
@@ -272,16 +272,16 @@ def _expand_location_for_build_script_runner(ctx, env, data, known_variables):
272272 """
273273
274274 # 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
277277
278278 for directive in ("$(execpath " , "$(location " ):
279- if directive in env :
279+ if directive in v :
280280 # build script runner will expand pwd to execroot for us
281- env = env .replace (directive , "$${pwd}/" + directive )
281+ v = v .replace (directive , "$${pwd}/" + directive )
282282 return ctx .expand_make_variables (
283- env ,
284- dedup_expand_location ( ctx , env , data ),
283+ v ,
284+ ctx . expand_location ( v , data ),
285285 known_variables ,
286286 )
287287
@@ -315,7 +315,7 @@ def expand_dict_value_locations(ctx, env, data, known_variables):
315315 Returns:
316316 dict: A dict of environment variables with expanded location macros
317317 """
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 ()}
319319
320320def expand_list_element_locations (ctx , args , data , known_variables ):
321321 """Performs location-macro expansion on a list of string values.
0 commit comments