diff options
| author | 2021-01-11 12:27:24 -0800 | |
|---|---|---|
| committer | 2021-01-19 18:15:16 +0000 | |
| commit | fb04df4d57e52b38e6ebfec9cfcc2bb76968b2ce (patch) | |
| tree | 86a325d8082e9c172324c907fef214862c8f7de8 /java | |
| parent | a41a6963b4a8636a6b5de9b0d4aa746c9a6e99ac (diff) | |
Supply LOCAL_SOONG_DEX_JAR for java_import with compile_dex.
Without LOCAL_SOONG_DEX_JAR, ninja fails with a missing
dependency error.
Test: m nothing
Test: new TestImportSoongDexJar
Bug: 173705556
Change-Id: I54a4c6ea93877667a3fb97f8b2621c42e431f577
Diffstat (limited to 'java')
| -rw-r--r-- | java/androidmk.go | 3 | ||||
| -rw-r--r-- | java/androidmk_test.go | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/java/androidmk.go b/java/androidmk.go index aaad44f72..cc454b03d 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -196,6 +196,9 @@ func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries { ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(entries *android.AndroidMkEntries) { entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable)) + if prebuilt.dexJarFile != nil { + entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile) + } entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile) entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile) entries.SetString("LOCAL_SDK_VERSION", prebuilt.makeSdkVersion()) diff --git a/java/androidmk_test.go b/java/androidmk_test.go index 233e9d5c5..e2647cf0f 100644 --- a/java/androidmk_test.go +++ b/java/androidmk_test.go @@ -166,3 +166,25 @@ func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) { } } } + +func TestImportSoongDexJar(t *testing.T) { + ctx, config := testJava(t, ` + java_import { + name: "my-java-import", + jars: ["a.jar"], + prefer: true, + compile_dex: true, + } + `) + + mod := ctx.ModuleForTests("my-java-import", "android_common").Module() + entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0] + expectedSoongDexJar := buildDir + "/.intermediates/my-java-import/android_common/dex/my-java-import.jar" + actualSoongDexJar := entries.EntryMap["LOCAL_SOONG_DEX_JAR"] + + if len(actualSoongDexJar) != 1 { + t.Errorf("LOCAL_SOONG_DEX_JAR incorrect len %d", len(actualSoongDexJar)) + } else if actualSoongDexJar[0] != expectedSoongDexJar { + t.Errorf("LOCAL_SOONG_DEX_JAR mismatch, actual: %s, expected: %s", actualSoongDexJar[0], expectedSoongDexJar) + } +} |