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:
Paul Duffin
2020-03-20 13:35:40 +00:00
parent c9103930a4
commit 93520edca2
4 changed files with 54 additions and 62 deletions

View File

@@ -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})
}
}