Add phonies as provider instead of updaing a global map.
Bug: 358425833 Test: Manually compare the generated mk and ninja files. Change-Id: Ie74b620fc680ca2fc0d7836e88361ab3bdb87c49
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -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])
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user