Merge "Handle simple prebuilt static libraries from bazel" am: 76579e0e9a am: 70a88424ba am: 8d77e0b2fd

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

Change-Id: Ib330bfb45d699a0541c12362939ad780f4057a01
This commit is contained in:
Treehugger Robot
2021-04-09 15:23:32 +00:00
committed by Automerger Merge Worker
3 changed files with 104 additions and 2 deletions

View File

@@ -305,6 +305,7 @@ func PrebuiltStaticLibraryFactory() android.Module {
func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
module, library := NewPrebuiltLibrary(hod)
library.BuildOnlyStatic()
module.bazelHandler = &prebuiltStaticLibraryBazelHandler{module: module, library: library}
return module, library
}
@@ -319,6 +320,52 @@ type prebuiltObjectLinker struct {
properties prebuiltObjectProperties
}
type prebuiltStaticLibraryBazelHandler struct {
bazelHandler
module *Module
library *libraryDecorator
}
func (h *prebuiltStaticLibraryBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
bazelCtx := ctx.Config().BazelContext
staticLibs, ok := bazelCtx.GetPrebuiltCcStaticLibraryFiles(label, ctx.Arch().ArchType)
if !ok {
return false
}
if len(staticLibs) > 1 {
ctx.ModuleErrorf("expected 1 static library from bazel target %q, got %s", label, staticLibs)
return false
}
// TODO(b/184543518): cc_prebuilt_library_static may have properties for re-exporting flags
// TODO(eakammer):Add stub-related flags if this library is a stub library.
// h.library.exportVersioningMacroIfNeeded(ctx)
// 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{}
if len(staticLibs) == 0 {
h.module.outputFile = android.OptionalPath{}
return true
}
out := android.PathForBazelOut(ctx, staticLibs[0])
h.module.outputFile = android.OptionalPathForPath(out)
depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(out).Build()
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: out,
TransitiveStaticLibrariesForOrdering: depSet,
})
return true
}
func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt {
return &p.Prebuilt
}