diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/java/java.go b/java/java.go index a4e91ab9c..279d67424 100644 --- a/java/java.go +++ b/java/java.go @@ -37,14 +37,7 @@ func init() { RegisterJavaBuildComponents(android.InitRegistrationContext) // Register sdk member types. - android.RegisterSdkMemberType(&headerLibrarySdkMemberType{ - librarySdkMemberType{ - android.SdkMemberTypeBase{ - PropertyName: "java_header_libs", - SupportsSdk: true, - }, - }, - }) + android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType) android.RegisterSdkMemberType(&implLibrarySdkMemberType{ librarySdkMemberType{ @@ -1482,6 +1475,16 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.implementationAndResourcesJar = implementationAndResourcesJar + // Enable dex compilation for the APEX variants, unless it is disabled explicitly + if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() { + if j.deviceProperties.Compile_dex == nil { + j.deviceProperties.Compile_dex = proptools.BoolPtr(true) + } + if j.deviceProperties.Hostdex == nil { + j.deviceProperties.Hostdex = proptools.BoolPtr(true) + } + } + if ctx.Device() && j.hasCode(ctx) && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) { // Dex compilation @@ -1717,8 +1720,10 @@ func (j *Module) hasCode(ctx android.ModuleContext) bool { func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { depTag := ctx.OtherModuleDependencyTag(dep) - // dependencies other than the static linkage are all considered crossing APEX boundary - return depTag == staticLibTag + // Dependencies other than the static linkage are all considered crossing APEX boundary + // Also, a dependency to an sdk member is also considered as such. This is required because + // sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator. + return depTag == staticLibTag || j.IsInAnySdk() } func (j *Module) Stem() string { @@ -1847,6 +1852,15 @@ func (mt *librarySdkMemberType) buildSnapshot( module.AddProperty("jars", []string{snapshotRelativeJavaLibPath}) } +var javaHeaderLibsSdkMemberType android.SdkMemberType = &headerLibrarySdkMemberType{ + librarySdkMemberType{ + android.SdkMemberTypeBase{ + PropertyName: "java_header_libs", + SupportsSdk: true, + }, + }, +} + type headerLibrarySdkMemberType struct { librarySdkMemberType } @@ -2406,6 +2420,14 @@ func (j *Import) SrcJarArgs() ([]string, android.Paths) { return nil, nil } +func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { + depTag := ctx.OtherModuleDependencyTag(dep) + // dependencies other than the static linkage are all considered crossing APEX boundary + // Also, a dependency to an sdk member is also considered as such. This is required because + // sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator. + return depTag == staticLibTag || j.IsInAnySdk() +} + // Add compile time check for interface implementation var _ android.IDEInfo = (*Import)(nil) var _ android.IDECustomizedModuleName = (*Import)(nil) |