diff options
Diffstat (limited to 'android/path_properties.go')
-rw-r--r-- | android/path_properties.go | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/android/path_properties.go b/android/path_properties.go index d80a8ed13..8ada1330c 100644 --- a/android/path_properties.go +++ b/android/path_properties.go @@ -18,6 +18,7 @@ import ( "fmt" "reflect" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -38,20 +39,32 @@ func pathDepsMutator(ctx BottomUpMutatorContext) { // squashed into the real modules. return } + if !ctx.Module().Enabled(ctx) { + return + } props := ctx.Module().base().GetProperties() addPathDepsForProps(ctx, props) } func addPathDepsForProps(ctx BottomUpMutatorContext, props []interface{}) { // Iterate through each property struct of the module extracting the contents of all properties - // tagged with `android:"path"`. + // tagged with `android:"path"` or one of the variant-specifying tags. var pathProperties []string + var pathDeviceFirstProperties []string + var pathDeviceCommonProperties []string + var pathCommonOsProperties []string for _, ps := range props { - pathProperties = append(pathProperties, pathPropertiesForPropertyStruct(ctx, ps)...) + pathProperties = append(pathProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path")...) + pathDeviceFirstProperties = append(pathDeviceFirstProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path_device_first")...) + pathDeviceCommonProperties = append(pathDeviceCommonProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path_device_common")...) + pathCommonOsProperties = append(pathCommonOsProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path_common_os")...) } // Remove duplicates to avoid multiple dependencies. pathProperties = FirstUniqueStrings(pathProperties) + pathDeviceFirstProperties = FirstUniqueStrings(pathDeviceFirstProperties) + pathDeviceCommonProperties = FirstUniqueStrings(pathDeviceCommonProperties) + pathCommonOsProperties = FirstUniqueStrings(pathCommonOsProperties) // Add dependencies to anything that is a module reference. for _, s := range pathProperties { @@ -59,12 +72,35 @@ func addPathDepsForProps(ctx BottomUpMutatorContext, props []interface{}) { ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(m, t), m) } } + // For properties tagged "path_device_first", use the first arch device variant when adding + // dependencies. This allows host modules to have some properties that add dependencies on + // device modules. + for _, s := range pathDeviceFirstProperties { + if m, t := SrcIsModuleWithTag(s); m != "" { + ctx.AddVariationDependencies(ctx.Config().AndroidFirstDeviceTarget.Variations(), sourceOrOutputDepTag(m, t), m) + } + } + // properties tagged "path_device_common" get the device common variant + for _, s := range pathDeviceCommonProperties { + if m, t := SrcIsModuleWithTag(s); m != "" { + ctx.AddVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), sourceOrOutputDepTag(m, t), m) + } + } + // properties tagged "path_device_common" get the device common variant + for _, s := range pathCommonOsProperties { + if m, t := SrcIsModuleWithTag(s); m != "" { + ctx.AddVariationDependencies([]blueprint.Variation{ + {Mutator: "os", Variation: "common_os"}, + {Mutator: "arch", Variation: ""}, + }, sourceOrOutputDepTag(m, t), m) + } + } } -// pathPropertiesForPropertyStruct uses the indexes of properties that are tagged with -// android:"path" to extract all their values from a property struct, returning them as a single +// taggedPropertiesForPropertyStruct uses the indexes of properties that are tagged with +// android:"tagValue" to extract all their values from a property struct, returning them as a single // slice of strings. -func pathPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{}) []string { +func taggedPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{}, tagValue string) []string { v := reflect.ValueOf(ps) if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct { panic(fmt.Errorf("type %s is not a pointer to a struct", v.Type())) @@ -79,7 +115,7 @@ func pathPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{}) v = v.Elem() // Get or create the list of indexes of properties that are tagged with `android:"path"`. - pathPropertyIndexes := pathPropertyIndexesForPropertyStruct(ps) + pathPropertyIndexes := taggedPropertyIndexesForPropertyStruct(ps, tagValue) var ret []string @@ -172,12 +208,20 @@ func isSliceOfStruct(v reflect.Value) bool { var pathPropertyIndexesCache OncePer -// pathPropertyIndexesForPropertyStruct returns a list of all of the indexes of properties in -// property struct type that are tagged with `android:"path"`. Each index is a []int suitable for -// passing to reflect.Value.FieldByIndex. The value is cached in a global cache by type. -func pathPropertyIndexesForPropertyStruct(ps interface{}) [][]int { - key := NewCustomOnceKey(reflect.TypeOf(ps)) +// taggedPropertyIndexesForPropertyStruct returns a list of all of the indexes of properties in +// property struct type that are tagged with `android:"tagValue"`. Each index is a []int suitable +// for passing to reflect.Value.FieldByIndex. The value is cached in a global cache by type and +// tagValue. +func taggedPropertyIndexesForPropertyStruct(ps interface{}, tagValue string) [][]int { + type pathPropertyIndexesOnceKey struct { + propStructType reflect.Type + tagValue string + } + key := NewCustomOnceKey(pathPropertyIndexesOnceKey{ + propStructType: reflect.TypeOf(ps), + tagValue: tagValue, + }) return pathPropertyIndexesCache.Once(key, func() interface{} { - return proptools.PropertyIndexesWithTag(ps, "android", "path") + return proptools.PropertyIndexesWithTag(ps, "android", tagValue) }).([][]int) } |