Merge changes Ib004c2c3,I6b63d9d0

* changes:
  Create aliases for stubs in build/bazel/api_surfaces
  Add a method in bp2build to create aliases in another directory
This commit is contained in:
Spandan Das
2023-03-09 18:14:13 +00:00
committed by Gerrit Code Review
4 changed files with 74 additions and 2 deletions

View File

@@ -464,6 +464,21 @@ func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module
ctx.CreateBazelTargetModule(stubSuitesProps,
android.CommonAttributes{Name: m.Name() + "_stub_libs"},
stubSuitesAttrs)
// Add alias for the stub shared_library in @api_surfaces repository
currentModuleLibApiDir := ctx.Config().ApiSurfacesDir(android.ModuleLibApi, "current")
actualLabelInMainWorkspace := bazel.Label{
Label: fmt.Sprintf("@//%s:%s_stub_libs_current", ctx.ModuleDir(), m.Name()),
}
ctx.CreateBazelTargetAliasInDir(currentModuleLibApiDir, m.Name(), actualLabelInMainWorkspace)
// Add alias for headers exported by the stub library
headerLabelInMainWorkspace := bazel.Label{
// This label is generated from cc_stub_suite macro
Label: fmt.Sprintf("@//%s:%s_stub_libs_%s_headers", ctx.ModuleDir(), m.Name(), android.ModuleLibApi.String()),
}
headerAlias := m.Name() + "_headers"
ctx.CreateBazelTargetAliasInDir(currentModuleLibApiDir, headerAlias, headerLabelInMainWorkspace)
}
}