blob: 1e3b91ddd56a61439179a8036c764f96759d0dd2 [file] [log] [blame]
Paul Duffin2e61fa62019-03-28 14:10:57 +00001// Copyright 2019 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package android
16
17import (
18 "fmt"
19 "regexp"
20 "strings"
21 "sync"
Paul Duffin78ac5b92020-01-14 12:42:08 +000022
23 "github.com/google/blueprint"
Paul Duffin2e61fa62019-03-28 14:10:57 +000024)
25
26// Enforces visibility rules between modules.
27//
Paul Duffine2453c72019-05-31 14:00:04 +010028// Multi stage process:
29// * First stage works bottom up, before defaults expansion, to check the syntax of the visibility
30// rules that have been specified.
31//
32// * Second stage works bottom up to extract the package info for each package and store them in a
33// map by package name. See package.go for functionality for this.
34//
35// * Third stage works bottom up to extract visibility information from the modules, parse it,
Paul Duffin2e61fa62019-03-28 14:10:57 +000036// create visibilityRule structures and store them in a map keyed by the module's
37// qualifiedModuleName instance, i.e. //<pkg>:<name>. The map is stored in the context rather
38// than a global variable for testing. Each test has its own Config so they do not share a map
Paul Duffine2453c72019-05-31 14:00:04 +010039// and so can be run in parallel. If a module has no visibility specified then it uses the
40// default package visibility if specified.
Paul Duffin2e61fa62019-03-28 14:10:57 +000041//
Paul Duffine2453c72019-05-31 14:00:04 +010042// * Fourth stage works top down and iterates over all the deps for each module. If the dep is in
Paul Duffin2e61fa62019-03-28 14:10:57 +000043// the same package then it is automatically visible. Otherwise, for each dep it first extracts
44// its visibilityRule from the config map. If one could not be found then it assumes that it is
45// publicly visible. Otherwise, it calls the visibility rule to check that the module can see
46// the dependency. If it cannot then an error is reported.
47//
48// TODO(b/130631145) - Make visibility work properly with prebuilts.
49// TODO(b/130796911) - Make visibility work properly with defaults.
50
51// Patterns for the values that can be specified in visibility property.
52const (
53 packagePattern = `//([^/:]+(?:/[^/:]+)*)`
54 namePattern = `:([^/:]+)`
55 visibilityRulePattern = `^(?:` + packagePattern + `)?(?:` + namePattern + `)?$`
56)
57
58var visibilityRuleRegexp = regexp.MustCompile(visibilityRulePattern)
59
Paul Duffin2e61fa62019-03-28 14:10:57 +000060// A visibility rule is associated with a module and determines which other modules it is visible
61// to, i.e. which other modules can depend on the rule's module.
62type visibilityRule interface {
63 // Check to see whether this rules matches m.
64 // Returns true if it does, false otherwise.
65 matches(m qualifiedModuleName) bool
66
67 String() string
68}
69
Paul Duffine2453c72019-05-31 14:00:04 +010070// Describes the properties provided by a module that contain visibility rules.
71type visibilityPropertyImpl struct {
Paul Duffin63c6e182019-07-24 14:24:38 +010072 name string
73 stringsProperty *[]string
Paul Duffine2453c72019-05-31 14:00:04 +010074}
75
76type visibilityProperty interface {
77 getName() string
78 getStrings() []string
79}
80
Paul Duffin63c6e182019-07-24 14:24:38 +010081func newVisibilityProperty(name string, stringsProperty *[]string) visibilityProperty {
Paul Duffine2453c72019-05-31 14:00:04 +010082 return visibilityPropertyImpl{
Paul Duffin63c6e182019-07-24 14:24:38 +010083 name: name,
84 stringsProperty: stringsProperty,
Paul Duffine2453c72019-05-31 14:00:04 +010085 }
86}
87
88func (p visibilityPropertyImpl) getName() string {
89 return p.name
90}
91
92func (p visibilityPropertyImpl) getStrings() []string {
Paul Duffin63c6e182019-07-24 14:24:38 +010093 return *p.stringsProperty
Paul Duffine2453c72019-05-31 14:00:04 +010094}
95
Martin Stjernholm226b20d2019-05-17 22:42:02 +010096// A compositeRule is a visibility rule composed from a list of atomic visibility rules.
97//
98// The list corresponds to the list of strings in the visibility property after defaults expansion.
99// Even though //visibility:public is not allowed together with other rules in the visibility list
100// of a single module, it is allowed here to permit a module to override an inherited visibility
101// spec with public visibility.
102//
103// //visibility:private is not allowed in the same way, since we'd need to check for it during the
104// defaults expansion to make that work. No non-private visibility rules are allowed in a
105// compositeRule containing a privateRule.
106//
Paul Duffin2e61fa62019-03-28 14:10:57 +0000107// This array will only be [] if all the rules are invalid and will behave as if visibility was
108// ["//visibility:private"].
109type compositeRule []visibilityRule
110
111// A compositeRule matches if and only if any of its rules matches.
112func (c compositeRule) matches(m qualifiedModuleName) bool {
113 for _, r := range c {
114 if r.matches(m) {
115 return true
116 }
117 }
118 return false
119}
120
Paul Duffine2453c72019-05-31 14:00:04 +0100121func (c compositeRule) String() string {
Paul Duffin593b3c92019-12-05 14:31:48 +0000122 return "[" + strings.Join(c.Strings(), ", ") + "]"
123}
124
125func (c compositeRule) Strings() []string {
Paul Duffine2453c72019-05-31 14:00:04 +0100126 s := make([]string, 0, len(c))
127 for _, r := range c {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000128 s = append(s, r.String())
129 }
Paul Duffin593b3c92019-12-05 14:31:48 +0000130 return s
Paul Duffin2e61fa62019-03-28 14:10:57 +0000131}
132
133// A packageRule is a visibility rule that matches modules in a specific package (i.e. directory).
134type packageRule struct {
135 pkg string
136}
137
138func (r packageRule) matches(m qualifiedModuleName) bool {
139 return m.pkg == r.pkg
140}
141
142func (r packageRule) String() string {
143 return fmt.Sprintf("//%s:__pkg__", r.pkg)
144}
145
146// A subpackagesRule is a visibility rule that matches modules in a specific package (i.e.
147// directory) or any of its subpackages (i.e. subdirectories).
148type subpackagesRule struct {
149 pkgPrefix string
150}
151
152func (r subpackagesRule) matches(m qualifiedModuleName) bool {
153 return isAncestor(r.pkgPrefix, m.pkg)
154}
155
156func isAncestor(p1 string, p2 string) bool {
157 return strings.HasPrefix(p2+"/", p1+"/")
158}
159
160func (r subpackagesRule) String() string {
161 return fmt.Sprintf("//%s:__subpackages__", r.pkgPrefix)
162}
163
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100164// visibilityRule for //visibility:public
165type publicRule struct{}
166
167func (r publicRule) matches(_ qualifiedModuleName) bool {
168 return true
169}
170
171func (r publicRule) String() string {
172 return "//visibility:public"
173}
174
175// visibilityRule for //visibility:private
176type privateRule struct{}
177
178func (r privateRule) matches(_ qualifiedModuleName) bool {
179 return false
180}
181
182func (r privateRule) String() string {
183 return "//visibility:private"
184}
185
Paul Duffin2e61fa62019-03-28 14:10:57 +0000186var visibilityRuleMap = NewOnceKey("visibilityRuleMap")
187
188// The map from qualifiedModuleName to visibilityRule.
Paul Duffin44885e22020-02-19 16:10:09 +0000189func moduleToVisibilityRuleMap(config Config) *sync.Map {
190 return config.Once(visibilityRuleMap, func() interface{} {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000191 return &sync.Map{}
192 }).(*sync.Map)
193}
194
Paul Duffin78ac5b92020-01-14 12:42:08 +0000195// Marker interface that identifies dependencies that are excluded from visibility
196// enforcement.
197type ExcludeFromVisibilityEnforcementTag interface {
198 blueprint.DependencyTag
199
200 // Method that differentiates this interface from others.
201 ExcludeFromVisibilityEnforcement()
202}
203
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100204// The rule checker needs to be registered before defaults expansion to correctly check that
205// //visibility:xxx isn't combined with other packages in the same list in any one module.
Paul Duffin593b3c92019-12-05 14:31:48 +0000206func RegisterVisibilityRuleChecker(ctx RegisterMutatorsContext) {
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100207 ctx.BottomUp("visibilityRuleChecker", visibilityRuleChecker).Parallel()
208}
209
Paul Duffine2453c72019-05-31 14:00:04 +0100210// Registers the function that gathers the visibility rules for each module.
211//
Paul Duffin2e61fa62019-03-28 14:10:57 +0000212// Visibility is not dependent on arch so this must be registered before the arch phase to avoid
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100213// having to process multiple variants for each module. This goes after defaults expansion to gather
Paul Duffine2453c72019-05-31 14:00:04 +0100214// the complete visibility lists from flat lists and after the package info is gathered to ensure
215// that default_visibility is available.
Paul Duffin593b3c92019-12-05 14:31:48 +0000216func RegisterVisibilityRuleGatherer(ctx RegisterMutatorsContext) {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000217 ctx.BottomUp("visibilityRuleGatherer", visibilityRuleGatherer).Parallel()
218}
219
220// This must be registered after the deps have been resolved.
Paul Duffin593b3c92019-12-05 14:31:48 +0000221func RegisterVisibilityRuleEnforcer(ctx RegisterMutatorsContext) {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000222 ctx.TopDown("visibilityRuleEnforcer", visibilityRuleEnforcer).Parallel()
223}
224
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100225// Checks the per-module visibility rule lists before defaults expansion.
226func visibilityRuleChecker(ctx BottomUpMutatorContext) {
227 qualified := createQualifiedModuleName(ctx)
Paul Duffin63c6e182019-07-24 14:24:38 +0100228 if m, ok := ctx.Module().(Module); ok {
Paul Duffine2453c72019-05-31 14:00:04 +0100229 visibilityProperties := m.visibilityProperties()
230 for _, p := range visibilityProperties {
231 if visibility := p.getStrings(); visibility != nil {
232 checkRules(ctx, qualified.pkg, p.getName(), visibility)
233 }
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100234 }
235 }
236}
237
Paul Duffine2453c72019-05-31 14:00:04 +0100238func checkRules(ctx BaseModuleContext, currentPkg, property string, visibility []string) {
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100239 ruleCount := len(visibility)
240 if ruleCount == 0 {
241 // This prohibits an empty list as its meaning is unclear, e.g. it could mean no visibility and
242 // it could mean public visibility. Requiring at least one rule makes the owner's intent
243 // clearer.
Paul Duffine2453c72019-05-31 14:00:04 +0100244 ctx.PropertyErrorf(property, "must contain at least one visibility rule")
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100245 return
246 }
247
248 for _, v := range visibility {
Paul Duffin0c83aba2020-05-01 18:13:36 +0100249 ok, pkg, name := splitRule(ctx, v, currentPkg, property)
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100250 if !ok {
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100251 continue
252 }
253
254 if pkg == "visibility" {
255 switch name {
256 case "private", "public":
257 case "legacy_public":
Paul Duffine2453c72019-05-31 14:00:04 +0100258 ctx.PropertyErrorf(property, "//visibility:legacy_public must not be used")
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100259 continue
260 default:
Paul Duffine2453c72019-05-31 14:00:04 +0100261 ctx.PropertyErrorf(property, "unrecognized visibility rule %q", v)
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100262 continue
263 }
264 if ruleCount != 1 {
Paul Duffine2453c72019-05-31 14:00:04 +0100265 ctx.PropertyErrorf(property, "cannot mix %q with any other visibility rules", v)
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100266 continue
267 }
268 }
269
270 // If the current directory is not in the vendor tree then there are some additional
271 // restrictions on the rules.
272 if !isAncestor("vendor", currentPkg) {
273 if !isAllowedFromOutsideVendor(pkg, name) {
Paul Duffine2453c72019-05-31 14:00:04 +0100274 ctx.PropertyErrorf(property,
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100275 "%q is not allowed. Packages outside //vendor cannot make themselves visible to specific"+
276 " targets within //vendor, they can only use //vendor:__subpackages__.", v)
277 continue
278 }
279 }
280 }
281}
282
283// Gathers the flattened visibility rules after defaults expansion, parses the visibility
284// properties, stores them in a map by qualifiedModuleName for retrieval during enforcement.
Paul Duffin2e61fa62019-03-28 14:10:57 +0000285//
286// See ../README.md#Visibility for information on the format of the visibility rules.
Paul Duffin2e61fa62019-03-28 14:10:57 +0000287func visibilityRuleGatherer(ctx BottomUpMutatorContext) {
288 m, ok := ctx.Module().(Module)
289 if !ok {
290 return
291 }
292
Paul Duffine2453c72019-05-31 14:00:04 +0100293 qualifiedModuleId := m.qualifiedModuleId(ctx)
294 currentPkg := qualifiedModuleId.pkg
Paul Duffin2e61fa62019-03-28 14:10:57 +0000295
Paul Duffin63c6e182019-07-24 14:24:38 +0100296 // Parse the visibility rules that control access to the module and store them by id
297 // for use when enforcing the rules.
Paul Duffin0c83aba2020-05-01 18:13:36 +0100298 primaryProperty := m.base().primaryVisibilityProperty
299 if primaryProperty != nil {
300 if visibility := primaryProperty.getStrings(); visibility != nil {
301 rule := parseRules(ctx, currentPkg, primaryProperty.getName(), visibility)
302 if rule != nil {
303 moduleToVisibilityRuleMap(ctx.Config()).Store(qualifiedModuleId, rule)
304 }
Paul Duffin2e61fa62019-03-28 14:10:57 +0000305 }
306 }
307}
308
Paul Duffin0c83aba2020-05-01 18:13:36 +0100309func parseRules(ctx BaseModuleContext, currentPkg, property string, visibility []string) compositeRule {
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100310 rules := make(compositeRule, 0, len(visibility))
311 hasPrivateRule := false
Paul Duffin44885e22020-02-19 16:10:09 +0000312 hasPublicRule := false
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100313 hasNonPrivateRule := false
Paul Duffin2e61fa62019-03-28 14:10:57 +0000314 for _, v := range visibility {
Paul Duffin0c83aba2020-05-01 18:13:36 +0100315 ok, pkg, name := splitRule(ctx, v, currentPkg, property)
Paul Duffin2e61fa62019-03-28 14:10:57 +0000316 if !ok {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000317 continue
318 }
319
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100320 var r visibilityRule
321 isPrivateRule := false
Paul Duffin2e61fa62019-03-28 14:10:57 +0000322 if pkg == "visibility" {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000323 switch name {
324 case "private":
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100325 r = privateRule{}
326 isPrivateRule = true
Paul Duffin2e61fa62019-03-28 14:10:57 +0000327 case "public":
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100328 r = publicRule{}
Paul Duffin44885e22020-02-19 16:10:09 +0000329 hasPublicRule = true
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100330 }
331 } else {
332 switch name {
333 case "__pkg__":
334 r = packageRule{pkg}
335 case "__subpackages__":
336 r = subpackagesRule{pkg}
Paul Duffin2e61fa62019-03-28 14:10:57 +0000337 default:
Paul Duffin2e61fa62019-03-28 14:10:57 +0000338 continue
339 }
340 }
341
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100342 if isPrivateRule {
343 hasPrivateRule = true
344 } else {
345 hasNonPrivateRule = true
Paul Duffin2e61fa62019-03-28 14:10:57 +0000346 }
347
348 rules = append(rules, r)
349 }
350
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100351 if hasPrivateRule && hasNonPrivateRule {
352 ctx.PropertyErrorf("visibility",
353 "cannot mix \"//visibility:private\" with any other visibility rules")
354 return compositeRule{privateRule{}}
355 }
356
Paul Duffin44885e22020-02-19 16:10:09 +0000357 if hasPublicRule {
358 // Public overrides all other rules so just return it.
359 return compositeRule{publicRule{}}
360 }
361
Paul Duffin2e61fa62019-03-28 14:10:57 +0000362 return rules
363}
364
365func isAllowedFromOutsideVendor(pkg string, name string) bool {
366 if pkg == "vendor" {
367 if name == "__subpackages__" {
368 return true
369 }
370 return false
371 }
372
373 return !isAncestor("vendor", pkg)
374}
375
Paul Duffin0c83aba2020-05-01 18:13:36 +0100376func splitRule(ctx BaseModuleContext, ruleExpression string, currentPkg, property string) (bool, string, string) {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000377 // Make sure that the rule is of the correct format.
378 matches := visibilityRuleRegexp.FindStringSubmatch(ruleExpression)
379 if ruleExpression == "" || matches == nil {
Paul Duffin0c83aba2020-05-01 18:13:36 +0100380 // Visibility rule is invalid so ignore it. Keep going rather than aborting straight away to
381 // ensure all the rules on this module are checked.
382 ctx.PropertyErrorf(property,
383 "invalid visibility pattern %q must match"+
384 " //<package>:<module>, //<package> or :<module>",
385 ruleExpression)
Paul Duffin2e61fa62019-03-28 14:10:57 +0000386 return false, "", ""
387 }
388
389 // Extract the package and name.
390 pkg := matches[1]
391 name := matches[2]
392
393 // Normalize the short hands
394 if pkg == "" {
395 pkg = currentPkg
396 }
397 if name == "" {
398 name = "__pkg__"
399 }
400
401 return true, pkg, name
402}
403
404func visibilityRuleEnforcer(ctx TopDownMutatorContext) {
Martin Stjernholm226b20d2019-05-17 22:42:02 +0100405 if _, ok := ctx.Module().(Module); !ok {
Paul Duffin2e61fa62019-03-28 14:10:57 +0000406 return
407 }
408
409 qualified := createQualifiedModuleName(ctx)
410
Paul Duffin2e61fa62019-03-28 14:10:57 +0000411 // Visit all the dependencies making sure that this module has access to them all.
412 ctx.VisitDirectDeps(func(dep Module) {
Paul Duffin78ac5b92020-01-14 12:42:08 +0000413 // Ignore dependencies that have an ExcludeFromVisibilityEnforcementTag
414 tag := ctx.OtherModuleDependencyTag(dep)
415 if _, ok := tag.(ExcludeFromVisibilityEnforcementTag); ok {
416 return
417 }
418
Paul Duffin2e61fa62019-03-28 14:10:57 +0000419 depName := ctx.OtherModuleName(dep)
420 depDir := ctx.OtherModuleDir(dep)
421 depQualified := qualifiedModuleName{depDir, depName}
422
423 // Targets are always visible to other targets in their own package.
424 if depQualified.pkg == qualified.pkg {
425 return
426 }
427
Paul Duffin44885e22020-02-19 16:10:09 +0000428 rule := effectiveVisibilityRules(ctx.Config(), depQualified)
Paul Duffine2453c72019-05-31 14:00:04 +0100429 if rule != nil && !rule.matches(qualified) {
430 ctx.ModuleErrorf("depends on %s which is not visible to this module", depQualified)
431 }
Paul Duffin2e61fa62019-03-28 14:10:57 +0000432 })
433}
434
Paul Duffin44885e22020-02-19 16:10:09 +0000435func effectiveVisibilityRules(config Config, qualified qualifiedModuleName) compositeRule {
436 moduleToVisibilityRule := moduleToVisibilityRuleMap(config)
Paul Duffin593b3c92019-12-05 14:31:48 +0000437 value, ok := moduleToVisibilityRule.Load(qualified)
438 var rule compositeRule
439 if ok {
440 rule = value.(compositeRule)
441 } else {
Paul Duffin44885e22020-02-19 16:10:09 +0000442 rule = packageDefaultVisibility(config, qualified)
Paul Duffin593b3c92019-12-05 14:31:48 +0000443 }
444 return rule
445}
446
Paul Duffin2e61fa62019-03-28 14:10:57 +0000447func createQualifiedModuleName(ctx BaseModuleContext) qualifiedModuleName {
448 moduleName := ctx.ModuleName()
449 dir := ctx.ModuleDir()
450 qualified := qualifiedModuleName{dir, moduleName}
451 return qualified
452}
Paul Duffine484f472019-06-20 16:38:08 +0100453
Paul Duffin44885e22020-02-19 16:10:09 +0000454func packageDefaultVisibility(config Config, moduleId qualifiedModuleName) compositeRule {
455 moduleToVisibilityRule := moduleToVisibilityRuleMap(config)
Paul Duffine484f472019-06-20 16:38:08 +0100456 packageQualifiedId := moduleId.getContainingPackageId()
457 for {
458 value, ok := moduleToVisibilityRule.Load(packageQualifiedId)
459 if ok {
460 return value.(compositeRule)
461 }
462
463 if packageQualifiedId.isRootPackage() {
464 return nil
465 }
466
467 packageQualifiedId = packageQualifiedId.getContainingPackageId()
468 }
469}
Paul Duffin593b3c92019-12-05 14:31:48 +0000470
471// Get the effective visibility rules, i.e. the actual rules that affect the visibility of the
472// property irrespective of where they are defined.
473//
474// Includes visibility rules specified by package default_visibility and/or on defaults.
475// Short hand forms, e.g. //:__subpackages__ are replaced with their full form, e.g.
476// //package/containing/rule:__subpackages__.
477func EffectiveVisibilityRules(ctx BaseModuleContext, module Module) []string {
478 moduleName := ctx.OtherModuleName(module)
479 dir := ctx.OtherModuleDir(module)
480 qualified := qualifiedModuleName{dir, moduleName}
481
Paul Duffin44885e22020-02-19 16:10:09 +0000482 rule := effectiveVisibilityRules(ctx.Config(), qualified)
Paul Duffin593b3c92019-12-05 14:31:48 +0000483
484 return rule.Strings()
485}
Paul Duffin5ec73ec2020-05-01 17:52:01 +0100486
487// Clear the default visibility properties so they can be replaced.
488func clearVisibilityProperties(module Module) {
489 module.base().visibilityPropertyInfo = nil
490}
491
492// Add a property that contains visibility rules so that they are checked for
493// correctness.
494func AddVisibilityProperty(module Module, name string, stringsProperty *[]string) {
495 addVisibilityProperty(module, name, stringsProperty)
496}
497
498func addVisibilityProperty(module Module, name string, stringsProperty *[]string) visibilityProperty {
499 base := module.base()
500 property := newVisibilityProperty(name, stringsProperty)
501 base.visibilityPropertyInfo = append(base.visibilityPropertyInfo, property)
502 return property
503}
504
505// Set the primary visibility property.
506//
507// Also adds the property to the list of properties to be validated.
508func setPrimaryVisibilityProperty(module Module, name string, stringsProperty *[]string) {
509 module.base().primaryVisibilityProperty = addVisibilityProperty(module, name, stringsProperty)
510}