Merge "Strip relative paths from android_library_import output files" into main am: eabd1ef484
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3023204 Change-Id: Ie20e0d312052f65f893c16d8d0c29a43c72ee923 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
12
java/aar.go
12
java/aar.go
@@ -1156,7 +1156,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extractedAARDir := android.PathForModuleOut(ctx, "aar")
|
extractedAARDir := android.PathForModuleOut(ctx, "aar")
|
||||||
classpathFile := extractedAARDir.Join(ctx, "classes-combined.jar")
|
classpathFile := extractedAARDir.Join(ctx, ctx.ModuleName()+".jar")
|
||||||
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
|
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
|
||||||
a.rTxt = extractedAARDir.Join(ctx, "R.txt")
|
a.rTxt = extractedAARDir.Join(ctx, "R.txt")
|
||||||
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
|
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
|
||||||
@@ -1284,14 +1284,18 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
addCLCFromDep(ctx, module, a.classLoaderContexts)
|
addCLCFromDep(ctx, module, a.classLoaderContexts)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var implementationJarFile android.OutputPath
|
||||||
if len(staticJars) > 0 {
|
if len(staticJars) > 0 {
|
||||||
combineJars := append(android.Paths{classpathFile}, staticJars...)
|
combineJars := append(android.Paths{classpathFile}, staticJars...)
|
||||||
a.implementationJarFile = android.PathForModuleOut(ctx, "combined", ctx.ModuleName()+".jar")
|
implementationJarFile = android.PathForModuleOut(ctx, "combined", ctx.ModuleName()+".jar").OutputPath
|
||||||
TransformJarsToJar(ctx, a.implementationJarFile, "combine", combineJars, android.OptionalPath{}, false, nil, nil)
|
TransformJarsToJar(ctx, implementationJarFile, "combine", combineJars, android.OptionalPath{}, false, nil, nil)
|
||||||
} else {
|
} else {
|
||||||
a.implementationJarFile = classpathFile
|
implementationJarFile = classpathFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource
|
||||||
|
a.implementationJarFile = implementationJarFile.WithoutRel()
|
||||||
|
|
||||||
if len(staticHeaderJars) > 0 {
|
if len(staticHeaderJars) > 0 {
|
||||||
combineJars := append(android.Paths{classpathFile}, staticHeaderJars...)
|
combineJars := append(android.Paths{classpathFile}, staticHeaderJars...)
|
||||||
a.headerJarFile = android.PathForModuleOut(ctx, "turbine-combined", ctx.ModuleName()+".jar")
|
a.headerJarFile = android.PathForModuleOut(ctx, "turbine-combined", ctx.ModuleName()+".jar")
|
||||||
|
@@ -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",
|
"--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())
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user