diff options
author | 2021-09-14 20:58:25 +0000 | |
---|---|---|
committer | 2021-09-16 18:13:52 +0000 | |
commit | bc4e734e59cf6d54a0ce311bab1cc86158ec028f (patch) | |
tree | 681de70f6a08cf1563566dd6bfb55e115086a226 /cc/library_test.go | |
parent | ac5097fcf4cdc14932b21b92c7c99b125c7efac7 (diff) |
Incorporate cc_library_shared into mixed builds
The infrastructure is already there via its need in
`cc_library`. Therefore, just enable it by setting
the `bazelHandler` in `LibrarySharedFactory`, and
add a test to verify the functionality.
Bug: 198817980
Test: cc/library_test.go:TestCcLibrarySharedWithBazel
Change-Id: Ibff80616632af59a0e409110f8645e028f99c7d6
Diffstat (limited to 'cc/library_test.go')
-rw-r--r-- | cc/library_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cc/library_test.go b/cc/library_test.go index 6b349b615..6caee49d7 100644 --- a/cc/library_test.go +++ b/cc/library_test.go @@ -320,3 +320,38 @@ func TestLibraryDynamicList(t *testing.T) { 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) +} |