Strip relative paths from android_library_import output files

androidx.annotation_annotation is used as a test data file, and
converting it from an android_library to an android_library_import
causes the relative path used in the test data path to change.
Clear the relative path in android_library_import the same way that
android_library and other java based modules do.

Also change the name of classes-combined.jar to the name of the
module so that the output file has the right name if there are no
static dependences that require running the merge_zips step.

Bug: 288358614
Test: TestAndroidLibraryOutputFileRel
Change-Id: I28210aa370a742d789102ff71db3685ca744878f
This commit is contained in:
Colin Cross
2024-04-02 12:21:34 -07:00
parent ddde9e29a4
commit 28ac2ffc80
2 changed files with 53 additions and 4 deletions

View File

@@ -128,3 +128,48 @@ func TestLibraryFlagsPackages(t *testing.T) {
"--feature-flags @out/soong/.intermediates/bar/intermediate.txt --feature-flags @out/soong/.intermediates/baz/intermediate.txt",
)
}
func TestAndroidLibraryOutputFilesRel(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
android_library {
name: "foo",
srcs: ["a.java"],
}
android_library_import {
name: "bar",
aars: ["bar.aar"],
}
android_library_import {
name: "baz",
aars: ["baz.aar"],
static_libs: ["bar"],
}
`)
foo := result.ModuleForTests("foo", "android_common")
bar := result.ModuleForTests("bar", "android_common")
baz := result.ModuleForTests("baz", "android_common")
fooOutputPath := android.OutputFileForModule(android.PathContext(nil), foo.Module(), "")
barOutputPath := android.OutputFileForModule(android.PathContext(nil), bar.Module(), "")
bazOutputPath := android.OutputFileForModule(android.PathContext(nil), baz.Module(), "")
android.AssertPathRelativeToTopEquals(t, "foo output path",
"out/soong/.intermediates/foo/android_common/javac/foo.jar", fooOutputPath)
android.AssertPathRelativeToTopEquals(t, "bar output path",
"out/soong/.intermediates/bar/android_common/aar/bar.jar", barOutputPath)
android.AssertPathRelativeToTopEquals(t, "baz output path",
"out/soong/.intermediates/baz/android_common/combined/baz.jar", bazOutputPath)
android.AssertStringEquals(t, "foo relative output path",
"foo.jar", fooOutputPath.Rel())
android.AssertStringEquals(t, "bar relative output path",
"bar.jar", barOutputPath.Rel())
android.AssertStringEquals(t, "baz relative output path",
"baz.jar", bazOutputPath.Rel())
}