Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
package_group: Add "public"/"private" constants, fix "//..." meaning
This CL does three things: 1. It adds the special package specifications "public" and "private, guarded behind the flag `--incompatible_package_group_has_public_syntax`. 2. It fixes the behavior of package specification "//..." to mean "all packages in the current repo" rather than "all packages in any repo", guarded behind the flag `--incompatible_fix_package_group_reporoot_syntax`. 3. It fixes the behavior of `bazel query --output=proto` (and `--output=xml`) so that the `packages` attribute is serialized without dropping the leading `//` from package names -- it is now `"//foo/bar/..."` instead of `"foo/bar/..."`. This behavioral change is guarded behind `--incompatible_package_group_includes_double_slash`. The .bzl `visibility()` builtin always acts as if the first two flags are enabled. Work toward bazelbuild#11261. Work toward bazelbuild#16323. Work toward bazelbuild#16355. Work toward bazelbuild#16391. RELNOTES: Added three `package_group`-related flags: `--incompatible_package_group_includes_double_slash` (bazelbuild#16391), `--incompatible_package_group_has_public_syntax` (bazelbuild#16355), and `--incompatible_fix_package_group_reporoot_syntax` (bazelbuild#16323). With these flags, `package_group` can now easily specify "all packages", "no packages", and "all packages in the current repo". In PackageSpecification: - fromString(), fromStringPositive(): rewrote docstring, added bool args for flags, renamed or removed vars for simplicity, added handling of public/private and flag behavior - AllPackagesBeneath(): fixed asStringWithoutRepository() for case of //..., which wasn't likely to arise before. - normalize order of equals(), hashCode(), etc. - AllPackages: change hash, and change str representation to "public" - Add NoPackages, symmetric to AllPackages - NegativePackageSpecification: don't reuse the delegate's hash as our own hash verbatim In PackageGroupTest: - Move `testEverythingSpecificationWorks` to above `testNegativeEverything`, and made it use "public" syntax in place of "//...". - Add test for "private" syntax. - Add test for flag guarding "public"/"private". - Add tests for old and new "//..." behavior. - Add tests that you can't negate "public" or "private". - Add test for illegal combination of flags. - Add assertions for stringification of "public"/"private". Other changes: - Update XmlOutputFormatterTest and ProtoOutputFormatterTest with test cases for the flag. In the latter case, parameterize a helper to allow setting per-test-case flags. - Add test cases to BzlLoadFunctionTest for bzl visibility accepting the list forms `["public"]`/`["private"]`, and for its behavior being unaffected by the new flags. PiperOrigin-RevId: 479347358 Change-Id: I124ca5406bff15615adaa1256e2d7bef69b9d9a5
- Loading branch information