Allow //visibility:public to override other visibility rules.

However only allow it when they are merged from different defaults.

Extend the tests to cover that and other cases with visibilities in
defaults.

Also avoid dumping the whole visibility spec in the error message when a
visibility check fails, because it gets noisy for long visibility lists, and
can be confusing when //visibility:public gets merged with other visibility
rules.

Test: Soong self test
Bug: 112158820
Bug: 130796911
Change-Id: I242513975a3f824b9ea2eab5b94b194b9af2481b
This commit is contained in:
Martin Stjernholm
2019-05-17 22:42:02 +01:00
parent acce05a58c
commit 226b20dc15
4 changed files with 463 additions and 103 deletions

View File

@@ -195,8 +195,10 @@ where `//project` is the module's package. e.g. using `[":__subpackages__"]` in
* `["//visibility:legacy_public"]`: The default visibility, behaves as
`//visibility:public` for now. It is an error if it is used in a module.
The visibility rules of `//visibility:public` and `//visibility:private` can
not be combined with any other visibility specifications.
The visibility rules of `//visibility:public` and `//visibility:private` can not
be combined with any other visibility specifications, except
`//visibility:public` is allowed to override visibility specifications imported
through the `defaults` property.
Packages outside `vendor/` cannot make themselves visible to specific packages
in `vendor/`, e.g. a module in `libcore` cannot declare that it is visible to