Support using cc_prebuilt_library_shared with cc_library

Allow a cc_prebuilt_library_shared to share the same name as a
cc_library by always creating static and shared variants of
prebuilts so that the variants of the source module are always
a superset of the variants of the target module.

Bug: 131709055
Test: TestPrebuilts
Change-Id: I4afd6d37e6a986d08ad25aee69eca6d994febc6b
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 36d8aa4..ef6364b 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -52,7 +52,9 @@
 	os.Exit(run())
 }
 
-func createTestContext(t *testing.T, config android.Config, bp string, os android.OsType) *android.TestContext {
+func createTestContext(t *testing.T, config android.Config, bp string, fs map[string][]byte,
+	os android.OsType) *android.TestContext {
+
 	ctx := android.NewTestArchContext()
 	ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory))
 	ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory))
@@ -77,12 +79,11 @@
 		ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
 	})
 	ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
-	ctx.Register()
 
 	// add some modules that are required by the compiler and/or linker
 	bp = bp + GatherRequiredDepsForTest(os)
 
-	ctx.MockFileSystem(map[string][]byte{
+	mockFS := map[string][]byte{
 		"Android.bp":  []byte(bp),
 		"foo.c":       nil,
 		"bar.c":       nil,
@@ -90,7 +91,14 @@
 		"b.aidl":      nil,
 		"my_include":  nil,
 		"foo.map.txt": nil,
-	})
+		"liba.so":     nil,
+	}
+
+	for k, v := range fs {
+		mockFS[k] = v
+	}
+
+	ctx.MockFileSystem(mockFS)
 
 	return ctx
 }
@@ -101,7 +109,8 @@
 
 func testCcWithConfigForOs(t *testing.T, bp string, config android.Config, os android.OsType) *android.TestContext {
 	t.Helper()
-	ctx := createTestContext(t, config, bp, os)
+	ctx := createTestContext(t, config, bp, nil, os)
+	ctx.Register()
 
 	_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
 	android.FailIfErrored(t, errs)
@@ -134,7 +143,8 @@
 	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
 	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
 
-	ctx := createTestContext(t, config, bp, android.Android)
+	ctx := createTestContext(t, config, bp, nil, android.Android)
+	ctx.Register()
 
 	_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
 	if len(errs) > 0 {