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
This commit is contained in:
Colin Cross
2019-05-14 14:07:01 -07:00
parent 4c83b8950a
commit 33b2fb7333
5 changed files with 177 additions and 12 deletions

View File

@@ -52,7 +52,9 @@ func TestMain(m *testing.M) {
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 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi
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 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi
"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 testCcWithConfig(t *testing.T, bp string, config android.Config) *android.T
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 @@ func testCcError(t *testing.T, pattern string, bp string) {
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 {