aboutsummaryrefslogtreecommitdiffstats
path: root/java/java.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2020-03-17 21:04:24 +0000
committerPaul Duffin <paulduffin@google.com>2020-04-22 12:51:44 +0100
commitc9103930a41317898fb495424ac3b2f9c12d36ff (patch)
treebab85d186fe3c28f332876fd2a9143eea951af53 /java/java.go
parent17ab883cb03878acf0429fa858ec4d5739c7a093 (diff)
downloadbuild_soong-c9103930a41317898fb495424ac3b2f9c12d36ff.tar.gz
build_soong-c9103930a41317898fb495424ac3b2f9c12d36ff.tar.bz2
build_soong-c9103930a41317898fb495424ac3b2f9c12d36ff.zip
Improve consistency of handling java snapshot properties
Previously, java snapshot properties (java_library and java_test) relied on the properties not being optimized when there was a single os type and instead being added directly to the common os type properties. However, that means that the behavior is inconsistent for other member types depending on whether there was one os type or not. This change updates the java sdk member handling to support optimization. This involved: 1) Adding AidlIncludeDirs field to librarySdkMemberProperties to specify the aidl include dirs instead of extracting that from the library field. 2) Renaming jarToExport to JarToExport (in both library/testSdkMemberProperties)to allow it to be optimized. 3) Adding MemberType() and Name() methods to SdkMemberPropertiesContext to avoid having to store the former in the properties struct and retrieve the latter from the library/test fields. 4) Removing the now unused library/test fields from the properties structures. 5) Separating the processing of the jar/test config in AddToPropertySet(...) as they may be optimized separately. 6) Ditto for the jar/aidl include dirs. 7) While doing this work I noticed that although the contents of the aidl include dirs are copied into the snapshot the java_import does not make use of them. Raised bug 151933053 and added TODO to track that work. Bug: 142935992 Bug: 153306490 Test: m nothing Merged-In: Iba9799e111ca5672b2133568163d8c49837ba9cd Change-Id: Iba9799e111ca5672b2133568163d8c49837ba9cd
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go57
1 files changed, 32 insertions, 25 deletions
diff --git a/java/java.go b/java/java.go
index 416cbe5a..20e01f2a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1896,35 +1896,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 {
@@ -1932,7 +1935,7 @@ func (p *librarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberConte
}
}
- propertySet.AddProperty("jars", []string{snapshotRelativeJavaLibPath})
+ // TODO(b/151933053) - add aidl include dirs property
}
}
@@ -2110,8 +2113,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) {
@@ -2122,21 +2125,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()
-
- snapshotRelativeJavaLibPath := sdkSnapshotFilePathForJar(p.OsPrefix(), p.test.Name())
- builder.CopyToSnapshot(p.jarToExport, snapshotRelativeJavaLibPath)
+ builder := ctx.SnapshotBuilder()
- 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)
}
}