diff --git a/site/en/concepts/visibility.md b/site/en/concepts/visibility.md index 89efcfbd6d4ba3..596e838628ec60 100644 --- a/site/en/concepts/visibility.md +++ b/site/en/concepts/visibility.md @@ -45,7 +45,8 @@ target. * Package groups use a different syntax for specifying packages. Within a package group, the forms `"//foo/bar:__pkg__"` and `"//foo/bar:__subpackages__"` are respectively replaced by `"//foo/bar"` - and `"//foo/bar/..."`. + and `"//foo/bar/..."`. Likewise, `"//visibility:public"` and + `"//visibility:private"` are just `"public"` and `"private"`. For example, if `//some/package:mytarget` has its `visibility` set to `[":__subpackages__", "//tests:__pkg__"]`, then it could be used by any target diff --git a/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm b/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm index 164ece718cf14d..c8c64fd2aea3aa 100644 --- a/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm +++ b/src/main/java/com/google/devtools/build/docgen/templates/be/functions.vm @@ -178,13 +178,18 @@ not themselves have any visibility protection.

  • As above, but with a trailing /.... For example, //foo/... specifies the set of //foo and all its - subpackages. As a special case, //... specifies all - packages in any repository (in other words, public). + subpackages. //... specifies all packages in the current + repository. + +
  • The strings public or private, which + respectively specify every package or no package. (This form requires + the flag --incompatible_package_group_has_public_syntax to + be set.) -

    In addition, a package specification may also be prefixed with - - to indicate that it is negated.

    +

    In addition, the first two kinds of package specifications may also + be prefixed with - to indicate that they are negated.

    The package group contains any package that matches at least one of its positive specifications and none of its negative specifications @@ -193,11 +198,24 @@ not themselves have any visibility protection.

    subpackages of //foo/tests. (//foo itself is included while //foo/tests itself is not.)

    -

    Aside from //..., there is no way to directly specify +

    Aside from public visibility, there is no way to directly specify packages outside the current repository.

    If this attribute is missing, it is the same as setting it to an - empty list (in other words, private). + empty list, which is also the same as setting it to a list containing + only private. + +

    Note: The specification //... has a legacy behavior + of being the same as public. This behavior is disabled when + --incompatible_fix_package_group_reporoot_syntax is + enabled.

    + +

    Note: As a legacy behavior, when this attribute is serialized as + part of bazel query --output=proto (or + --output=xml), the leading slashes are omitted if + --incompatible_package_group_includes_double_slash is not + enabled. For instance, //pkg/foo/... will output as + \"pkg/foo/...\".

    diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java index f9dec2a7979f18..a73a3d38f20d15 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Package.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java @@ -1652,14 +1652,26 @@ Label createLabel(String targetName) throws LabelSyntaxException { return Label.create(pkg.getPackageIdentifier(), targetName); } - /** - * Adds a package group to the package. - */ - void addPackageGroup(String name, Collection packages, Collection