summaryrefslogtreecommitdiff
path: root/android/paths.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/paths.go')
-rw-r--r--android/paths.go35
1 files changed, 27 insertions, 8 deletions
diff --git a/android/paths.go b/android/paths.go
index c5e4806cf..bec8a51a2 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -88,7 +88,8 @@ func GlobFiles(ctx EarlyModulePathContext, globPattern string, excludes []string
// the Path methods that rely on module dependencies having been resolved.
type ModuleWithDepsPathContext interface {
EarlyModulePathContext
- GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
+ VisitDirectDepsBlueprint(visit func(blueprint.Module))
+ OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
}
// ModuleMissingDepsPathContext is a subset of *ModuleContext methods required by
@@ -484,10 +485,27 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag
//
// If tag is "" then the returned module will be the dependency that was added for ":moduleName".
// Otherwise, it is the dependency that was added for ":moduleName{tag}".
-//
-// TODO(b/193228441) Make this handle fully qualified names, e.g. //namespace:moduleName.
func GetModuleFromPathDep(ctx ModuleWithDepsPathContext, moduleName, tag string) blueprint.Module {
- return ctx.GetDirectDepWithTag(moduleName, sourceOrOutputDepTag(tag))
+ var found blueprint.Module
+ // The sourceOrOutputDepTag uniquely identifies the module dependency as it contains both the
+ // module name and the tag. Dependencies added automatically for properties tagged with
+ // `android:"path"` are deduped so are guaranteed to be unique. It is possible for duplicate
+ // dependencies to be added manually using ExtractSourcesDeps or ExtractSourceDeps but even then
+ // it will always be the case that the dependencies will be identical, i.e. the same tag and same
+ // moduleName referring to the same dependency module.
+ //
+ // It does not matter whether the moduleName is a fully qualified name or if the module
+ // dependency is a prebuilt module. All that matters is the same information is supplied to
+ // create the tag here as was supplied to create the tag when the dependency was added so that
+ // this finds the matching dependency module.
+ expectedTag := sourceOrOutputDepTag(moduleName, tag)
+ ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
+ depTag := ctx.OtherModuleDependencyTag(module)
+ if depTag == expectedTag {
+ found = module
+ }
+ })
+ return found
}
// PathsAndMissingDepsForModuleSrcExcludes returns a Paths{} containing the resolved references in
@@ -1268,10 +1286,11 @@ var _ resPathProvider = SourcePath{}
// PathForModuleSrc returns a Path representing the paths... under the
// module's local source directory.
func PathForModuleSrc(ctx ModuleMissingDepsPathContext, pathComponents ...string) Path {
- p, err := validatePath(pathComponents...)
- if err != nil {
- reportPathError(ctx, err)
- }
+ // Just join the components textually just to make sure that it does not corrupt a fully qualified
+ // module reference, e.g. if the pathComponents is "://other:foo" then using filepath.Join() or
+ // validatePath() will corrupt it, e.g. replace "//" with "/". If the path is not a module
+ // reference then it will be validated by expandOneSrcPath anyway when it calls expandOneSrcPath.
+ p := strings.Join(pathComponents, string(filepath.Separator))
paths, err := expandOneSrcPath(ctx, p, nil)
if err != nil {
if depErr, ok := err.(missingDependencyError); ok {