Improve consistency of handling java snapshot properties am: a551a1c2f9 am: bfc8e986bf

Change-Id: I294bef0bd3de32f9761649acb6b9ea883dd3ea4f
This commit is contained in:
Paul Duffin
2020-03-23 11:52:19 +00:00
committed by Automerger Merge Worker
3 changed files with 70 additions and 29 deletions

View File

@@ -1867,35 +1867,38 @@ func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext,
}
func (mt *librarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
return &librarySdkMemberProperties{memberType: mt}
return &librarySdkMemberProperties{}
}
type librarySdkMemberProperties struct {
android.SdkMemberPropertiesBase
memberType *librarySdkMemberType
library *Library
jarToExport android.Path
JarToExport android.Path
AidlIncludeDirs android.Paths
}
func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
j := variant.(*Library)
p.library = j
p.jarToExport = p.memberType.jarToExportGetter(j)
p.JarToExport = ctx.MemberType().(*librarySdkMemberType).jarToExportGetter(j)
p.AidlIncludeDirs = j.AidlIncludeDirs()
}
func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
if p.jarToExport != nil {
sdkModuleContext := ctx.SdkModuleContext()
builder := ctx.SnapshotBuilder()
builder := ctx.SnapshotBuilder()
exportedJar := p.jarToExport
snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), p.library.Name())
exportedJar := p.JarToExport
if exportedJar != nil {
snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), ctx.Name())
builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath)
for _, dir := range p.library.AidlIncludeDirs() {
propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
}
aidlIncludeDirs := p.AidlIncludeDirs
if len(aidlIncludeDirs) != 0 {
sdkModuleContext := ctx.SdkModuleContext()
for _, dir := range aidlIncludeDirs {
// TODO(jiyong): copy parcelable declarations only
aidlFiles, _ := sdkModuleContext.GlobWithDeps(dir.String()+"/**/*.aidl", nil)
for _, file := range aidlFiles {
@@ -1903,7 +1906,7 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte
}
}
propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
// TODO(b/151933053) - add aidl include dirs property
}
}
@@ -2080,8 +2083,8 @@ func (mt *testSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberPr
type testSdkMemberProperties struct {
android.SdkMemberPropertiesBase
test *Test
jarToExport android.Path
JarToExport android.Path
TestConfig android.Path
}
func (p *testSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
@@ -2092,21 +2095,25 @@ func (p *testSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberConte
panic(fmt.Errorf("there must be only one implementation jar from %q", test.Name()))
}
p.test = test
p.jarToExport = implementationJars[0]
p.JarToExport = implementationJars[0]
p.TestConfig = test.testConfig
}
func (p *testSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
if p.jarToExport != nil {
builder := ctx.SnapshotBuilder()
builder := ctx.SnapshotBuilder()
snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), p.test.Name())
builder.CopyToSnapshot(p.jarToExport, snapshotRelativeJavaLibPath)
snapshotRelativeTestConfigPath := sdkSnapshotFilePathForMember(p.OsPrefix(), p.test.Name(), testConfigSuffix)
builder.CopyToSnapshot(p.test.testConfig, snapshotRelativeTestConfigPath)
exportedJar := p.JarToExport
if exportedJar != nil {
snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), ctx.Name())
builder.CopyToSnapshot(exportedJar, snapshotRelativeJavaLibPath)
propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
}
testConfig := p.TestConfig
if testConfig != nil {
snapshotRelativeTestConfigPath := sdkSnapshotFilePathForMember(p.OsPrefix(), ctx.Name(), testConfigSuffix)
builder.CopyToSnapshot(testConfig, snapshotRelativeTestConfigPath)
propertySet.AddProperty("test_config", snapshotRelativeTestConfigPath)
}
}