mixed builds correctly reference stubs libs

Bug: 270408757
Test: go test
Test: m NeuralNetworksTest_shared_partial --bazel-mode-staging
  && verify that Ninja commands link libneuralnetworks via stubs
Change-Id: I19bf5a829cea7fd00c0f82511ad2bddbc40fae4f
This commit is contained in:
Sam Delmerico
2023-04-10 17:19:51 -04:00
parent 2a1de1bfe6
commit ca438e6b72
6 changed files with 201 additions and 13 deletions

View File

@@ -931,9 +931,17 @@ func (handler *ccLibraryBazelHandler) generateSharedBazelBuildActions(ctx androi
func (handler *ccLibraryBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetCcInfo, android.GetConfigKeyApexVariant(ctx, GetApexConfigKey(ctx)))
if v := handler.module.library.stubsVersion(); v != "" {
stubsLabel := label + "_stub_libs-" + v
bazelCtx.QueueBazelRequest(stubsLabel, cquery.GetCcInfo, android.GetConfigKeyApexVariant(ctx, GetApexConfigKey(ctx)))
}
}
func (handler *ccLibraryBazelHandler) ProcessBazelQueryResponse(ctx android.ModuleContext, label string) {
if v := handler.module.library.stubsVersion(); v != "" {
// if we are a stubs variant, just use the Bazel stubs target
label = label + "_stub_libs-" + v
}
bazelCtx := ctx.Config().BazelContext
ccInfo, err := bazelCtx.GetCcInfo(label, android.GetConfigKeyApexVariant(ctx, GetApexConfigKey(ctx)))
if err != nil {
@@ -962,6 +970,9 @@ func (handler *ccLibraryBazelHandler) ProcessBazelQueryResponse(ctx android.Modu
}
handler.module.setAndroidMkVariablesFromCquery(ccInfo.CcAndroidMkInfo)
cctx := moduleContextFromAndroidModuleContext(ctx, handler.module)
addStubDependencyProviders(cctx)
}
func (library *libraryDecorator) setFlagExporterInfoFromCcInfo(ctx android.ModuleContext, ccInfo cquery.CcInfo) {
@@ -1787,6 +1798,12 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
Target: ctx.Target(),
})
addStubDependencyProviders(ctx)
return unstrippedOutputFile
}
func addStubDependencyProviders(ctx ModuleContext) {
stubs := ctx.GetDirectDepsWithTag(stubImplDepTag)
if len(stubs) > 0 {
var stubsInfo []SharedStubLibrary
@@ -1801,12 +1818,9 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
}
ctx.SetProvider(SharedLibraryStubsProvider, SharedLibraryStubsInfo{
SharedStubLibraries: stubsInfo,
IsLLNDK: ctx.IsLlndk(),
IsLLNDK: ctx.IsLlndk(),
})
}
return unstrippedOutputFile
}
func (library *libraryDecorator) unstrippedOutputFilePath() android.Path {
@@ -2648,7 +2662,7 @@ func LinkageMutator(mctx android.BottomUpMutatorContext) {
// normalizeVersions modifies `versions` in place, so that each raw version
// string becomes its normalized canonical form.
// Validates that the versions in `versions` are specified in least to greatest order.
func normalizeVersions(ctx android.BaseModuleContext, versions []string) {
func normalizeVersions(ctx android.BazelConversionPathContext, versions []string) {
var previous android.ApiLevel
for i, v := range versions {
ver, err := android.ApiLevelFromUser(ctx, v)