Skip to content

Commit

Permalink
Improve env and args handling
Browse files Browse the repository at this point in the history
args is not allowed, env should at least support make variable substitution.
  • Loading branch information
fmeum committed Jan 28, 2022
1 parent e60e6d3 commit 27dc841
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion meta/internal/forwarding.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def transition_and_forward_providers_factory(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
})

# This is allowed to collide.
rule_name = "apply_transition"
if test:
Expand Down Expand Up @@ -64,7 +65,11 @@ def _transition_and_forward_providers_impl_factory(extra_providers = []):
)

if ctx.attr.env:
providers.append(testing.TestEnvironment(ctx.attr.env))
expanded_env = {
key: ctx.expand_make_variables("env", value, {})
for key, value in ctx.attr.env.items()
}
providers.append(testing.TestEnvironment(expanded_env))

return providers

Expand Down
7 changes: 5 additions & 2 deletions meta/internal/meta.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ def wrap_with_transition(
def _wrapper_macro(name, visibility = None, tags = None, testonly = None, **kwargs):
unsupported_attr = None
if is_native_rule:
if kwargs.get("env", default = None) != None and not test:
if kwargs.get("env") != None and not test:
unsupported_attr = "env"
elif kwargs.get("env_inherit", default = None) != None:
elif kwargs.get("env_inherit") != None:
unsupported_attr = "env_inherit"
elif kwargs.get("args") != None:
unsupported_attr = "args"

if unsupported_attr != None:
fail("Setting the '{unsupported_attr}' attribute of '{native_rule_name}' on the transition wrapper generated by rules_meta is not yet supported.".format(
unsupported_attr = unsupported_attr,
Expand Down

0 comments on commit 27dc841

Please sign in to comment.