fix: Override vndk-ext lib name with original lib
vndk-ext should have the same output filename with the lib which it
extends. "extends" property is "module name", not "filename" of output.
Bug: 143130384
Test: add "protox" as a vndk-ext module (extends 'libprotobuf-cpp-full')
m protox.vendor && check output filename under /vendor/lib/vndk/
(should have correct suffix)
Change-Id: I5741ea87b4f2ad375b69f54c93dcb8753d9952dd
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 689aacd..0649c2d 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -768,6 +768,19 @@
},
nocrt: true,
}
+ cc_library {
+ name: "libvndk2",
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ target: {
+ vendor: {
+ suffix: "-suffix",
+ },
+ },
+ nocrt: true,
+ }
cc_library {
name: "libvndk_ext",
@@ -778,9 +791,22 @@
},
nocrt: true,
}
+
+ cc_library {
+ name: "libvndk2_ext",
+ vendor: true,
+ vndk: {
+ enabled: true,
+ extends: "libvndk2",
+ },
+ nocrt: true,
+ }
`)
checkVndkModule(t, ctx, "libvndk_ext", "vndk", false, "libvndk")
+
+ mod := ctx.ModuleForTests("libvndk2_ext", vendorVariant).Module().(*Module)
+ assertString(t, mod.outputFile.Path().Base(), "libvndk2-suffix.so")
}
func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
diff --git a/cc/library.go b/cc/library.go
index 80dc76c..829c617 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -599,7 +599,11 @@
name += suffix
if ctx.isVndkExt() {
- name = ctx.getVndkExtendsModuleName()
+ // vndk-ext lib should have the same name with original lib
+ ctx.VisitDirectDepsWithTag(vndkExtDepTag, func(module android.Module) {
+ originalName := module.(*Module).outputFile.Path()
+ name = strings.TrimSuffix(originalName.Base(), originalName.Ext())
+ })
}
if ctx.Host() && Bool(library.Properties.Unique_host_soname) {