Add visibility support

Implementation uploaded for review. Includes unit tests but does not
yet handle prebuilts, that will come in a future change once some
more general issues with prebuilts and namespaces is resolved.

See README.md#Visibility for details of what this does and how to use
it.

Bug: 112158820
Test: add visibility rules for core library modules, make core-tests
Change-Id: I8ec980554398ad6f2d42043ce518f811a35da679
This commit is contained in:
Paul Duffin
2019-03-28 14:10:57 +00:00
parent 02cbe8f1c6
commit 2e61fa6e14
7 changed files with 894 additions and 9 deletions

View File

@@ -26,12 +26,6 @@ import (
"github.com/google/blueprint"
)
// This file implements namespaces
const (
namespacePrefix = "//"
modulePrefix = ":"
)
func init() {
RegisterModuleType("soong_namespace", NamespaceFactory)
}
@@ -215,11 +209,11 @@ func (r *NameResolver) AllModules() []blueprint.ModuleGroup {
// parses a fully-qualified path (like "//namespace_path:module_name") into a namespace name and a
// module name
func (r *NameResolver) parseFullyQualifiedName(name string) (namespaceName string, moduleName string, ok bool) {
if !strings.HasPrefix(name, namespacePrefix) {
if !strings.HasPrefix(name, "//") {
return "", "", false
}
name = strings.TrimPrefix(name, namespacePrefix)
components := strings.Split(name, modulePrefix)
name = strings.TrimPrefix(name, "//")
components := strings.Split(name, ":")
if len(components) != 2 {
return "", "", false
}