Set Bazel_module for (un)converted sysprop libs

Set Bazel_module.Label for modules that are migrated and
Bazel_module.Bp2build_available: false for types that are not converted.

Test: CI
Test: m json-module-graph and inspect
Change-Id: I47b82d5055cdfd5ba6b2878e88f39447f1a50223
This commit is contained in:
Liz Kammer
2023-08-11 14:16:05 -04:00
parent c86e094e13
commit 12dc96ebe1

View File

@@ -24,6 +24,7 @@ import (
"sync"
"android/soong/bazel"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -410,7 +411,7 @@ type ccLibraryProperties struct {
Apex_available []string
Min_sdk_version *string
Bazel_module struct {
Bp2build_available *bool
Label *string
}
}
@@ -428,6 +429,9 @@ type javaLibraryProperties struct {
SyspropPublicStub string
Apex_available []string
Min_sdk_version *string
Bazel_module struct {
Bp2build_available *bool
}
}
func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
@@ -473,6 +477,14 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
"Unknown value %s: must be one of Platform, Vendor or Odm", m.Owner())
}
var label *string
if b, ok := ctx.Module().(android.Bazelable); ok && b.ShouldConvertWithBp2build(ctx) {
// TODO: b/295566168 - this will need to change once build files are checked in to account for
// checked in modules in mixed builds
label = proptools.StringPtr(
fmt.Sprintf("//%s:%s", ctx.ModuleDir(), m.CcImplementationModuleName()))
}
// Generate a C++ implementation library.
// cc_library can receive *.sysprop files as their srcs, generating sources itself.
ccProps := ccLibraryProperties{}
@@ -492,11 +504,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
ccProps.Host_supported = m.properties.Host_supported
ccProps.Apex_available = m.ApexProperties.Apex_available
ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version
// A Bazel macro handles this, so this module does not need to be handled
// in bp2build
// TODO(b/237810289) perhaps do something different here so that we aren't
// also disabling these modules in mixed builds
ccProps.Bazel_module.Bp2build_available = proptools.BoolPtr(false)
ccProps.Bazel_module.Label = label
ctx.CreateModule(cc.LibraryFactory, &ccProps)
scope := "internal"
@@ -541,6 +549,11 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
SyspropPublicStub: publicStub,
Apex_available: m.ApexProperties.Apex_available,
Min_sdk_version: m.properties.Java.Min_sdk_version,
Bazel_module: struct {
Bp2build_available *bool
}{
Bp2build_available: proptools.BoolPtr(false),
},
})
if publicStub != "" {
@@ -558,6 +571,11 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
Sdk_version: proptools.StringPtr("core_current"),
Libs: []string{javaSyspropStub},
Stem: proptools.StringPtr(m.BaseModuleName()),
Bazel_module: struct {
Bp2build_available *bool
}{
Bp2build_available: proptools.BoolPtr(false),
},
})
}