diff --git a/android/module.go b/android/module.go index 664ac5c71..d1f8b3606 100644 --- a/android/module.go +++ b/android/module.go @@ -1797,6 +1797,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) bp: blueprintCtx, baseModuleContext: m.baseModuleContextFactory(blueprintCtx), variables: make(map[string]string), + phonies: make(map[string]Paths), } setContainerInfo(ctx) @@ -2052,6 +2053,11 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) SetProvider(ctx, OutputFilesProvider, m.outputFiles) } + if len(ctx.phonies) > 0 { + SetProvider(ctx, ModulePhonyProvider, ModulePhonyInfo{ + Phonies: ctx.phonies, + }) + } buildComplianceMetadataProvider(ctx, m) } diff --git a/android/module_context.go b/android/module_context.go index f619da2ba..514678222 100644 --- a/android/module_context.go +++ b/android/module_context.go @@ -361,7 +361,7 @@ func (m *moduleContext) Build(pctx PackageContext, params BuildParams) { } func (m *moduleContext) Phony(name string, deps ...Path) { - addPhony(m.config, name, deps...) + m.phonies[name] = append(m.phonies[name], deps...) } func (m *moduleContext) GetMissingDependencies() []string { diff --git a/android/phony.go b/android/phony.go index 814a9e30a..f8db88d43 100644 --- a/android/phony.go +++ b/android/phony.go @@ -26,14 +26,20 @@ type phonyMap map[string]Paths var phonyMapLock sync.Mutex -func getPhonyMap(config Config) phonyMap { +type ModulePhonyInfo struct { + Phonies map[string]Paths +} + +var ModulePhonyProvider = blueprint.NewProvider[ModulePhonyInfo]() + +func getSingletonPhonyMap(config Config) phonyMap { return config.Once(phonyMapOnceKey, func() interface{} { return make(phonyMap) }).(phonyMap) } -func addPhony(config Config, name string, deps ...Path) { - phonyMap := getPhonyMap(config) +func addSingletonPhony(config Config, name string, deps ...Path) { + phonyMap := getSingletonPhonyMap(config) phonyMapLock.Lock() defer phonyMapLock.Unlock() phonyMap[name] = append(phonyMap[name], deps...) @@ -47,7 +53,15 @@ type phonySingleton struct { var _ SingletonMakeVarsProvider = (*phonySingleton)(nil) func (p *phonySingleton) GenerateBuildActions(ctx SingletonContext) { - p.phonyMap = getPhonyMap(ctx.Config()) + p.phonyMap = getSingletonPhonyMap(ctx.Config()) + ctx.VisitAllModules(func(m Module) { + if info, ok := OtherModuleProvider(ctx, m, ModulePhonyProvider); ok { + for k, v := range info.Phonies { + p.phonyMap[k] = append(p.phonyMap[k], v...) + } + } + }) + p.phonyList = SortedKeys(p.phonyMap) for _, phony := range p.phonyList { p.phonyMap[phony] = SortedUniquePaths(p.phonyMap[phony]) diff --git a/android/singleton.go b/android/singleton.go index 92264d2e3..8542bd9e6 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -177,7 +177,7 @@ func (s *singletonContextAdaptor) Build(pctx PackageContext, params BuildParams) } func (s *singletonContextAdaptor) Phony(name string, deps ...Path) { - addPhony(s.Config(), name, deps...) + addSingletonPhony(s.Config(), name, deps...) } func (s *singletonContextAdaptor) SetOutDir(pctx PackageContext, value string) {