Gate external-repo source dir package boundary checks behind a flag#30019
Gate external-repo source dir package boundary checks behind a flag#30019fmeum wants to merge 2 commits into
Conversation
Besides fixing the false positives reported in bazelbuild#29688, this also started enforcing a genuinely new class of errors: a source directory in an external repository that crosses a package boundary into a sub-package of that same external repository. Previously the lookup always resolved against the main repository, so such crossings inside external repositories went undetected and the build succeeded. That is an incompatible change: builds that worked on 9.1.1 now fail (see the repro in bazelbuild#29688). Gate the new enforcement behind --incompatible_check_external_repo_source_dir_package_boundary (default off). When the flag is off, package boundary crossings by source directories in external repositories are skipped entirely rather than reverting to the old main-repo lookup, so bazelbuild#29688 stays fixed regardless of the flag value; only the new strictness is deferred. Source directories in the main repository are unaffected.
5cd39dd to
1d3f3d3
Compare
|
@bazel-io fork 9.2.0 |
| effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, | ||
| metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, | ||
| help = | ||
| "If true, a source directory in an external repository fails the build if it crosses a" |
There was a problem hiding this comment.
just a quick comment: is "source directory" the well-known name for this concept? This sentence is very confusing to me without reading the integration set up in SourceDirectoryIntegrationTest.java ("how can a directory cross package boundaries?").
There was a problem hiding this comment.
Yes, the rollout flag was named "track source directories" and this has been the term used for them (unfortunately we say tree artifact instead of generated directory...)
There was a problem hiding this comment.
The source directory / package interaction is legitimately confusing. Happy to reword it you think that this should be clarified, I'm just not sure how.
There was a problem hiding this comment.
ok, thanks for the context. I don't have a much better idea either to be honest, so let's keep it as is for now.
…ectoryIntegrationTest.java Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
Description
#29692 made the package-boundary check for source directories in
RecursiveFilesystemTraversalFunctionrepo-aware. Besides fixing the false positives reported in #29688, it also made the check effective for source directories in external repos, which is a breaking change.This PR gates that new enforcement behind
--incompatible_check_external_repo_source_dir_package_boundary(default off).When the flag is off, package boundary crossings by source directories in external repositories are skipped entirely rather than reverting to the old main-repo lookup. As a result, #29688 stays fixed regardless of the flag value.
Motivation
#29688 (comment)
Build API Changes
Yes: adds the command-line flag
--incompatible_check_external_repo_source_dir_package_boundary.Checklist
Release Notes
RELNOTES: Source directories in external repositories are temporarily allowed to cross package boundaries. This will be disallowed in the future, gated by the new
--incompatible_check_external_repo_source_dir_package_boundaryflag.