Merge "Revert "Do not convert non-unit tests."" into main
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 4fe64eb..16e2328 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -324,34 +324,35 @@
"libnativehelper": Bp2BuildDefaultTrueRecursively,
- "packages/apps/DevCamera": Bp2BuildDefaultTrue,
- "packages/apps/HTMLViewer": Bp2BuildDefaultTrue,
- "packages/apps/Protips": Bp2BuildDefaultTrue,
- "packages/apps/SafetyRegulatoryInfo": Bp2BuildDefaultTrue,
- "packages/apps/WallpaperPicker": Bp2BuildDefaultTrue,
- "packages/modules/NeuralNetworks/driver/cache": Bp2BuildDefaultTrueRecursively,
- "packages/modules/StatsD/lib/libstatssocket": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb": Bp2BuildDefaultTrue,
- "packages/modules/adb/apex": Bp2BuildDefaultTrue,
- "packages/modules/adb/fastdeploy": Bp2BuildDefaultTrue,
- "packages/modules/adb/crypto": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/libs": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/pairing_auth": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/pairing_connection": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/bpf_progs": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/service-t": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/staticlibs/native": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/staticlibs/netd/libnetdutils": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/tests/unit/jni": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Gki/libkver": Bp2BuildDefaultTrue,
- "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue,
- "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue,
- "packages/modules/NeuralNetworks/apex/testing": Bp2BuildDefaultTrue,
- "packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374)
- "packages/screensavers/Basic": Bp2BuildDefaultTrue,
- "packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321)
+ "packages/apps/DevCamera": Bp2BuildDefaultTrue,
+ "packages/apps/HTMLViewer": Bp2BuildDefaultTrue,
+ "packages/apps/Protips": Bp2BuildDefaultTrue,
+ "packages/apps/SafetyRegulatoryInfo": Bp2BuildDefaultTrue,
+ "packages/apps/WallpaperPicker": Bp2BuildDefaultTrue,
+ "packages/modules/NeuralNetworks/driver/cache": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/StatsD/lib/libstatssocket": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/adb": Bp2BuildDefaultTrue,
+ "packages/modules/adb/apex": Bp2BuildDefaultTrue,
+ "packages/modules/adb/fastdeploy": Bp2BuildDefaultTrue,
+ "packages/modules/adb/crypto": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/adb/libs": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/adb/pairing_auth": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/adb/pairing_connection": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Connectivity/bpf_progs": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Connectivity/service-t": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Connectivity/service/native": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Connectivity/staticlibs/native": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Connectivity/staticlibs/netd": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Connectivity/tests/unit/jni": Bp2BuildDefaultTrueRecursively,
+ "packages/modules/Gki/libkver": Bp2BuildDefaultTrue,
+ "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue,
+ "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue,
+ "packages/modules/NeuralNetworks/apex/testing": Bp2BuildDefaultTrue,
+ "packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374)
+ "packages/screensavers/Basic": Bp2BuildDefaultTrue,
+ "packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321)
"platform_testing/libraries/annotations": Bp2BuildDefaultTrueRecursively,
"platform_testing/libraries/flag-helpers/libflagtest": Bp2BuildDefaultTrueRecursively,
@@ -1000,6 +1001,9 @@
"tradefed-device-build-interfaces",
"tradefed-invocation-interfaces",
"tradefed-lib-core",
+
+ "libandroid_net_connectivity_com_android_net_module_util_jni",
+ "libservice-connectivity",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 5c9cbf2..d198596 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -5178,6 +5178,7 @@
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_stub_suite", "libfoo.ndk_stub_libs", AttrNameToString{
"api_surface": `"publicapi"`,
+ "included_in_ndk": `True`,
"soname": `"libfoo.so"`,
"source_library_label": `"//:libfoo"`,
"symbol_file": `"libfoo.map.txt"`,
@@ -5305,3 +5306,61 @@
},
})
}
+
+func TestPropertiesIfStubLibraryIsInNdk(t *testing.T) {
+ tc := Bp2buildTestCase{
+ Description: "If an equivalent ndk_library exists, set included_in_ndk=true for module-libapi stubs",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+// libfoo is an ndk library and contributes to module-libapi
+cc_library {
+ name: "libfoo",
+ stubs: {symbol_file: "libfoo.map.txt"},
+}
+ndk_library {
+ name: "libfoo",
+ first_version: "29",
+ symbol_file: "libfoo.map.txt",
+}
+// libbar is not an ndk library, but contributes to module-libapi
+cc_library {
+ name: "libbar",
+ stubs: {symbol_file: "libbar.map.txt"},
+}
+`,
+ StubbedBuildDefinitions: []string{"libfoo.ndk"},
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "libfoo_bp2build_cc_library_static", AttrNameToString{
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "libfoo", AttrNameToString{
+ "local_includes": `["."]`,
+ "stubs_symbol_file": `"libfoo.map.txt"`,
+ }),
+ MakeBazelTarget("cc_stub_suite", "libfoo_stub_libs", AttrNameToString{
+ "api_surface": `"module-libapi"`,
+ "soname": `"libfoo.so"`,
+ "source_library_label": `"//:libfoo"`,
+ "symbol_file": `"libfoo.map.txt"`,
+ "versions": `["current"]`,
+ "included_in_ndk": `True`,
+ }),
+ MakeBazelTarget("cc_library_static", "libbar_bp2build_cc_library_static", AttrNameToString{
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "libbar", AttrNameToString{
+ "local_includes": `["."]`,
+ "stubs_symbol_file": `"libbar.map.txt"`,
+ }),
+ MakeBazelTarget("cc_stub_suite", "libbar_stub_libs", AttrNameToString{
+ "api_surface": `"module-libapi"`,
+ "soname": `"libbar.so"`,
+ "source_library_label": `"//:libbar"`,
+ "symbol_file": `"libbar.map.txt"`,
+ "versions": `["current"]`,
+ }),
+ },
+ }
+ runCcLibraryTestCase(t, tc)
+}
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index c697235..b2792e6 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -15,7 +15,6 @@
rust_config "android/soong/rust/config"
"android/soong/starlark_fmt"
- "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -34,19 +33,9 @@
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)))
diff --git a/bp2build/conversion_test.go b/bp2build/conversion_test.go
index 6b10077..51675ce 100644
--- a/bp2build/conversion_test.go
+++ b/bp2build/conversion_test.go
@@ -107,10 +107,6 @@
},
{
dir: "cc_toolchain",
- basename: "ndk_libs.bzl",
- },
- {
- dir: "cc_toolchain",
basename: "sanitizer_constants.bzl",
},
{
diff --git a/cc/library.go b/cc/library.go
index 6acd7ae..2161512 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -500,6 +500,10 @@
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 @@
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 {
diff --git a/cc/lto.go b/cc/lto.go
index 281b527..d48be14 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -68,7 +68,7 @@
func (lto *lto) begin(ctx BaseModuleContext) {
// First, determine the module independent default LTO mode.
- ltoDefault := GlobalThinLTO(ctx)
+ ltoDefault := true
if ctx.Config().IsEnvTrue("DISABLE_LTO") {
ltoDefault = false
} else if lto.Never() {
@@ -163,10 +163,6 @@
return lto != nil && proptools.Bool(lto.Properties.Lto.Never)
}
-func GlobalThinLTO(ctx android.BaseModuleContext) bool {
- return !ctx.Config().IsEnvFalse("GLOBAL_THINLTO")
-}
-
// Propagate lto requirements down from binaries
func ltoDepsMutator(mctx android.TopDownMutatorContext) {
if m, ok := mctx.Module().(*Module); ok {
@@ -205,8 +201,6 @@
// Create lto variants for modules that need them
func ltoMutator(mctx android.BottomUpMutatorContext) {
- globalThinLTO := GlobalThinLTO(mctx)
-
if m, ok := mctx.Module().(*Module); ok && m.lto != nil {
// Create variations for LTO types required as static
// dependencies
@@ -218,10 +212,10 @@
variationNames = append(variationNames, "lto-none")
}
- if globalThinLTO && !m.lto.Properties.LtoEnabled {
+ if !m.lto.Properties.LtoEnabled {
mctx.SetDependencyVariation("lto-none")
}
- if !globalThinLTO && m.lto.Properties.LtoEnabled {
+ if m.lto.Properties.LtoEnabled {
mctx.SetDependencyVariation("lto-thin")
}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 4936559..df775de 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -594,9 +594,10 @@
symbolFileLabel := android.BazelLabelForModuleSrcSingle(ctx, proptools.String(ndk.properties.Symbol_file))
attrs := &bazelCcStubSuiteAttributes{
// TODO - b/300504837 Add ndk headers
- Symbol_file: proptools.StringPtr(symbolFileLabel.Label),
- Soname: proptools.StringPtr(sourceLibraryName + ".so"),
- Api_surface: proptools.StringPtr(android.PublicApi.String()),
+ Symbol_file: proptools.StringPtr(symbolFileLabel.Label),
+ Soname: proptools.StringPtr(sourceLibraryName + ".so"),
+ Api_surface: proptools.StringPtr(android.PublicApi.String()),
+ Included_in_ndk: proptools.BoolPtr(true),
}
if sourceLibrary, exists := ctx.ModuleFromName(sourceLibraryName); exists {
// the source library might not exist in minimal/unbuildable branches like kernel-build-tools.
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
index 3e92706..9647a18 100644
--- a/genrule/allowlists.go
+++ b/genrule/allowlists.go
@@ -17,6 +17,7 @@
var (
DepfileAllowList = []string{
"depfile_allowed_for_test",
+ "tflite_support_metadata_schema",
"tflite_support_spm_config",
"tflite_support_spm_encoder_config",
"gen_uwb_core_proto",
@@ -249,6 +250,13 @@
"ue_unittest_erofs_imgs",
"vts_vndk_abi_dump_zip",
"atest_integration_fake_src",
+ "VehicleServerProtoStub_cc@2.0-grpc-trout",
+ "VehicleServerProtoStub_cc@default-grpc",
+ "VehicleServerProtoStub_h@default-grpc",
+ "VehicleServerProtoStub_h@2.0-grpc-trout",
+ "chre_atoms_log.h",
+ "checkIn-service-stub-lite",
+ "seller-frontend-service-stub-lite",
}
SandboxingDenyPathList = []string{