Merge \"Allow defaults modules to have defaults\"
am: 2846cc448b
Change-Id: I12aaa8f7de21fb2732846aa57320ee5b81087a18
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator)
|
RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator)
|
||||||
RegisterTopDownMutator("defaults", defaultsMutator)
|
RegisterBottomUpMutator("defaults", defaultsMutator)
|
||||||
|
|
||||||
RegisterBottomUpMutator("arch", ArchMutator)
|
RegisterBottomUpMutator("arch", ArchMutator)
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ func (d *DefaultableModule) setProperties(props []interface{}) {
|
|||||||
type Defaultable interface {
|
type Defaultable interface {
|
||||||
defaults() *defaultsProperties
|
defaults() *defaultsProperties
|
||||||
setProperties([]interface{})
|
setProperties([]interface{})
|
||||||
applyDefaults(TopDownMutatorContext, Defaults)
|
applyDefaults(BottomUpMutatorContext, Defaults)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Defaultable = (*DefaultableModule)(nil)
|
var _ Defaultable = (*DefaultableModule)(nil)
|
||||||
@@ -61,12 +61,13 @@ func InitDefaultableModule(module Module, d Defaultable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DefaultsModule struct {
|
type DefaultsModule struct {
|
||||||
|
DefaultableModule
|
||||||
defaultProperties []interface{}
|
defaultProperties []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Defaults interface {
|
type Defaults interface {
|
||||||
|
Defaultable
|
||||||
isDefaults() bool
|
isDefaults() bool
|
||||||
setProperties([]interface{})
|
|
||||||
properties() []interface{}
|
properties() []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,22 +76,16 @@ func (d *DefaultsModule) isDefaults() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DefaultsModule) properties() []interface{} {
|
func (d *DefaultsModule) properties() []interface{} {
|
||||||
return d.defaultProperties
|
return d.defaultableProperties
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DefaultsModule) setProperties(props []interface{}) {
|
|
||||||
d.defaultProperties = props
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitDefaultsModule(module Module, d Defaults, props ...interface{}) (blueprint.Module, []interface{}) {
|
func InitDefaultsModule(module Module, d Defaults, props ...interface{}) (blueprint.Module, []interface{}) {
|
||||||
d.setProperties(props)
|
return InitDefaultableModule(module, d, props...)
|
||||||
|
|
||||||
return module, props
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Defaults = (*DefaultsModule)(nil)
|
var _ Defaults = (*DefaultsModule)(nil)
|
||||||
|
|
||||||
func (defaultable *DefaultableModule) applyDefaults(ctx TopDownMutatorContext,
|
func (defaultable *DefaultableModule) applyDefaults(ctx BottomUpMutatorContext,
|
||||||
defaults Defaults) {
|
defaults Defaults) {
|
||||||
|
|
||||||
for _, prop := range defaultable.defaultableProperties {
|
for _, prop := range defaultable.defaultableProperties {
|
||||||
@@ -115,7 +110,7 @@ func defaultsDepsMutator(ctx BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultsMutator(ctx TopDownMutatorContext) {
|
func defaultsMutator(ctx BottomUpMutatorContext) {
|
||||||
if defaultable, ok := ctx.Module().(Defaultable); ok {
|
if defaultable, ok := ctx.Module().(Defaultable); ok {
|
||||||
for _, defaultsDep := range defaultable.defaults().Defaults {
|
for _, defaultsDep := range defaultable.defaults().Defaults {
|
||||||
ctx.VisitDirectDeps(func(m blueprint.Module) {
|
ctx.VisitDirectDeps(func(m blueprint.Module) {
|
||||||
|
Reference in New Issue
Block a user