Only generate stubs for shared libraries

Bug: 246958825
Test: Unit tests
Test: m nothing
Change-Id: If976027314b079525397fa8f5d6dc3de9f1221c8
diff --git a/cc/library.go b/cc/library.go
index 83a2c68..56534a6 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2704,6 +2704,7 @@
 		modType = "cc_library_static"
 	} else {
 		modType = "cc_library_shared"
+		createStubsBazelTargetIfNeeded(ctx, module, compilerAttrs, exportedIncludes, baseAttributes)
 	}
 	props := bazel.BazelTargetModuleProperties{
 		Rule_class:        modType,
@@ -2711,8 +2712,6 @@
 	}
 
 	ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
-
-	createStubsBazelTargetIfNeeded(ctx, module, compilerAttrs, exportedIncludes, baseAttributes)
 }
 
 // TODO(b/199902614): Can this be factored to share with the other Attributes?