Lines Matching full:visibility
27 // Enforces visibility rules between modules.
30 // * First stage works bottom up, before defaults expansion, to check the syntax of the visibility
36 // * Third stage works bottom up to extract visibility information from the modules, parse it,
40 // and so can be run in parallel. If a module has no visibility specified then it uses the
41 // default package visibility if specified.
46 // publicly visible. Otherwise, it calls the visibility rule to check that the module can see
49 // TODO(b/130631145) - Make visibility work properly with prebuilts.
51 // Patterns for the values that can be specified in visibility property.
72 // A visibility rule is associated with a module and determines which other modules it is visible
82 // Describes the properties provided by a module that contain visibility rules.
108 // A compositeRule is a visibility rule composed from a list of atomic visibility rules.
110 // The list corresponds to the list of strings in the visibility property after defaults expansion.
111 // Even though //visibility:public is not allowed together with other rules in the visibility list
112 // of a single module, it is allowed here to permit a module to override an inherited visibility
113 // spec with public visibility.
115 // //visibility:private is not allowed in the same way, since we'd need to check for it during the
116 // defaults expansion to make that work. No non-private visibility rules are allowed in a
119 // This array will only be [] if all the rules are invalid and will behave as if visibility was
120 // ["//visibility:private"].
147 // A packageRule is a visibility rule that matches modules in a specific package (i.e. directory).
162 // A subpackagesRule is a visibility rule that matches modules in a specific package (i.e.
186 // visibilityRule for //visibility:public
196 return "//visibility:public"
199 // visibilityRule for //visibility:private
209 return "//visibility:private"
214 // visibilityRule for //visibility:any_partition
233 return "//visibility:any_" + r.partitionType + "_partition"
250 // Marker interface that identifies dependencies that are excluded from visibility
259 // The visibility mutators.
269 // //visibility:xxx isn't combined with other packages in the same list in any one module.
274 // Registers the function that gathers the visibility rules for each module.
276 // Visibility is not dependent on arch so this must be registered before the arch phase to avoid
278 // the complete visibility lists from flat lists and after the package info is gathered to ensure
289 // Checks the per-module visibility rule lists before defaults expansion.
293 if visibility := p.getStrings(); visibility != nil {
294 checkRules(ctx, ctx.ModuleDir(), p.getName(), visibility)
299 func checkRules(ctx BaseModuleContext, currentPkg, property string, visibility []string) {
300 ruleCount := len(visibility)
302 // This prohibits an empty list as its meaning is unclear, e.g. it could mean no visibility and
303 // it could mean public visibility. Requiring at least one rule makes the owner's intent
305 ctx.PropertyErrorf(property, "must contain at least one visibility rule")
309 for i, v := range visibility {
315 if pkg == "visibility" {
319 ctx.PropertyErrorf(property, "//visibility:legacy_public must not be used")
326 // any_*_partition can be used with another visibility fields
329 ctx.PropertyErrorf(property, "unrecognized visibility rule %q", v)
334 ctx.PropertyErrorf(property, `"%v" may only be used at the start of the visibility rules`, v)
337 ctx.PropertyErrorf(property, "cannot mix %q with any other visibility rules", v)
355 // Gathers the flattened visibility rules after defaults expansion, parses the visibility
358 // See ../README.md#Visibility for information on the format of the visibility rules.
365 // Parse the visibility rules that control access to the module and store them by id
370 if visibility := primaryProperty.getStrings(); visibility != nil {
371 rule = parseRules(ctx, currentPkg, primaryProperty.getName(), visibility)
383 func parseRules(ctx BaseModuleContext, currentPkg, property string, visibility []string) compositeR…
384 rules := make(compositeRule, 0, len(visibility))
388 for _, v := range visibility {
396 if pkg == "visibility" {
427 ctx.PropertyErrorf(property, "invalid visibility pattern %q. Must match "+
444 ctx.PropertyErrorf("visibility",
445 "cannot mix \"//visibility:private\" with any other visibility rules")
485 // Visibility rule is invalid so ignore it. Keep going rather than aborting straight away to
488 "invalid visibility pattern %q must match"+
532 … %s which is not visible to this module\nYou may need to add %q to its visibility", depQualified, …
537 // Default visibility is public.
540 // Return the effective visibility rules.
542 // If no rules have been specified this will return the default visibility rule
543 // which is currently //visibility:public.
557 // If no rule is specified then return the default visibility rule to avoid
563 // If a partition rule wasn't specified, add implicit partition visibility
601 // Widen the visibility with some extra rules.
615 // the current visibility is public then the extra rules will just be ignored.
619 case "//visibility:public":
623 case "//visibility:private":
625 return fmt.Errorf("%q does not widen the visibility", singularRule)
631 case "//visibility:public":
634 case "//visibility:private":
650 // Get the effective visibility rules, i.e. the actual rules that affect the visibility of the
653 // Includes visibility rules specified by package default_visibility and/or on defaults.
666 // without checking the visibility rules. Here we need to add that visibility
671 // If the rule is //visibility:private we can't append another
672 // visibility to it. Semantically we need to convert it to a package
673 // visibility rule for the location where the result is used, but since
686 // Clear the default visibility properties so they can be replaced.
691 // Add a property that contains visibility rules so that they are checked for
704 // Set the primary visibility property.