Replace ndk_libs.bzl with an attr in cc_stub_suite

(This CL is a cleanup, and should be a no-op)

Currently we support three variations of cc api stubs.
1. publicapi stubs, i.e. ndk stubs (empty additional args to ndkstubgen)
2. module-libapi stubs that are also an ndk library (--systemapi --apex)
3. module-libapi stubs that are not an ndk library (--systemapi --apex
   --no-ndk)

ndk_libs.bzl was used to differentiate between (2) and (3). This creates
an additional layer of indirection - users will need to modify this
external .bzl file if they would like to add a library to an ndk.

Replace this with an explicit atttibute in cc_stub_suite macro for better UX.

Test: go test ./bp2build
Test: b test //build/bazel/rules/cc:cc_stub_library_tests (added in
sibling CL)
Bug: 299501496

Change-Id: Idd3579e8013bae7a1740534f90d2767df5bac1a5
This commit is contained in:
Spandan Das
2023-10-06 21:35:21 +00:00
parent 69cf8a3221
commit 17a27f0c14
5 changed files with 74 additions and 18 deletions

View File

@@ -500,6 +500,10 @@ func createStubsBazelTargetIfNeeded(ctx android.Bp2buildMutatorContext, m *Modul
Deps: baseAttributes.deps,
Api_surface: proptools.StringPtr("module-libapi"),
}
if _, isNdk := ctx.ModuleFromName(m.Name() + ".ndk"); isNdk {
stubSuitesAttrs.Included_in_ndk = proptools.BoolPtr(true)
}
ctx.CreateBazelTargetModule(stubSuitesProps, android.CommonAttributes{
Name: m.Name() + "_stub_libs",
// TODO: b/303307456 - Remove this when data is properly supported in cc rules.
@@ -3023,6 +3027,13 @@ type bazelCcStubSuiteAttributes struct {
Soname *string
Deps bazel.LabelListAttribute
Api_surface *string
// Unless the library is in the NDK, module-libapi stubs should *not* include the public symbols
// Soong uses a global variable to determine if the library is in the NDK
// Since Bazel does not have global analysis, create an explicit property
// This property is only relevant if `api_surface = module-libapi`
// https://cs.android.com/android/_/android/platform/build/soong/+/main:cc/library.go;l=1214-1219;drc=7123cc5370a38983ee6325b5f5f6df19f4e4f10b;bpv=1;bpt=0
Included_in_ndk *bool
}
type bazelCcHeaderAbiCheckerAttributes struct {