Merge "Fix type assertion error regarding dex_import" am: 36aef533cc am: 86e4acfaad

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

Change-Id: Ie52128b2cb0fd78bf6e36d57d4d68231208f94c8
This commit is contained in:
Treehugger Robot 2020-06-11 01:14:55 +00:00 committed by Automerger Merge Worker
commit 639e87e123
2 changed files with 18 additions and 4 deletions

View File

@ -180,13 +180,17 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
} }
switch fi.class { switch fi.class {
case javaSharedLib: case javaSharedLib:
javaModule := fi.module.(java.Dependency)
// soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore // soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
// we will have foo.jar.jar // we will have foo.jar.jar
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar")) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar"))
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String()) if javaModule, ok := fi.module.(java.Dependency); ok {
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String()) fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
} else {
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", fi.builtFile.String())
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", fi.builtFile.String())
}
fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String()) fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false") fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk") fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")

View File

@ -329,7 +329,7 @@ func ensureListEmpty(t *testing.T, result []string) {
// Minimal test // Minimal test
func TestBasicApex(t *testing.T) { func TestBasicApex(t *testing.T) {
ctx, _ := testApex(t, ` ctx, config := testApex(t, `
apex_defaults { apex_defaults {
name: "myapex-defaults", name: "myapex-defaults",
manifest: ":myapex.manifest", manifest: ":myapex.manifest",
@ -484,6 +484,16 @@ func TestBasicApex(t *testing.T) {
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule") apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule")
// Make sure that Android.mk is created
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
data := android.AndroidMkDataForTest(t, config, "", ab)
var builder strings.Builder
data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
optFlags := apexRule.Args["opt_flags"] optFlags := apexRule.Args["opt_flags"]
ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey") ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey")
// Ensure that the NOTICE output is being packaged as an asset. // Ensure that the NOTICE output is being packaged as an asset.