Incorporate cc_library_shared into mixed builds am: bc4e734e59 am: 5ce0135bd8 am: f4718aefa7

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1826912

Change-Id: I0879a59133f3491272ad262d280c33e1f801da40
This commit is contained in:
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
2021-09-17 15:13:56 +00:00
committed by Automerger Merge Worker
2 changed files with 36 additions and 0 deletions

View File

@@ -370,6 +370,7 @@ func LibrarySharedFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported) module, library := NewLibrary(android.HostAndDeviceSupported)
library.BuildOnlyShared() library.BuildOnlyShared()
module.sdkMemberTypes = []android.SdkMemberType{sharedLibrarySdkMemberType} module.sdkMemberTypes = []android.SdkMemberType{sharedLibrarySdkMemberType}
module.bazelHandler = &ccLibraryBazelHandler{module: module}
return module.Init() return module.Init()
} }

View File

@@ -320,3 +320,38 @@ func TestLibraryDynamicList(t *testing.T) {
libfoo.Args["ldFlags"], "-Wl,--dynamic-list,foo.dynamic.txt") libfoo.Args["ldFlags"], "-Wl,--dynamic-list,foo.dynamic.txt")
} }
func TestCcLibrarySharedWithBazel(t *testing.T) {
bp := `
cc_library_shared {
name: "foo",
srcs: ["foo.cc"],
bazel_module: { label: "//foo/bar:bar" },
}`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.BazelContext = android.MockBazelContext{
OutputBaseDir: "outputbase",
LabelToCcInfo: map[string]cquery.CcInfo{
"//foo/bar:bar": cquery.CcInfo{
CcObjectFiles: []string{"foo.o"},
Includes: []string{"include"},
SystemIncludes: []string{"system_include"},
RootDynamicLibraries: []string{"foo.so"},
},
},
}
ctx := testCcWithConfig(t, config)
sharedFoo := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon_shared").Module()
outputFiles, err := sharedFoo.(android.OutputFileProducer).OutputFiles("")
if err != nil {
t.Errorf("Unexpected error getting cc_object outputfiles %s", err)
}
expectedOutputFiles := []string{"outputbase/execroot/__main__/foo.so"}
android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
entries := android.AndroidMkEntriesForTest(t, ctx, sharedFoo)[0]
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
}