Merge "Remove pre singletons" into main am: 228915b2f1
am: 90d740b3cb
am: 8e0f2903ef
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2814612 Change-Id: I00f39a9c9c21aeac9ce81ac523f156cbaa1123f8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
0387ee776d
2 changed files with 2 additions and 44 deletions
33
context.go
33
context.go
|
@ -84,7 +84,6 @@ type Context struct {
|
||||||
moduleGroups []*moduleGroup
|
moduleGroups []*moduleGroup
|
||||||
moduleInfo map[Module]*moduleInfo
|
moduleInfo map[Module]*moduleInfo
|
||||||
modulesSorted []*moduleInfo
|
modulesSorted []*moduleInfo
|
||||||
preSingletonInfo []*singletonInfo
|
|
||||||
singletonInfo []*singletonInfo
|
singletonInfo []*singletonInfo
|
||||||
mutatorInfo []*mutatorInfo
|
mutatorInfo []*mutatorInfo
|
||||||
variantMutatorNames []string
|
variantMutatorNames []string
|
||||||
|
@ -594,29 +593,6 @@ func (c *Context) RegisterSingletonType(name string, factory SingletonFactory, p
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterPreSingletonType registers a presingleton type that will be invoked to
|
|
||||||
// generate build actions before any Blueprint files have been read. Each registered
|
|
||||||
// presingleton type is instantiated and invoked exactly once at the beginning of the
|
|
||||||
// parse phase. Each registered presingleton is invoked in registration order.
|
|
||||||
//
|
|
||||||
// The presingleton type names given here must be unique for the context. The
|
|
||||||
// factory function should be a named function so that its package and name can
|
|
||||||
// be included in the generated Ninja file for debugging purposes.
|
|
||||||
func (c *Context) RegisterPreSingletonType(name string, factory SingletonFactory) {
|
|
||||||
for _, s := range c.preSingletonInfo {
|
|
||||||
if s.name == name {
|
|
||||||
panic(fmt.Errorf("presingleton %q is already registered", name))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c.preSingletonInfo = append(c.preSingletonInfo, &singletonInfo{
|
|
||||||
factory: factory,
|
|
||||||
singleton: factory(),
|
|
||||||
name: name,
|
|
||||||
parallel: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) SetNameInterface(i NameInterface) {
|
func (c *Context) SetNameInterface(i NameInterface) {
|
||||||
c.nameInterface = i
|
c.nameInterface = i
|
||||||
}
|
}
|
||||||
|
@ -1970,22 +1946,15 @@ func (c *Context) resolveDependencies(ctx context.Context, config interface{}) (
|
||||||
|
|
||||||
c.liveGlobals = newLiveTracker(c, config)
|
c.liveGlobals = newLiveTracker(c, config)
|
||||||
|
|
||||||
deps, errs = c.generateSingletonBuildActions(config, c.preSingletonInfo, c.liveGlobals)
|
|
||||||
if len(errs) > 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
errs = c.updateDependencies()
|
errs = c.updateDependencies()
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var mutatorDeps []string
|
deps, errs = c.runMutators(ctx, config)
|
||||||
mutatorDeps, errs = c.runMutators(ctx, config)
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
deps = append(deps, mutatorDeps...)
|
|
||||||
|
|
||||||
c.BeginEvent("clone_modules")
|
c.BeginEvent("clone_modules")
|
||||||
if !c.SkipCloneModulesAfterMutators {
|
if !c.SkipCloneModulesAfterMutators {
|
||||||
|
|
|
@ -556,16 +556,6 @@ func addNinjaDepsTestTopDownMutator(ctx TopDownMutatorContext) {
|
||||||
ctx.AddNinjaFileDeps("TopDownMutator")
|
ctx.AddNinjaFileDeps("TopDownMutator")
|
||||||
}
|
}
|
||||||
|
|
||||||
type addNinjaDepsTestPreSingleton struct{}
|
|
||||||
|
|
||||||
func addNinjaDepsTestPreSingletonFactory() Singleton {
|
|
||||||
return &addNinjaDepsTestPreSingleton{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *addNinjaDepsTestPreSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|
||||||
ctx.AddNinjaFileDeps("PreSingleton")
|
|
||||||
}
|
|
||||||
|
|
||||||
type addNinjaDepsTestSingleton struct{}
|
type addNinjaDepsTestSingleton struct{}
|
||||||
|
|
||||||
func addNinjaDepsTestSingletonFactory() Singleton {
|
func addNinjaDepsTestSingletonFactory() Singleton {
|
||||||
|
@ -589,7 +579,6 @@ func TestAddNinjaFileDeps(t *testing.T) {
|
||||||
ctx.RegisterModuleType("test", addNinjaDepsTestModuleFactory)
|
ctx.RegisterModuleType("test", addNinjaDepsTestModuleFactory)
|
||||||
ctx.RegisterBottomUpMutator("testBottomUpMutator", addNinjaDepsTestBottomUpMutator)
|
ctx.RegisterBottomUpMutator("testBottomUpMutator", addNinjaDepsTestBottomUpMutator)
|
||||||
ctx.RegisterTopDownMutator("testTopDownMutator", addNinjaDepsTestTopDownMutator)
|
ctx.RegisterTopDownMutator("testTopDownMutator", addNinjaDepsTestTopDownMutator)
|
||||||
ctx.RegisterPreSingletonType("testPreSingleton", addNinjaDepsTestPreSingletonFactory)
|
|
||||||
ctx.RegisterSingletonType("testSingleton", addNinjaDepsTestSingletonFactory, false)
|
ctx.RegisterSingletonType("testSingleton", addNinjaDepsTestSingletonFactory, false)
|
||||||
parseDeps, errs := ctx.ParseBlueprintsFiles("Android.bp", nil)
|
parseDeps, errs := ctx.ParseBlueprintsFiles("Android.bp", nil)
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
@ -622,7 +611,7 @@ func TestAddNinjaFileDeps(t *testing.T) {
|
||||||
t.Errorf("ParseBlueprintsFiles: wanted deps %q, got %q", w, g)
|
t.Errorf("ParseBlueprintsFiles: wanted deps %q, got %q", w, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
if g, w := resolveDeps, []string{"PreSingleton", "BottomUpMutator", "TopDownMutator"}; !reflect.DeepEqual(g, w) {
|
if g, w := resolveDeps, []string{"BottomUpMutator", "TopDownMutator"}; !reflect.DeepEqual(g, w) {
|
||||||
t.Errorf("ResolveDependencies: wanted deps %q, got %q", w, g)
|
t.Errorf("ResolveDependencies: wanted deps %q, got %q", w, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue