Merge "bootclasspath_fragment: Add hidden API flag files to snapshot"

This commit is contained in:
Paul Duffin
2021-04-22 17:02:58 +00:00
committed by Gerrit Code Review
2 changed files with 131 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ package java
import (
"fmt"
"path/filepath"
"strings"
"android/soong/android"
@@ -326,6 +327,9 @@ type bootImageSdkMemberProperties struct {
// Contents of the bootclasspath fragment
Contents []string
// Flag files by *hiddenAPIFlagFileCategory
Flag_files_by_category map[*hiddenAPIFlagFileCategory]android.Paths
}
func (b *bootImageSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
@@ -338,6 +342,11 @@ func (b *bootImageSdkMemberProperties) PopulateFromVariant(ctx android.SdkMember
// boot image. Therefore, contents property is only copied if the image name is not specified.
b.Contents = module.properties.Contents
}
// Get the flag file information from the module.
mctx := ctx.SdkModuleContext()
flagFileInfo := mctx.OtherModuleProvider(module, hiddenAPIFlagFileInfoProvider).(hiddenAPIFlagFileInfo)
b.Flag_files_by_category = flagFileInfo.categoryToPaths
}
func (b *bootImageSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
@@ -348,6 +357,23 @@ func (b *bootImageSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCon
if len(b.Contents) > 0 {
propertySet.AddPropertyWithTag("contents", b.Contents, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(true))
}
builder := ctx.SnapshotBuilder()
if b.Flag_files_by_category != nil {
hiddenAPISet := propertySet.AddPropertySet("hidden_api")
for _, category := range hiddenAPIFlagFileCategories {
paths := b.Flag_files_by_category[category]
if len(paths) > 0 {
dests := []string{}
for _, p := range paths {
dest := filepath.Join("hiddenapi", p.Base())
builder.CopyToSnapshot(p, dest)
dests = append(dests, dest)
}
hiddenAPISet.AddProperty(category.propertyName, dests)
}
}
}
}
var _ android.SdkMemberType = (*bootImageMemberType)(nil)