Remove global state on module suffixes from vendor and recovery snapshots

Propgate the Android.mk suffix from source modules into the snapshot so
that it can be used for the prebuilt modules.

Bug: 177098205
Test: vendor_snapshot_test.go
Change-Id: Iea151dc91395f714fbcad1df3a6fd0874e5455d9
diff --git a/cc/cc.go b/cc/cc.go
index 0dd90cf..d282b6e 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -50,8 +50,6 @@
 		ctx.BottomUp("version", versionMutator).Parallel()
 		ctx.BottomUp("begin", BeginMutator).Parallel()
 		ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
-		ctx.BottomUp("vendor_snapshot_source", VendorSnapshotSourceMutator).Parallel()
-		ctx.BottomUp("recovery_snapshot_source", RecoverySnapshotSourceMutator).Parallel()
 	})
 
 	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -1235,7 +1233,7 @@
 }
 
 func (c *Module) isSnapshotPrebuilt() bool {
-	if p, ok := c.linker.(interface{ isSnapshotPrebuilt() bool }); ok {
+	if p, ok := c.linker.(snapshotInterface); ok {
 		return p.isSnapshotPrebuilt()
 	}
 	return false
@@ -2887,8 +2885,6 @@
 }
 
 func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface, depName string) string {
-	vendorSuffixModules := vendorSuffixModules(ctx.Config())
-	recoverySuffixModules := recoverySuffixModules(ctx.Config())
 	vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
 
 	libName := baseLibName(depName)
@@ -2899,20 +2895,10 @@
 
 	if c, ok := ccDep.(*Module); ok {
 		// Use base module name for snapshots when exporting to Makefile.
-		if c.isSnapshotPrebuilt() {
+		if snapshotPrebuilt, ok := c.linker.(snapshotInterface); ok {
 			baseName := c.BaseModuleName()
 
-			if c.IsVndk() {
-				return baseName + ".vendor"
-			}
-
-			if c.InVendor() && vendorSuffixModules[baseName] {
-				return baseName + ".vendor"
-			} else if c.InRecovery() && recoverySuffixModules[baseName] {
-				return baseName + ".recovery"
-			} else {
-				return baseName
-			}
+			return baseName + snapshotPrebuilt.snapshotAndroidMkSuffix()
 		}
 	}