Support customizing behavior around sourceOrOutputDependencyTag
Previously, modules customized behavior around the handling of sourceOrOutputDependencyTag by comparing them to android.SourceDepTag and retrieving the module using something like this: ctx.GetDirectDepWithTag(m, android.SourceDepTag) The problem with that is it does not allow an output tag to be specified and does not handle fully qualified names properly. This adds the following: * IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter also checks that it has the correct output tag. * GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for ctx.GetDirectDepWithTag(m, android.SourceDepTag). Replaces usages of: * t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "") * ctx.GetDirectDepWithTag(m, android.SourceDepTag) with GetModuleFromPathDep(ctx, m, "") It also deprecates the following: * android.SourcDepTag - as a follow up change needs to modify the sourceOrOutputDependencyTag will make this useless. * ExpandSources, ExpandsSources - copies existing deprecated messages from the implementation to the interface so that they can be seen by users of that interface. Bug: 193228441 Test: m nothing Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
This commit is contained in:
@@ -344,8 +344,18 @@ type ModuleContext interface {
|
|||||||
// Deprecated: use ModuleContext.Build instead.
|
// Deprecated: use ModuleContext.Build instead.
|
||||||
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
||||||
|
|
||||||
|
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
|
||||||
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
||||||
|
//
|
||||||
|
// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
|
||||||
ExpandSources(srcFiles, excludes []string) Paths
|
ExpandSources(srcFiles, excludes []string) Paths
|
||||||
|
|
||||||
|
// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
|
||||||
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
||||||
|
//
|
||||||
|
// Deprecated: use PathForModuleSrc instead.
|
||||||
ExpandSource(srcFile, prop string) Path
|
ExpandSource(srcFile, prop string) Path
|
||||||
|
|
||||||
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
||||||
|
|
||||||
// InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
|
// InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
|
||||||
@@ -2832,8 +2842,26 @@ func sourceOrOutputDepTag(tag string) blueprint.DependencyTag {
|
|||||||
return sourceOrOutputDependencyTag{tag: tag}
|
return sourceOrOutputDependencyTag{tag: tag}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated, use IsSourceDepTagWithOutputTag(tag, "") instead.
|
||||||
var SourceDepTag = sourceOrOutputDepTag("")
|
var SourceDepTag = sourceOrOutputDepTag("")
|
||||||
|
|
||||||
|
// IsSourceDepTag returns true if the supplied blueprint.DependencyTag is one that was used to add
|
||||||
|
// dependencies by either ExtractSourceDeps, ExtractSourcesDeps or automatically for properties
|
||||||
|
// tagged with `android:"path"`.
|
||||||
|
func IsSourceDepTag(depTag blueprint.DependencyTag) bool {
|
||||||
|
_, ok := depTag.(sourceOrOutputDependencyTag)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSourceDepTagWithOutputTag returns true if the supplied blueprint.DependencyTag is one that was
|
||||||
|
// used to add dependencies by either ExtractSourceDeps, ExtractSourcesDeps or automatically for
|
||||||
|
// properties tagged with `android:"path"` AND it was added using a module reference of
|
||||||
|
// :moduleName{outputTag}.
|
||||||
|
func IsSourceDepTagWithOutputTag(depTag blueprint.DependencyTag, outputTag string) bool {
|
||||||
|
t, ok := depTag.(sourceOrOutputDependencyTag)
|
||||||
|
return ok && t.tag == outputTag
|
||||||
|
}
|
||||||
|
|
||||||
// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
|
||||||
// using ":module" syntax, if any.
|
// using ":module" syntax, if any.
|
||||||
//
|
//
|
||||||
|
@@ -63,7 +63,8 @@ func (p *pathDepsMutatorTestModule) GenerateAndroidBuildActions(ctx ModuleContex
|
|||||||
|
|
||||||
if p.props.Foo != "" {
|
if p.props.Foo != "" {
|
||||||
// Make sure there is only one dependency on a module listed in a property present in multiple property structs
|
// Make sure there is only one dependency on a module listed in a property present in multiple property structs
|
||||||
if ctx.GetDirectDepWithTag(SrcIsModule(p.props.Foo), sourceOrOutputDepTag("")) == nil {
|
m := SrcIsModule(p.props.Foo)
|
||||||
|
if GetModuleFromPathDep(ctx, m, "") == nil {
|
||||||
ctx.ModuleErrorf("GetDirectDepWithTag failed")
|
ctx.ModuleErrorf("GetDirectDepWithTag failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -446,7 +446,7 @@ func (p OutputPaths) Strings() []string {
|
|||||||
// If the dependency is not found, a missingErrorDependency is returned.
|
// If the dependency is not found, a missingErrorDependency is returned.
|
||||||
// If the module dependency is not a SourceFileProducer or OutputFileProducer, appropriate errors will be returned.
|
// If the module dependency is not a SourceFileProducer or OutputFileProducer, appropriate errors will be returned.
|
||||||
func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag string) (Paths, error) {
|
func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag string) (Paths, error) {
|
||||||
module := ctx.GetDirectDepWithTag(moduleName, sourceOrOutputDepTag(tag))
|
module := GetModuleFromPathDep(ctx, moduleName, tag)
|
||||||
if module == nil {
|
if module == nil {
|
||||||
return nil, missingDependencyError{[]string{moduleName}}
|
return nil, missingDependencyError{[]string{moduleName}}
|
||||||
}
|
}
|
||||||
@@ -474,6 +474,22 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetModuleFromPathDep will return the module that was added as a dependency automatically for
|
||||||
|
// properties tagged with `android:"path"` or manually using ExtractSourceDeps or
|
||||||
|
// ExtractSourcesDeps.
|
||||||
|
//
|
||||||
|
// The moduleName and tag supplied to this should be the values returned from SrcIsModuleWithTag.
|
||||||
|
// Or, if no tag is expected then the moduleName should be the value returned by SrcIsModule and
|
||||||
|
// the tag must be "".
|
||||||
|
//
|
||||||
|
// 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))
|
||||||
|
}
|
||||||
|
|
||||||
// PathsAndMissingDepsForModuleSrcExcludes returns a Paths{} containing the resolved references in
|
// PathsAndMissingDepsForModuleSrcExcludes returns a Paths{} containing the resolved references in
|
||||||
// paths, minus those listed in excludes. Elements of paths and excludes are resolved as:
|
// paths, minus those listed in excludes. Elements of paths and excludes are resolved as:
|
||||||
// * filepath, relative to local module directory, resolves as a filepath relative to the local
|
// * filepath, relative to local module directory, resolves as a filepath relative to the local
|
||||||
|
@@ -990,7 +990,9 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
case procMacroDepTag:
|
case procMacroDepTag:
|
||||||
directProcMacroDeps = append(directProcMacroDeps, rustDep)
|
directProcMacroDeps = append(directProcMacroDeps, rustDep)
|
||||||
mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, makeLibName)
|
mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, makeLibName)
|
||||||
case android.SourceDepTag:
|
}
|
||||||
|
|
||||||
|
if android.IsSourceDepTagWithOutputTag(depTag, "") {
|
||||||
// Since these deps are added in path_properties.go via AddDependencies, we need to ensure the correct
|
// Since these deps are added in path_properties.go via AddDependencies, we need to ensure the correct
|
||||||
// OS/Arch variant is used.
|
// OS/Arch variant is used.
|
||||||
var helper string
|
var helper string
|
||||||
@@ -1120,8 +1122,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if srcDep, ok := dep.(android.SourceFileProducer); ok {
|
if srcDep, ok := dep.(android.SourceFileProducer); ok {
|
||||||
switch depTag {
|
if android.IsSourceDepTagWithOutputTag(depTag, "") {
|
||||||
case android.SourceDepTag:
|
|
||||||
// These are usually genrules which don't have per-target variants.
|
// These are usually genrules which don't have per-target variants.
|
||||||
directSrcDeps = append(directSrcDeps, srcDep)
|
directSrcDeps = append(directSrcDeps, srcDep)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user