Allow deferred module build action generation. am: 67a6d702d1
am: 1739902dcf
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2099161 Change-Id: Ibe2775cfb6af169603ccd9ec9cb1141271ed80c7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
d3f68a1702
1 changed files with 27 additions and 0 deletions
|
@ -157,6 +157,10 @@ type SingletonContext interface {
|
|||
// Fs returns a pathtools.Filesystem that can be used to interact with files. Using the Filesystem interface allows
|
||||
// the singleton to be used in build system tests that run against a mock filesystem.
|
||||
Fs() pathtools.FileSystem
|
||||
|
||||
// ModuleVariantsFromName returns the list of module variants named `name` in the same namespace as `referer`.
|
||||
// Allows generating build actions for `referer` based on the metadata for `name` deferred until the singleton context.
|
||||
ModuleVariantsFromName(referer Module, name string) []Module
|
||||
}
|
||||
|
||||
var _ SingletonContext = (*singletonContext)(nil)
|
||||
|
@ -369,3 +373,26 @@ func (s *singletonContext) GlobWithDeps(pattern string,
|
|||
func (s *singletonContext) Fs() pathtools.FileSystem {
|
||||
return s.context.fs
|
||||
}
|
||||
|
||||
func (s *singletonContext) ModuleVariantsFromName(referer Module, name string) []Module {
|
||||
c := s.context
|
||||
|
||||
refererInfo := c.moduleInfo[referer]
|
||||
if refererInfo == nil {
|
||||
s.ModuleErrorf(referer, "could not find module %q", referer.Name())
|
||||
return nil
|
||||
}
|
||||
|
||||
moduleGroup, exists := c.nameInterface.ModuleFromName(name, refererInfo.namespace())
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
result := make([]Module, 0, len(moduleGroup.modules))
|
||||
for _, module := range moduleGroup.modules {
|
||||
moduleInfo := module.module()
|
||||
if moduleInfo != nil {
|
||||
result = append(result, moduleInfo.logicModule)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue