summaryrefslogtreecommitdiff
path: root/sdk/update.go
diff options
context:
space:
mode:
Diffstat (limited to 'sdk/update.go')
-rw-r--r--sdk/update.go56
1 files changed, 35 insertions, 21 deletions
diff --git a/sdk/update.go b/sdk/update.go
index 537ab13cb..f29b5a00c 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -300,7 +300,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
snapshotModule.AddProperty("name", snapshotName)
// Make sure that the snapshot has the same visibility as the sdk.
- visibility := android.EffectiveVisibilityRules(ctx, s)
+ visibility := android.EffectiveVisibilityRules(ctx, s).Strings()
if len(visibility) != 0 {
snapshotModule.AddProperty("visibility", visibility)
}
@@ -371,8 +371,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
osPropertySet := targetPropertySet.AddPropertySet(sdkVariant.Target().Os.Name)
// Enable the variant explicitly when we've disabled it by default on host.
- if hasHostOsDependentMember &&
- (osType.Class == android.Host || osType.Class == android.HostCross) {
+ if hasHostOsDependentMember && osType.Class == android.Host {
osPropertySet.AddProperty("enabled", true)
}
@@ -720,7 +719,15 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType
} else {
// Extract visibility information from a member variant. All variants have the same
// visibility so it doesn't matter which one is used.
- visibility := android.EffectiveVisibilityRules(s.ctx, variant)
+ visibilityRules := android.EffectiveVisibilityRules(s.ctx, variant)
+
+ // Add any additional visibility rules needed for the prebuilts to reference each other.
+ err := visibilityRules.Widen(s.sdk.properties.Prebuilt_visibility)
+ if err != nil {
+ s.ctx.PropertyErrorf("prebuilt_visibility", "%s", err)
+ }
+
+ visibility := visibilityRules.Strings()
if len(visibility) != 0 {
m.AddProperty("visibility", visibility)
}
@@ -731,7 +738,7 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType
for _, variant := range member.Variants() {
osClass := variant.Target().Os.Class
- if osClass == android.Host || osClass == android.HostCross {
+ if osClass == android.Host {
hostSupported = true
} else if osClass == android.Device {
deviceSupported = true
@@ -1061,8 +1068,7 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
archPropertySet = targetPropertySet
// Enable the variant explicitly when we've disabled it by default on host.
- if ctx.memberType.IsHostOsDependent() &&
- (osType.Class == android.Host || osType.Class == android.HostCross) {
+ if ctx.memberType.IsHostOsDependent() && osType.Class == android.Host {
osPropertySet.AddProperty("enabled", true)
}
@@ -1086,7 +1092,7 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
func (osInfo *osTypeSpecificInfo) isHostVariant() bool {
osClass := osInfo.osType.Class
- return osClass == android.Host || osClass == android.HostCross
+ return osClass == android.Host
}
var _ isHostVariant = (*osTypeSpecificInfo)(nil)
@@ -1323,7 +1329,7 @@ func (s *sdk) getPossibleOsTypes() []android.OsType {
}
}
if s.HostSupported() {
- if osType.Class == android.Host || osType.Class == android.HostCross {
+ if osType.Class == android.Host {
osTypes = append(osTypes, osType)
}
}
@@ -1348,7 +1354,8 @@ type isHostVariant interface {
// A property that can be optimized by the commonValueExtractor.
type extractorProperty struct {
- // The name of the field for this property.
+ // The name of the field for this property. It is a "."-separated path for
+ // fields in non-anonymous substructs.
name string
// Filter that can use metadata associated with the properties being optimized
@@ -1385,18 +1392,18 @@ type commonValueExtractor struct {
func newCommonValueExtractor(propertiesStruct interface{}) *commonValueExtractor {
structType := getStructValue(reflect.ValueOf(propertiesStruct)).Type()
extractor := &commonValueExtractor{}
- extractor.gatherFields(structType, nil)
+ extractor.gatherFields(structType, nil, "")
return extractor
}
// Gather the fields from the supplied structure type from which common values will
// be extracted.
//
-// This is recursive function. If it encounters an embedded field (no field name)
-// that is a struct then it will recurse into that struct passing in the accessor
-// for the field. That will then be used in the accessors for the fields in the
-// embedded struct.
-func (e *commonValueExtractor) gatherFields(structType reflect.Type, containingStructAccessor fieldAccessorFunc) {
+// This is recursive function. If it encounters a struct then it will recurse
+// into it, passing in the accessor for the field and the struct name as prefix
+// for the nested fields. That will then be used in the accessors for the fields
+// in the embedded struct.
+func (e *commonValueExtractor) gatherFields(structType reflect.Type, containingStructAccessor fieldAccessorFunc, namePrefix string) {
for f := 0; f < structType.NumField(); f++ {
field := structType.Field(f)
if field.PkgPath != "" {
@@ -1426,7 +1433,7 @@ func (e *commonValueExtractor) gatherFields(structType reflect.Type, containingS
// Save a copy of the field index for use in the function.
fieldIndex := f
- name := field.Name
+ name := namePrefix + field.Name
fieldGetter := func(value reflect.Value) reflect.Value {
if containingStructAccessor != nil {
@@ -1448,9 +1455,15 @@ func (e *commonValueExtractor) gatherFields(structType reflect.Type, containingS
return value.Field(fieldIndex)
}
- if field.Type.Kind() == reflect.Struct && field.Anonymous {
- // Gather fields from the embedded structure.
- e.gatherFields(field.Type, fieldGetter)
+ if field.Type.Kind() == reflect.Struct {
+ // Gather fields from the nested or embedded structure.
+ var subNamePrefix string
+ if field.Anonymous {
+ subNamePrefix = namePrefix
+ } else {
+ subNamePrefix = name + "."
+ }
+ e.gatherFields(field.Type, fieldGetter, subNamePrefix)
} else {
property := extractorProperty{
name,
@@ -1514,7 +1527,8 @@ func (c dynamicMemberPropertiesContainer) String() string {
// Iterates over each exported field (capitalized name) and checks to see whether they
// have the same value (using DeepEquals) across all the input properties. If it does not then no
// change is made. Otherwise, the common value is stored in the field in the commonProperties
-// and the field in each of the input properties structure is set to its default value.
+// and the field in each of the input properties structure is set to its default value. Nested
+// structs are visited recursively and their non-struct fields are compared.
func (e *commonValueExtractor) extractCommonProperties(commonProperties interface{}, inputPropertiesSlice interface{}) error {
commonPropertiesValue := reflect.ValueOf(commonProperties)
commonStructValue := commonPropertiesValue.Elem()