aboutsummaryrefslogtreecommitdiff
path: root/cc/library_headers.go
diff options
context:
space:
mode:
authorLiz Kammer <eakammer@google.com>2021-04-12 15:42:51 -0400
committerLiz Kammer <eakammer@google.com>2021-04-23 09:37:33 -0400
commitb6a55bf065a4c1d0dfb7f4f9638f1333de3e183e (patch)
tree997677f6561972c10bf8523735227fa382e7cd04 /cc/library_headers.go
parent1552c7b1787ffdf36ff7108606cf1cda1ac0c3bc (diff)
downloadsoong-b6a55bf065a4c1d0dfb7f4f9638f1333de3e183e.tar.gz
Incorporate cc_library_headers into mixed builds
Test: go soong tests Test: bp2build generate & sync; mixed build libc; mixed build su (su is an Android.mk target that relies on converted a cc_library_headers) Bug: 181552740 Change-Id: I9efd587970551fd41f642a208f0aa0a80e8694e0
Diffstat (limited to 'cc/library_headers.go')
-rw-r--r--cc/library_headers.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 078242fab..f2cb52baf 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -43,6 +43,52 @@ func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("cc_prebuilt_library_headers", prebuiltLibraryHeaderFactory)
}
+type libraryHeaderBazelHander struct {
+ bazelHandler
+
+ module *Module
+ library *libraryDecorator
+}
+
+func (h *libraryHeaderBazelHander) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
+ bazelCtx := ctx.Config().BazelContext
+ ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
+ if err != nil {
+ ctx.ModuleErrorf("Error getting Bazel CcInfo: %s", err)
+ return false
+ }
+ if !ok {
+ return false
+ }
+
+ outputPaths := ccInfo.OutputFiles
+ if len(outputPaths) != 1 {
+ ctx.ModuleErrorf("expected exactly one output file for %q, but got %q", label, outputPaths)
+ return false
+ }
+
+ outputPath := android.PathForBazelOut(ctx, outputPaths[0])
+ h.module.outputFile = android.OptionalPathForPath(outputPath)
+
+ // HeaderLibraryInfo is an empty struct to indicate to dependencies that this is a header library
+ ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
+
+ flagExporterInfo := flagExporterInfoFromCcInfo(ctx, ccInfo)
+ // Store flag info to be passed along to androimk
+ // TODO(b/184387147): Androidmk should be done in Bazel, not Soong.
+ h.library.flagExporterInfo = &flagExporterInfo
+ // flag exporters consolidates properties like includes, flags, dependencies that should be
+ // exported from this module to other modules
+ ctx.SetProvider(FlagExporterInfoProvider, flagExporterInfo)
+
+ // Dependencies on this library will expect collectedSnapshotHeaders to be set, otherwise
+ // validation will fail. For now, set this to an empty list.
+ // TODO(cparsons): More closely mirror the collectHeadersForSnapshot implementation.
+ h.library.collectedSnapshotHeaders = android.Paths{}
+
+ return true
+}
+
// cc_library_headers contains a set of c/c++ headers which are imported by
// other soong cc modules using the header_libs property. For best practices,
// use export_include_dirs property or LOCAL_EXPORT_C_INCLUDE_DIRS for
@@ -51,6 +97,7 @@ func LibraryHeaderFactory() android.Module {
module, library := NewLibrary(android.HostAndDeviceSupported)
library.HeaderOnly()
module.sdkMemberTypes = []android.SdkMemberType{headersLibrarySdkMemberType}
+ module.bazelHandler = &libraryHeaderBazelHander{module: module, library: library}
return module.Init()
}