Converters for contributions to systemapi and vendorapi
The module types in scope of this conversion are
1. cc_library and cc_library_shared (non-null llndk or stubs prop)
2. cc_library_headers (all)
For (2), we need some postprocessing on the results of the parser
bp2BuildParseBaseProps. This is necessary because arch and os specific
API exports need to be flattened and added to the generateed API headers
target along NoConfigAxis
e.g.
```
The api equivalent of
cc_library_headers (
name = "lifoo",
deps = select({
"//build/bazel/platforms/arch:arm": ["arm_deps"],
"//build/bazel/platforms/arch:arm64": ["arm64_deps"],
}),
)
should be
cc_api_library_headers (
name = "lifoo",
deps = ["arm_deps", "arm64_deps"],
)
```
For (1), we also need to generate 1:many header api targets so that
arch-specific deps can propagate arch metadata to the top-level
api_domain rule
Test: go test ./bp2build
Test: go test ./cc
Change-Id: Ie40cba1ac8e89f290b3d926c190d5e93abd52859
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 06ded3f..49a919e 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -581,12 +581,12 @@
}
// Names of the cc_api_header targets in the bp2build workspace
-func (s *stubDecorator) apiHeaderLabels(ctx android.TopDownMutatorContext) bazel.LabelList {
+func apiHeaderLabels(ctx android.TopDownMutatorContext, hdrLibs []string) bazel.LabelList {
addSuffix := func(ctx android.BazelConversionPathContext, module blueprint.Module) string {
label := android.BazelModuleLabel(ctx, module)
return android.ApiContributionTargetName(label)
}
- return android.BazelLabelForModuleDepsWithFn(ctx, s.properties.Export_header_libs, addSuffix)
+ return android.BazelLabelForModuleDepsWithFn(ctx, hdrLibs, addSuffix)
}
func ndkLibraryBp2build(ctx android.TopDownMutatorContext, m *Module) {
@@ -604,7 +604,7 @@
apiLabel := android.BazelLabelForModuleSrcSingle(ctx, proptools.String(symbolFile)).Label
attrs.Api = *bazel.MakeLabelAttribute(apiLabel)
}
- apiHeaders := stubLibrary.apiHeaderLabels(ctx)
+ apiHeaders := apiHeaderLabels(ctx, stubLibrary.properties.Export_header_libs)
attrs.Hdrs = bazel.MakeLabelListAttribute(apiHeaders)
apiContributionTargetName := android.ApiContributionTargetName(ctx.ModuleName())
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: apiContributionTargetName}, attrs)