Improve consistency of handling java snapshot properties am: a551a1c2f9
Change-Id: Ibb5c90e494a4267d1f032af9cfde9d62d7e6ede5
This commit is contained in:
@@ -466,14 +466,29 @@ func RegisterSdkMemberType(memberType SdkMemberType) {
|
||||
// Contains common properties that apply across many different member types. These
|
||||
// are not affected by the optimization to extract common values.
|
||||
type SdkMemberPropertiesBase struct {
|
||||
// The setting to use for the compile_multilib property.
|
||||
Compile_multilib string `sdk:"keep"`
|
||||
|
||||
// The number of unique os types supported by the member variants.
|
||||
//
|
||||
// If a member has a variant with more than one os type then it will need to differentiate
|
||||
// the locations of any of their prebuilt files in the snapshot by os type to prevent them
|
||||
// from colliding. See OsPrefix().
|
||||
//
|
||||
// This property is the same for all variants of a member and so would be optimized away
|
||||
// if it was not explicitly kept.
|
||||
Os_count int `sdk:"keep"`
|
||||
|
||||
// The os type for which these properties refer.
|
||||
//
|
||||
// Provided to allow a member to differentiate between os types in the locations of their
|
||||
// prebuilt files when it supports more than one os type.
|
||||
//
|
||||
// This property is the same for all os type specific variants of a member and so would be
|
||||
// optimized away if it was not explicitly kept.
|
||||
Os OsType `sdk:"keep"`
|
||||
|
||||
// The setting to use for the compile_multilib property.
|
||||
//
|
||||
// This property is set after optimization so there is no point in trying to optimize it.
|
||||
Compile_multilib string `sdk:"keep"`
|
||||
}
|
||||
|
||||
// The os prefix to use for any file paths in the sdk.
|
||||
@@ -516,4 +531,13 @@ type SdkMemberContext interface {
|
||||
|
||||
// The builder of the snapshot.
|
||||
SnapshotBuilder() SnapshotBuilder
|
||||
|
||||
// The type of the member.
|
||||
MemberType() SdkMemberType
|
||||
|
||||
// The name of the member.
|
||||
//
|
||||
// Provided for use by sdk members to create a member specific location within the snapshot
|
||||
// into which to copy the prebuilt files.
|
||||
Name() string
|
||||
}
|
||||
|
57
java/java.go
57
java/java.go
@@ -1914,35 +1914,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 {
|
||||
@@ -1950,7 +1953,7 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte
|
||||
}
|
||||
}
|
||||
|
||||
propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
|
||||
// TODO(b/151933053) - add aidl include dirs property
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2127,8 +2130,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) {
|
||||
@@ -2139,21 +2142,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)
|
||||
}
|
||||
}
|
||||
|
@@ -255,7 +255,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
||||
for _, member := range members {
|
||||
memberType := member.memberType
|
||||
|
||||
memberCtx := &memberContext{ctx, builder}
|
||||
memberCtx := &memberContext{ctx, builder, memberType, member.name}
|
||||
|
||||
prebuiltModule := memberType.AddPrebuiltModule(memberCtx, member)
|
||||
if prebuiltModule == nil {
|
||||
@@ -1087,6 +1087,8 @@ func newLinkSpecificInfo(ctx android.SdkMemberContext, linkType string, variantP
|
||||
type memberContext struct {
|
||||
sdkMemberContext android.ModuleContext
|
||||
builder *snapshotBuilder
|
||||
memberType android.SdkMemberType
|
||||
name string
|
||||
}
|
||||
|
||||
func (m *memberContext) SdkModuleContext() android.ModuleContext {
|
||||
@@ -1097,6 +1099,14 @@ func (m *memberContext) SnapshotBuilder() android.SnapshotBuilder {
|
||||
return m.builder
|
||||
}
|
||||
|
||||
func (m *memberContext) MemberType() android.SdkMemberType {
|
||||
return m.memberType
|
||||
}
|
||||
|
||||
func (m *memberContext) Name() string {
|
||||
return m.name
|
||||
}
|
||||
|
||||
func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModule android.BpModule) {
|
||||
|
||||
memberType := member.memberType
|
||||
|
Reference in New Issue
Block a user