Remove old SdkMemberType API for creating snapshot modules
Migrates system modules and droid stubs over to use the new API for creating the snapshot modules and removes the old API. Bug: 153306490 Test: m nothing Merged-In: Ia825767f1f7ee77f68cfe00f53e09e6f6bfa027f Change-Id: Ia825767f1f7ee77f68cfe00f53e09e6f6bfa027f
This commit is contained in:
parent
c9103930a4
commit
93520edca2
4 changed files with 54 additions and 62 deletions
|
@ -145,10 +145,6 @@ func (s *SdkBase) RequiredSdks() SdkRefs {
|
|||
return s.properties.RequiredSdks
|
||||
}
|
||||
|
||||
func (s *SdkBase) BuildSnapshot(sdkModuleContext ModuleContext, builder SnapshotBuilder) {
|
||||
sdkModuleContext.ModuleErrorf("module type " + sdkModuleContext.OtherModuleType(s.module) + " cannot be used in an sdk")
|
||||
}
|
||||
|
||||
// InitSdkAwareModule initializes the SdkBase struct. This must be called by all modules including
|
||||
// SdkBase.
|
||||
func InitSdkAwareModule(m SdkAware) {
|
||||
|
@ -319,17 +315,6 @@ type SdkMemberType interface {
|
|||
// the module is not allowed in whichever sdk property it was added.
|
||||
IsInstance(module Module) bool
|
||||
|
||||
// Build the snapshot for the SDK member
|
||||
//
|
||||
// The ModuleContext provided is for the SDK module, so information for
|
||||
// variants in the supplied member can be accessed using the Other... methods.
|
||||
//
|
||||
// The SdkMember is guaranteed to contain variants for which the
|
||||
// IsInstance(Module) method returned true.
|
||||
//
|
||||
// deprecated Use AddPrebuiltModule() instead.
|
||||
BuildSnapshot(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember)
|
||||
|
||||
// Add a prebuilt module that the sdk will populate.
|
||||
//
|
||||
// Returning nil from this will cause the sdk module type to use the deprecated BuildSnapshot
|
||||
|
@ -381,19 +366,6 @@ func (b *SdkMemberTypeBase) HasTransitiveSdkMembers() bool {
|
|||
return b.TransitiveSdkMembers
|
||||
}
|
||||
|
||||
func (b *SdkMemberTypeBase) BuildSnapshot(sdkModuleContext ModuleContext, builder SnapshotBuilder, member SdkMember) {
|
||||
panic("override AddPrebuiltModule")
|
||||
}
|
||||
|
||||
func (b *SdkMemberTypeBase) AddPrebuiltModule(ctx SdkMemberContext, member SdkMember) BpModule {
|
||||
// Returning nil causes the legacy BuildSnapshot method to be used.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *SdkMemberTypeBase) CreateVariantPropertiesStruct() SdkMemberProperties {
|
||||
panic("override me")
|
||||
}
|
||||
|
||||
// Encapsulates the information about registered SdkMemberTypes.
|
||||
type SdkMemberTypesRegistry struct {
|
||||
// The list of types sorted by property name.
|
||||
|
|
|
@ -2041,18 +2041,33 @@ func (mt *droidStubsSdkMemberType) IsInstance(module android.Module) bool {
|
|||
return ok
|
||||
}
|
||||
|
||||
func (mt *droidStubsSdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
|
||||
variants := member.Variants()
|
||||
if len(variants) != 1 {
|
||||
sdkModuleContext.ModuleErrorf("sdk contains %d variants of member %q but only one is allowed", len(variants), member.Name())
|
||||
}
|
||||
variant := variants[0]
|
||||
d, _ := variant.(*Droidstubs)
|
||||
stubsSrcJar := d.stubsSrcJar
|
||||
|
||||
snapshotRelativeDir := filepath.Join("java", d.Name()+"_stubs_sources")
|
||||
builder.UnzipToSnapshot(stubsSrcJar, snapshotRelativeDir)
|
||||
|
||||
pbm := builder.AddPrebuiltModule(member, "prebuilt_stubs_sources")
|
||||
pbm.AddProperty("srcs", []string{snapshotRelativeDir})
|
||||
func (mt *droidStubsSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
|
||||
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_stubs_sources")
|
||||
}
|
||||
|
||||
func (mt *droidStubsSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
|
||||
return &droidStubsInfoProperties{}
|
||||
}
|
||||
|
||||
type droidStubsInfoProperties struct {
|
||||
android.SdkMemberPropertiesBase
|
||||
|
||||
StubsSrcJar android.Path
|
||||
}
|
||||
|
||||
func (p *droidStubsInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
|
||||
droidstubs := variant.(*Droidstubs)
|
||||
p.StubsSrcJar = droidstubs.stubsSrcJar
|
||||
}
|
||||
|
||||
func (p *droidStubsInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
||||
if p.StubsSrcJar != nil {
|
||||
builder := ctx.SnapshotBuilder()
|
||||
|
||||
snapshotRelativeDir := filepath.Join("java", ctx.Name()+"_stubs_sources")
|
||||
|
||||
builder.UnzipToSnapshot(p.StubsSrcJar, snapshotRelativeDir)
|
||||
|
||||
propertySet.AddProperty("srcs", []string{snapshotRelativeDir})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,18 +242,28 @@ func (mt *systemModulesSdkMemberType) IsInstance(module android.Module) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (mt *systemModulesSdkMemberType) BuildSnapshot(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) {
|
||||
variants := member.Variants()
|
||||
if len(variants) != 1 {
|
||||
sdkModuleContext.ModuleErrorf("sdk contains %d variants of member %q but only one is allowed", len(variants), member.Name())
|
||||
for _, variant := range variants {
|
||||
sdkModuleContext.ModuleErrorf(" %q", variant)
|
||||
}
|
||||
}
|
||||
variant := variants[0]
|
||||
systemModule := variant.(*SystemModules)
|
||||
|
||||
pbm := builder.AddPrebuiltModule(member, "java_system_modules_import")
|
||||
// Add the references to the libraries that form the system module.
|
||||
pbm.AddPropertyWithTag("libs", systemModule.properties.Libs, builder.SdkMemberReferencePropertyTag(true))
|
||||
func (mt *systemModulesSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
|
||||
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "java_system_modules_import")
|
||||
}
|
||||
|
||||
type systemModulesInfoProperties struct {
|
||||
android.SdkMemberPropertiesBase
|
||||
|
||||
Libs []string
|
||||
}
|
||||
|
||||
func (mt *systemModulesSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
|
||||
return &systemModulesInfoProperties{}
|
||||
}
|
||||
|
||||
func (p *systemModulesInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
|
||||
systemModule := variant.(*SystemModules)
|
||||
p.Libs = systemModule.properties.Libs
|
||||
}
|
||||
|
||||
func (p *systemModulesInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
||||
if len(p.Libs) > 0 {
|
||||
// Add the references to the libraries that form the system module.
|
||||
propertySet.AddPropertyWithTag("libs", p.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(true))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,12 +258,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
|||
memberCtx := &memberContext{ctx, builder, memberType, member.name}
|
||||
|
||||
prebuiltModule := memberType.AddPrebuiltModule(memberCtx, member)
|
||||
if prebuiltModule == nil {
|
||||
// Fall back to legacy method of building a snapshot
|
||||
memberType.BuildSnapshot(ctx, builder, member)
|
||||
} else {
|
||||
s.createMemberSnapshot(memberCtx, member, prebuiltModule)
|
||||
}
|
||||
s.createMemberSnapshot(memberCtx, member, prebuiltModule)
|
||||
}
|
||||
|
||||
// Create a transformer that will transform an unversioned module into a versioned module.
|
||||
|
|
Loading…
Reference in a new issue