Expose TocFile via CcInfo
To reflect what's provided in SharedLibraryInfoProvider Move the logic for identifying the toc file into Starlark instead of the Soong Go code. Adapt TestGetCcInfoParseResults to expect the toc as well. Test: build/bazel/cquery/request_type_test.go:TestGetCcInfoParseResults Test: cc/library_test.go:TestCcLibrarySharedWithBazel Test: build/bazel/ci/mixed_{libc,droid}.sh Change-Id: I40ad47158cb98b14ca03c21e351988818cb01770
This commit is contained in:
parent
4fbc62196d
commit
62585e8436
@@ -604,7 +604,10 @@ func (handler *ccLibraryBazelHandler) generateSharedBazelBuildActions(ctx androi
|
||||
|
||||
handler.module.linker.(*libraryDecorator).unstrippedOutputFile = outputFilePath
|
||||
|
||||
tocFile := getTocFile(ctx, label, ccInfo.OutputFiles)
|
||||
var tocFile android.OptionalPath
|
||||
if len(ccInfo.TocFile) > 0 {
|
||||
tocFile = android.OptionalPathForPath(android.PathForBazelOut(ctx, ccInfo.TocFile))
|
||||
}
|
||||
handler.module.linker.(*libraryDecorator).tocFile = tocFile
|
||||
|
||||
ctx.SetProvider(SharedLibraryInfoProvider, SharedLibraryInfo{
|
||||
@@ -617,25 +620,6 @@ func (handler *ccLibraryBazelHandler) generateSharedBazelBuildActions(ctx androi
|
||||
return true
|
||||
}
|
||||
|
||||
// getTocFile looks for the .so.toc file in the target's output files, if any. The .so.toc file
|
||||
// contains the table of contents of all symbols of a shared object.
|
||||
func getTocFile(ctx android.ModuleContext, label string, outputFiles []string) android.OptionalPath {
|
||||
var tocFile string
|
||||
for _, file := range outputFiles {
|
||||
if strings.HasSuffix(file, ".so.toc") {
|
||||
if tocFile != "" {
|
||||
ctx.ModuleErrorf("The %s target cannot produce more than 1 .toc file.", label)
|
||||
}
|
||||
tocFile = file
|
||||
// Don't break to validate that there are no multiple .toc files per .so.
|
||||
}
|
||||
}
|
||||
if tocFile == "" {
|
||||
return android.OptionalPath{}
|
||||
}
|
||||
return android.OptionalPathForPath(android.PathForBazelOut(ctx, tocFile))
|
||||
}
|
||||
|
||||
func (handler *ccLibraryBazelHandler) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
||||
bazelCtx := ctx.Config().BazelContext
|
||||
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
||||
|
@@ -337,19 +337,29 @@ cc_library_shared {
|
||||
Includes: []string{"include"},
|
||||
SystemIncludes: []string{"system_include"},
|
||||
RootDynamicLibraries: []string{"foo.so"},
|
||||
TocFile: "foo.so.toc",
|
||||
},
|
||||
},
|
||||
}
|
||||
ctx := testCcWithConfig(t, config)
|
||||
|
||||
sharedFoo := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon_shared").Module()
|
||||
outputFiles, err := sharedFoo.(android.OutputFileProducer).OutputFiles("")
|
||||
producer := sharedFoo.(android.OutputFileProducer)
|
||||
outputFiles, err := producer.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())
|
||||
|
||||
tocFilePath := sharedFoo.(*Module).Toc()
|
||||
if !tocFilePath.Valid() {
|
||||
t.Errorf("Invalid tocFilePath: %s", tocFilePath)
|
||||
}
|
||||
tocFile := tocFilePath.Path()
|
||||
expectedToc := "outputbase/execroot/__main__/foo.so.toc"
|
||||
android.AssertStringEquals(t, "toc file", expectedToc, tocFile.String())
|
||||
|
||||
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"]
|
||||
|
Reference in New Issue
Block a user