-
-
Notifications
You must be signed in to change notification settings - Fork 112
fix(run_binary): include RunEnvironmentInfo #1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,8 @@ Possible fixes: | |
| for a in ctx.attr.args: | ||
| args.add_all(split_args(expand_variables(ctx, ctx.expand_location(a, targets = ctx.attr.srcs), inputs = ctx.files.srcs, outs = outputs))) | ||
| envs = {} | ||
| if RunEnvironmentInfo in ctx.attr.tool: | ||
| envs = ctx.attr.tool[RunEnvironmentInfo].environment | ||
fmeum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for k, v in ctx.attr.env.items(): | ||
| envs[k] = expand_variables(ctx, ctx.expand_location(v, targets = ctx.attr.srcs), inputs = ctx.files.srcs, outs = outputs, attribute_name = "env") | ||
|
Comment on lines
53
to
57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The code assigns Useful? React with 👍 / 👎. |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see why this is useful, but it also deviates from pretty much all other rules by applying
envtransitively instead of only withbazel run/test. This could result in confusion and uncertainty, which may be worse than the status quo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some good documentation that shows when
envis forwarded and when not?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://bazel.build/reference/be/common-definitions#common-attributes-binaries, this is documented to only affect the behavior of
bazel run(andbazel testfor tests).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when using this as part of a
genruleorrun_binarytheenvandargshave to be set there as well, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the documented status quo. I'm not against changing this in general, but doing so for a single rule feels wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I love an ambitious plan. Reminds me of
default_shell_env.What would be the more principled (and maybe completely impractical) thing to do?
A rule that converts the
args/envlost attributes to be baked into the binary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just generally a rule that takes an executable target and bakes in args/env via a wrapper. That would be quite composable and not too magical.