rust: Don't append '.vendor' to vendor modules.
Rust vendor-only modules would have the '.vendor' subname appended to
them, which meant that 'm <vendor_module>' would not work -- instead
you would need to call 'm <vendor_module>.vendor', which leads to some
confusion.
This CL fixes the behavior by using the same SubName logic as the cc
module.
Bug: 205577906
Test: m <vendor_module> # works without .vendor suffix
Change-Id: I6ba18ce1d7281a1f8342ed6014644b48009d78e0
diff --git a/cc/cc.go b/cc/cc.go
index ac6da05..00b82d5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1218,6 +1218,17 @@
return c.VendorProperties.IsVendorPublicLibrary
}
+func (c *Module) IsVndkPrebuiltLibrary() bool {
+ if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
+ return true
+ }
+ return false
+}
+
+func (c *Module) SdkAndPlatformVariantVisibleToMake() bool {
+ return c.Properties.SdkAndPlatformVariantVisibleToMake
+}
+
func (c *Module) HasLlndkStubs() bool {
lib := moduleLibraryInterface(c)
return lib != nil && lib.hasLLNDKStubs()
@@ -1699,7 +1710,7 @@
return nil
}
-func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string {
+func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface) string {
// Returns the name suffix for product and vendor variants. If the VNDK version is not
// "current", it will append the VNDK version to the name suffix.
var vndkVersion string
@@ -1719,19 +1730,19 @@
if vndkVersion == "current" {
vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
}
- if c.Properties.VndkVersion != vndkVersion && c.Properties.VndkVersion != "" {
+ if c.VndkVersion() != vndkVersion && c.VndkVersion() != "" {
// add version suffix only if the module is using different vndk version than the
// version in product or vendor partition.
- nameSuffix += "." + c.Properties.VndkVersion
+ nameSuffix += "." + c.VndkVersion()
}
return nameSuffix
}
-func (c *Module) setSubnameProperty(actx android.ModuleContext) {
- c.Properties.SubName = ""
+func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string {
+ var subName = ""
if c.Target().NativeBridge == android.NativeBridgeEnabled {
- c.Properties.SubName += NativeBridgeSuffix
+ subName += NativeBridgeSuffix
}
llndk := c.IsLlndk()
@@ -1739,25 +1750,27 @@
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module.
- c.Properties.SubName += c.getNameSuffixWithVndkVersion(actx)
+ subName += getNameSuffixWithVndkVersion(actx, c)
} else if c.IsVendorPublicLibrary() {
- c.Properties.SubName += vendorPublicLibrarySuffix
- } else if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
+ subName += vendorPublicLibrarySuffix
+ } else if c.IsVndkPrebuiltLibrary() {
// .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
- c.Properties.SubName += VendorSuffix
+ subName += VendorSuffix
} else if c.InRamdisk() && !c.OnlyInRamdisk() {
- c.Properties.SubName += RamdiskSuffix
+ subName += RamdiskSuffix
} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
- c.Properties.SubName += VendorRamdiskSuffix
+ subName += VendorRamdiskSuffix
} else if c.InRecovery() && !c.OnlyInRecovery() {
- c.Properties.SubName += RecoverySuffix
- } else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) {
- c.Properties.SubName += sdkSuffix
+ subName += RecoverySuffix
+ } else if c.IsSdkVariant() && (c.SdkAndPlatformVariantVisibleToMake() || c.SplitPerApiLevel()) {
+ subName += sdkSuffix
if c.SplitPerApiLevel() {
- c.Properties.SubName += "." + c.SdkVersion()
+ subName += "." + c.SdkVersion()
}
}
+
+ return subName
}
// Returns true if Bazel was successfully used for the analysis of this module.
@@ -1795,7 +1808,7 @@
return
}
- c.setSubnameProperty(actx)
+ c.Properties.SubName = GetSubnameProperty(actx, c)
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if !apexInfo.IsForPlatform() {
c.hideApexVariantFromMake = true
diff --git a/cc/linkable.go b/cc/linkable.go
index d4b4770..6bec30c 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -176,10 +176,14 @@
IsVndk() bool
IsVndkExt() bool
IsVndkPrivate() bool
+ IsVendorPublicLibrary() bool
+ IsVndkPrebuiltLibrary() bool
HasVendorVariant() bool
HasProductVariant() bool
HasNonSystemVariants() bool
+ ProductSpecific() bool
InProduct() bool
+ SdkAndPlatformVariantVisibleToMake() bool
// SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName() string