diff options
author | Paul Duffin <paulduffin@google.com> | 2020-03-17 12:51:37 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2020-04-22 12:51:41 +0100 |
commit | 4a4b2d0b1b2b1cf0f04db7bb376057e698ad7789 (patch) | |
tree | 4ffcd391055948a6aaa794a5b585074b80bf5e13 /sdk | |
parent | 6562ce14570e69da7b6ec2db8c62a6ccec541edd (diff) | |
download | build_soong-4a4b2d0b1b2b1cf0f04db7bb376057e698ad7789.tar.gz build_soong-4a4b2d0b1b2b1cf0f04db7bb376057e698ad7789.tar.bz2 build_soong-4a4b2d0b1b2b1cf0f04db7bb376057e698ad7789.zip |
Extract archTypeSpecificInfo code from module creation loop
Extract the functionality to create an archTypeSpecificInfo struct and
to add its properties to a property set into methods of the
*archTypeSpecificInfo struct.
Bug: 153306490
Test: m nothing
Bug: 142918168
Merged-In: I2a9e0327b61bce7ad7699cd75de17aa0e5f1ebbb
Change-Id: I2a9e0327b61bce7ad7699cd75de17aa0e5f1ebbb
Diffstat (limited to 'sdk')
-rw-r--r-- | sdk/update.go | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/sdk/update.go b/sdk/update.go index d077e40a..1cff25ae 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -799,12 +799,40 @@ type osTypeSpecificInfo struct { archInfos []*archTypeSpecificInfo } +type variantPropertiesFactoryFunc func() android.SdkMemberProperties + type archTypeSpecificInfo struct { baseInfo archType android.ArchType } +// Create a new archTypeSpecificInfo for the specified arch type and its properties +// structures populated with information from the variants. +func newArchSpecificInfo(archType android.ArchType, variantPropertiesFactory variantPropertiesFactoryFunc, archVariants []android.SdkAware) *archTypeSpecificInfo { + + if len(archVariants) != 1 { + panic(fmt.Errorf("expected one arch specific variant but found %d", len(archVariants))) + } + + // Create an arch specific info into which the variant properties can be copied. + archInfo := &archTypeSpecificInfo{archType: archType} + + // Create the properties into which the arch type specific properties will be + // added. + archInfo.Properties = variantPropertiesFactory() + archInfo.Properties.PopulateFromVariant(archVariants[0]) + + return archInfo +} + +// Add the properties for an arch type to a property set. +func (archInfo *archTypeSpecificInfo) addToPropertySet(builder *snapshotBuilder, archPropertySet android.BpPropertySet, archOsPrefix string) { + archTypeName := archInfo.archType.Name + archTypePropertySet := archPropertySet.AddPropertySet(archOsPrefix + archTypeName) + archInfo.Properties.AddToPropertySet(builder.ctx, builder, archTypePropertySet) +} + func (s *sdk) createMemberSnapshot(sdkModuleContext android.ModuleContext, builder *snapshotBuilder, member *sdkMember, bpModule android.BpModule) { memberType := member.memberType @@ -881,17 +909,7 @@ func (s *sdk) createMemberSnapshot(sdkModuleContext android.ModuleContext, build archTypeName := archType.Name archVariants := variantsByArchName[archTypeName] - if len(archVariants) != 1 { - panic(fmt.Errorf("expected one arch specific variant but found %d", len(variants))) - } - - // Create an arch specific info into which the variant properties can be copied. - archInfo := &archTypeSpecificInfo{archType: archType} - - // Create the properties into which the arch type specific properties will be - // added. - archInfo.Properties = osSpecificVariantPropertiesFactory() - archInfo.Properties.PopulateFromVariant(archVariants[0]) + archInfo := newArchSpecificInfo(archType, osSpecificVariantPropertiesFactory, archVariants) osInfo.archInfos = append(osInfo.archInfos, archInfo) } @@ -990,9 +1008,7 @@ func (s *sdk) createMemberSnapshot(sdkModuleContext android.ModuleContext, build // // The archInfos list will be empty if the os contains variants for the common for _, archInfo := range osInfo.archInfos { - archTypePropertySet := archPropertySet.AddPropertySet(archOsPrefix + archInfo.archType.Name) - - archInfo.Properties.AddToPropertySet(sdkModuleContext, builder, archTypePropertySet) + archInfo.addToPropertySet(builder, archPropertySet, archOsPrefix) } } } |