Merge "Make the defaults property non-configurable" into main
This commit is contained in:
@@ -28,7 +28,7 @@ type defaultsDependencyTag struct {
|
|||||||
var DefaultsDepTag defaultsDependencyTag
|
var DefaultsDepTag defaultsDependencyTag
|
||||||
|
|
||||||
type defaultsProperties struct {
|
type defaultsProperties struct {
|
||||||
Defaults proptools.Configurable[[]string]
|
Defaults []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DefaultableModuleBase struct {
|
type DefaultableModuleBase struct {
|
||||||
@@ -278,13 +278,13 @@ func RegisterDefaultsPreArchMutators(ctx RegisterMutatorsContext) {
|
|||||||
|
|
||||||
func defaultsDepsMutator(ctx BottomUpMutatorContext) {
|
func defaultsDepsMutator(ctx BottomUpMutatorContext) {
|
||||||
if defaultable, ok := ctx.Module().(Defaultable); ok {
|
if defaultable, ok := ctx.Module().(Defaultable); ok {
|
||||||
ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults.GetOrDefault(ctx, nil)...)
|
ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultsMutator(ctx TopDownMutatorContext) {
|
func defaultsMutator(ctx TopDownMutatorContext) {
|
||||||
if defaultable, ok := ctx.Module().(Defaultable); ok {
|
if defaultable, ok := ctx.Module().(Defaultable); ok {
|
||||||
defaults := defaultable.defaults().Defaults.GetOrDefault(ctx, nil)
|
defaults := defaultable.defaults().Defaults
|
||||||
if len(defaults) > 0 {
|
if len(defaults) > 0 {
|
||||||
var defaultsList []Defaults
|
var defaultsList []Defaults
|
||||||
seen := make(map[Defaults]bool)
|
seen := make(map[Defaults]bool)
|
||||||
@@ -295,7 +295,7 @@ func defaultsMutator(ctx TopDownMutatorContext) {
|
|||||||
if !seen[defaults] {
|
if !seen[defaults] {
|
||||||
seen[defaults] = true
|
seen[defaults] = true
|
||||||
defaultsList = append(defaultsList, defaults)
|
defaultsList = append(defaultsList, defaults)
|
||||||
return len(defaults.defaults().Defaults.GetOrDefault(ctx, nil)) > 0
|
return len(defaults.defaults().Defaults) > 0
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
|
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
|
||||||
|
@@ -722,6 +722,7 @@ test {
|
|||||||
propInfo{Name: "Arch.X86_64.A", Type: "string", Value: "x86_64 a"},
|
propInfo{Name: "Arch.X86_64.A", Type: "string", Value: "x86_64 a"},
|
||||||
propInfo{Name: "B", Type: "bool", Value: "true"},
|
propInfo{Name: "B", Type: "bool", Value: "true"},
|
||||||
propInfo{Name: "C", Type: "string slice", Values: []string{"default_c", "c"}},
|
propInfo{Name: "C", Type: "string slice", Values: []string{"default_c", "c"}},
|
||||||
|
propInfo{Name: "Defaults", Type: "string slice", Values: []string{"foo_defaults"}},
|
||||||
propInfo{Name: "Embedded_prop", Type: "string", Value: "a"},
|
propInfo{Name: "Embedded_prop", Type: "string", Value: "a"},
|
||||||
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
propInfo{Name: "Name", Type: "string", Value: "foo"},
|
||||||
propInfo{Name: "Nested.E", Type: "string", Value: "nested e"},
|
propInfo{Name: "Nested.E", Type: "string", Value: "nested e"},
|
||||||
|
Reference in New Issue
Block a user