Skip to content
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

Code health: clean up Expander.java interface #11221

Closed
gregestren opened this issue Apr 24, 2020 · 2 comments
Closed

Code health: clean up Expander.java interface #11221

gregestren opened this issue Apr 24, 2020 · 2 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Configurability platforms, toolchains, cquery, select(), config transitions type: process

Comments

@gregestren
Copy link
Contributor

Expander is responsible for Bazel's make variable resolution. Its Java API is a bit delicate and could use some refactoring.

Copied out from pending change https://bazel-review.googlesource.com/c/bazel/+/134315/3/src/main/java/com/google/devtools/build/lib/analysis/Expander.java#68. :

// It's important that we inherit lookedUpVariables from old instances. RuleContext keeps a
// reference to the Expander it gives to rule implementations. But rule implementations may
// clone that with different settings (see the methods below that instantiate new instances).
// We have to guarantee whatever they look up in this instance is also recorded in the original
// instance RuleContext has.
//
// This is unfortunately fragile. A better approach would be to integrate a Builder or more
// customizable constructor into RuleContext so rule implementations can get exactly the
// instance they need from RuleContext's API. Then we can eliminate all other methods that
// construct new instances. Unfortunately there are too many calls in the code base to the
// current approach, so that's a non-trivial cleanup.
//
// Another approach could be to have rule implementations, not RuleContext, be responsible for
// processing lookedUpVariables to report which Make variables they consume. They can do this
// with whatever Expander instance they wish. This is even more fragile: every rule
// rule implementation would have to remember to do this (probably through a RuleContext call),
// to maintain accurate results. That's an unrealistic burden.
//
// TODO: Eliminate all methods that construct an Expander out of an existing Expander.

@gregestren gregestren added P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions labels Apr 24, 2020
bazel-io pushed a commit that referenced this issue Apr 27, 2020
Any Make variable "$(foo)" is equivalent to requiring
"--define foo".

This works for native rule logic and Starlark rules routing
through https://docs.bazel.build/versions/master/skylark/lib/ctx.html#expand_make_variables,
but not Starlark rules routing through
https://docs.bazel.build/versions/master/skylark/lib/ctx.html#var.

Supports #10613.
Added refactoring TODO in #11221.

PiperOrigin-RevId: 308632503
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 26, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Configurability platforms, toolchains, cquery, select(), config transitions type: process
Projects
None yet
Development

No branches or pull requests

1 participant