Fix watching paths in undefined repos in repo rules
Watching a path in an undefined repo (eg. `$output_base/external/i_am_undefined/blah`) currently causes an NPE because we expect it to need a skyframe restart when it actually doesn't. The underlying reason is rather convoluted, but the gist is that we request `RepositoryDirectoryValue.Key(@@i_am_undefined)` explicitly, when we don't actually have to -- we can simply use `FileValue.Key($output_base/external/i_am_undefined/blah` directly, and rely on the fact that `FileFunction` knows to request the corresponding `RepositoryDirectoryValue` and behave appropriately when the repo is undefined. (This is due to logic in `ExternalFilesHelper.maybeHandleExternalFile`.) Additionally, this PR removes the `rctx.symlink(watch_target=)` parameter. The symlink target's existence and its contents should not affect the creation of the symlink at all, so there's no reason to ever watch it. Fixes #21483.
Showing
- src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java 6 additions, 15 deletions...azel/repository/starlark/StarlarkBaseExternalContext.java
- src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryContext.java 4 additions, 22 deletions.../bazel/repository/starlark/StarlarkRepositoryContext.java
- src/main/java/com/google/devtools/build/lib/rules/repository/RepoRecordedInput.java 38 additions, 61 deletions...evtools/build/lib/rules/repository/RepoRecordedInput.java
- src/test/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryContextTest.java 1 addition, 1 deletion...el/repository/starlark/StarlarkRepositoryContextTest.java
- src/test/shell/bazel/starlark_repository_test.sh 43 additions, 3 deletionssrc/test/shell/bazel/starlark_repository_test.sh
Please register or sign in to comment