Use target dependent module to update the name suffix
The module names for vendor and product variants have the image
variant suffix to avoid conflict with the core modules. It requires
updating the module names in the dependency tree with the suffixes.
We had a hidden bug that used the original module properties to
update the names of its dependent modules.
Also, it must cover the product variants modules.
Test: updated cc_test.go and build
Change-Id: I6b4ea062d13c8fac1e699138d44376e52e0d7852
diff --git a/cc/cc.go b/cc/cc.go
index d282b6e..707de02 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2891,12 +2891,12 @@
ccDepModule, _ := ccDep.(*Module)
isLLndk := ccDepModule != nil && ccDepModule.IsLlndk()
isVendorPublicLib := inList(libName, *vendorPublicLibraries)
- bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk
+ nonSystemVariantsExist := ccDep.HasNonSystemVariants() || isLLndk
- if c, ok := ccDep.(*Module); ok {
+ if ccDepModule != nil {
// Use base module name for snapshots when exporting to Makefile.
- if snapshotPrebuilt, ok := c.linker.(snapshotInterface); ok {
- baseName := c.BaseModuleName()
+ if snapshotPrebuilt, ok := ccDepModule.linker.(snapshotInterface); ok {
+ baseName := ccDepModule.BaseModuleName()
return baseName + snapshotPrebuilt.snapshotAndroidMkSuffix()
}
@@ -2907,10 +2907,10 @@
// The vendor module is a no-vendor-variant VNDK library. Depend on the
// core module instead.
return libName
- } else if c.UseVndk() && bothVendorAndCoreVariantsExist {
- // The vendor module in Make will have been renamed to not conflict with the core
- // module, so update the dependency name here accordingly.
- return libName + c.getNameSuffixWithVndkVersion(ctx)
+ } else if ccDep.UseVndk() && nonSystemVariantsExist && ccDepModule != nil {
+ // The vendor and product modules in Make will have been renamed to not conflict with the
+ // core module, so update the dependency name here accordingly.
+ return libName + ccDepModule.Properties.SubName
} else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
return libName + vendorPublicLibrarySuffix
} else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 7288cc4..d272a32 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2712,6 +2712,14 @@
system_shared_libs : [],
}
cc_library {
+ name: "libproduct_vendor",
+ product_specific: true,
+ vendor_available: true,
+ no_libcrt : true,
+ nocrt : true,
+ system_shared_libs : [],
+ }
+ cc_library {
name: "libcore",
runtime_libs: ["liball_available"],
no_libcrt : true,
@@ -2728,7 +2736,7 @@
cc_library {
name: "libvendor2",
vendor: true,
- runtime_libs: ["liball_available", "libvendor1"],
+ runtime_libs: ["liball_available", "libvendor1", "libproduct_vendor"],
no_libcrt : true,
nocrt : true,
system_shared_libs : [],
@@ -2751,7 +2759,7 @@
cc_library {
name: "libproduct2",
product_specific: true,
- runtime_libs: ["liball_available", "libproduct1"],
+ runtime_libs: ["liball_available", "libproduct1", "libproduct_vendor"],
no_libcrt : true,
nocrt : true,
system_shared_libs : [],
@@ -2781,7 +2789,7 @@
checkRuntimeLibs(t, []string{"liball_available.vendor"}, module)
module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
- checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1"}, module)
+ checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1", "libproduct_vendor.vendor"}, module)
// runtime_libs for product variants have '.product' suffixes if the modules have both core
// and product variants.
@@ -2791,7 +2799,7 @@
checkRuntimeLibs(t, []string{"liball_available.product"}, module)
module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module)
- checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1"}, module)
+ checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1", "libproduct_vendor.product"}, module)
}
func TestExcludeRuntimeLibs(t *testing.T) {
@@ -2817,10 +2825,10 @@
checkRuntimeLibs(t, []string{"liball_available"}, module)
module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
- checkRuntimeLibs(t, []string{"liball_available", "libvendor1"}, module)
+ checkRuntimeLibs(t, []string{"liball_available", "libvendor1", "libproduct_vendor"}, module)
module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module)
- checkRuntimeLibs(t, []string{"liball_available", "libproduct1"}, module)
+ checkRuntimeLibs(t, []string{"liball_available", "libproduct1", "libproduct_vendor"}, module)
}
func checkStaticLibs(t *testing.T, expected []string, module *Module) {
diff --git a/cc/linkable.go b/cc/linkable.go
index ab5a552..58919a0 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -106,6 +106,8 @@
IsVndkExt() bool
IsVndkPrivate() bool
HasVendorVariant() bool
+ HasProductVariant() bool
+ HasNonSystemVariants() bool
InProduct() bool
SdkVersion() string
diff --git a/rust/image.go b/rust/image.go
index 5ff10ae..ac8c1b3 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -71,6 +71,15 @@
return Bool(mod.VendorProperties.Vendor_available) || Bool(mod.VendorProperties.Odm_available)
}
+// Always returns false because rust modules do not support product variant.
+func (mod *Module) HasProductVariant() bool {
+ return Bool(mod.VendorProperties.Product_available)
+}
+
+func (mod *Module) HasNonSystemVariants() bool {
+ return mod.HasVendorVariant() || mod.HasProductVariant()
+}
+
func (c *Module) InProduct() bool {
return false
}