Merge "dex_import can be added to apex" am: a8bf98852a

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1320920

Change-Id: I53fd8b961fba5ec095387d3d45ff450823b9ee73
This commit is contained in:
Treehugger Robot
2020-06-04 05:20:39 +00:00
committed by Automerger Merge Worker
3 changed files with 25 additions and 13 deletions

View File

@@ -1650,7 +1650,8 @@ func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFil
}
type javaDependency interface {
java.Dependency
DexJar() android.Path
JacocoReportClassesFile() android.Path
Stem() string
}
@@ -1977,23 +1978,16 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
}
case javaLibTag:
if javaLib, ok := child.(*java.Library); ok {
af := apexFileForJavaLibrary(ctx, javaLib, javaLib)
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
} else {
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
} else if sdkLib, ok := child.(*java.SdkLibrary); ok {
af := apexFileForJavaLibrary(ctx, sdkLib, sdkLib)
switch child.(type) {
case *java.Library, *java.SdkLibrary, *java.DexImport:
af := apexFileForJavaLibrary(ctx, child.(javaDependency), child.(android.Module))
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
return false
}
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
} else {
default:
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
}
case androidAppTag:

View File

@@ -329,7 +329,10 @@ func TestBasicApex(t *testing.T) {
binaries: ["foo",],
}
},
java_libs: ["myjar"],
java_libs: [
"myjar",
"myjar_dex",
],
}
apex {
@@ -438,6 +441,15 @@ func TestBasicApex(t *testing.T) {
],
}
dex_import {
name: "myjar_dex",
jars: ["prebuilt.jar"],
apex_available: [
"//apex_available:platform",
"myapex",
],
}
java_library {
name: "myotherjar",
srcs: ["foo/bar/MyClass.java"],
@@ -473,6 +485,7 @@ func TestBasicApex(t *testing.T) {
// Ensure that apex variant is created for the direct dep
ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common_myapex")
ensureListContains(t, ctx.ModuleVariantsForTests("myjar_dex"), "android_common_myapex")
// Ensure that apex variant is created for the indirect dep
ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
@@ -482,6 +495,7 @@ func TestBasicApex(t *testing.T) {
ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
ensureContains(t, copyCmds, "image.apex/javalib/myjar_stem.jar")
ensureContains(t, copyCmds, "image.apex/javalib/myjar_dex.jar")
// .. but not for java libs
ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar")
ensureNotContains(t, copyCmds, "image.apex/javalib/msharedjar.jar")

View File

@@ -2691,6 +2691,10 @@ func (j *DexImport) Stem() string {
return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name())
}
func (a *DexImport) JacocoReportClassesFile() android.Path {
return nil
}
func (j *DexImport) IsInstallable() bool {
return true
}