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

@@ -15,7 +15,6 @@ import (
rust_config "android/soong/rust/config"
"android/soong/starlark_fmt"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -34,19 +33,9 @@ func createSoongInjectionDirFiles(ctx *CodegenContext, metrics CodegenMetrics) (
files = append(files, newFile("android", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package.
files = append(files, newFile("android", "constants.bzl", android.BazelCcToolchainVars(cfg)))
// Visit all modules to determine the list of ndk libraries
// This list will be used to add additional flags for cc stub generation
ndkLibsStringFormatted := []string{}
ctx.Context().VisitAllModules(func(m blueprint.Module) {
if ctx.Context().ModuleType(m) == "ndk_library" {
ndkLibsStringFormatted = append(ndkLibsStringFormatted, fmt.Sprintf(`"%s"`, m.Name())) // name will be `"libc.ndk"`
}
})
files = append(files, newFile("cc_toolchain", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package.
files = append(files, newFile("cc_toolchain", "config_constants.bzl", cc_config.BazelCcToolchainVars(cfg)))
files = append(files, newFile("cc_toolchain", "sanitizer_constants.bzl", cc.BazelCcSanitizerToolchainVars(cfg)))
files = append(files, newFile("cc_toolchain", "ndk_libs.bzl", fmt.Sprintf("ndk_libs = [%v]", strings.Join(ndkLibsStringFormatted, ", "))))
files = append(files, newFile("java_toolchain", GeneratedBuildFileName, "")) // Creates a //java_toolchain package.
files = append(files, newFile("java_toolchain", "constants.bzl", java_config.BazelJavaToolchainVars(cfg)))