Skip to content

packages: compute generator_location from the source root#29219

Open
abishekgiri wants to merge 1 commit intobazelbuild:masterfrom
abishekgiri:generator-location-fix
Open

packages: compute generator_location from the source root#29219
abishekgiri wants to merge 1 commit intobazelbuild:masterfrom
abishekgiri:generator-location-fix

Conversation

@abishekgiri
Copy link
Copy Markdown
Contributor

Summary

This change computes generator_location from the package source root instead of trying to find the package name inside an absolute path with a substring search.

What changed

  • build the generator_location path by relativizing the Starlark call site against the package source root
  • keep returning null when Bazel cannot safely express the location relative to that root
  • update the query integration regressions to exercise the short package name p, which is the case that previously produced the wrong location

Root cause

Rule.getRelativeLocation() searched location.toString() for the package name and sliced the string from the first match. That could match unrelated earlier path segments, so short package names like p could produce malformed generator_location values.

Impact

query --output=build now reports stable repository-relative generator_location values even when the package name is a short substring of an earlier absolute-path segment.

Testing

Tried locally:

  • bazel test //src/test/java/com/google/devtools/build/lib/buildtool:QueryIntegrationTest --test_filter='.*(ruleStackInBuildOutput|ruleStackRegressionTest)' --test_output=errors

Current local blocker:

  • analysis completed, but execution on this machine is blocked by an unaccepted Xcode license (xcrun failed with code 69 from apple_support)

@abishekgiri
Copy link
Copy Markdown
Contributor Author

Reopened this change from the neutral branch name generator-location-fix. The targeted test command is in the PR body; local execution on this machine is still blocked by the unaccepted Xcode license.

@abishekgiri abishekgiri marked this pull request as ready for review April 2, 2026 23:15
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob labels Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant