Create fewer empty version variants
Don't create empty version variants for binaries, objects, rust
rlibs or rust dylibs.
Test: no change to build.ninja
Change-Id: I62d4d43da476eafdb258a08b5ada758bb2971a1a
diff --git a/cc/library.go b/cc/library.go
index bf7868f..059e29b 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1541,7 +1541,7 @@
mctx.CreateAliasVariation("latest", latestVersion)
}
-func VersionVariantAvailable(module interface {
+func CanBeOrLinkAgainstVersionVariants(module interface {
Host() bool
InRamdisk() bool
InRecovery() bool
@@ -1549,10 +1549,23 @@
return !module.Host() && !module.InRamdisk() && !module.InRecovery()
}
+func CanBeVersionVariant(module interface {
+ Host() bool
+ InRamdisk() bool
+ InRecovery() bool
+ CcLibraryInterface() bool
+ Shared() bool
+ Static() bool
+}) bool {
+ return CanBeOrLinkAgainstVersionVariants(module) &&
+ module.CcLibraryInterface() && (module.Shared() || module.Static())
+}
+
// versionSelector normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions,
// and propagates the value from implementation libraries to llndk libraries with the same name.
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
- if library, ok := mctx.Module().(LinkableInterface); ok && VersionVariantAvailable(library) {
+ if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
+
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 &&
!library.IsSdkVariant() {
@@ -1582,7 +1595,7 @@
// versionMutator splits a module into the mandatory non-stubs variant
// (which is unnamed) and zero or more stubs variants.
func versionMutator(mctx android.BottomUpMutatorContext) {
- if library, ok := mctx.Module().(LinkableInterface); ok && VersionVariantAvailable(library) {
+ if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
createVersionVariations(mctx, library.AllStubsVersions())
}
}