Implement bp2build for Sysprop Java
Bug: 297356813
Test: bp2build and inspect BUILD files
Test: Conversion Unit Tests
Change-Id: Ib70400eb91bca946df1d99d953d7a0e7e63fb7cf
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index d16bf32..13cf68f 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -24,6 +24,8 @@
"sync"
"android/soong/bazel"
+ "android/soong/sysprop/bp2build"
+ "android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -230,6 +232,10 @@
return m.BaseModuleName() + "_java_gen_public"
}
+func (m *syspropLibrary) bp2buildJavaImplementationModuleName() string {
+ return m.BaseModuleName() + "_java_library"
+}
+
func (m *syspropLibrary) BaseModuleName() string {
return m.ModuleBase.Name()
}
@@ -431,6 +437,7 @@
Min_sdk_version *string
Bazel_module struct {
Bp2build_available *bool
+ Label *string
}
}
@@ -551,8 +558,10 @@
Min_sdk_version: m.properties.Java.Min_sdk_version,
Bazel_module: struct {
Bp2build_available *bool
+ Label *string
}{
- Bp2build_available: proptools.BoolPtr(false),
+ Label: proptools.StringPtr(
+ fmt.Sprintf("//%s:%s", ctx.ModuleDir(), m.bp2buildJavaImplementationModuleName())),
},
})
@@ -573,6 +582,7 @@
Stem: proptools.StringPtr(m.BaseModuleName()),
Bazel_module: struct {
Bp2build_available *bool
+ Label *string
}{
Bp2build_available: proptools.BoolPtr(false),
},
@@ -592,13 +602,17 @@
// TODO(b/240463568): Additional properties will be added for API validation
func (m *syspropLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
- labels := cc.SyspropLibraryLabels{
- SyspropLibraryLabel: m.BaseModuleName(),
- SharedLibraryLabel: m.CcImplementationModuleName(),
- StaticLibraryLabel: cc.BazelLabelNameForStaticModule(m.CcImplementationModuleName()),
+ if m.Owner() != "Platform" {
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_UNSUPPORTED, "Only sysprop libraries owned by platform are supported at this time")
+ return
}
- cc.Bp2buildSysprop(ctx,
- labels,
- bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Srcs)),
- m.properties.Cpp.Min_sdk_version)
+ labels := bp2build.SyspropLibraryLabels{
+ SyspropLibraryLabel: m.BaseModuleName(),
+ CcSharedLibraryLabel: m.CcImplementationModuleName(),
+ CcStaticLibraryLabel: cc.BazelLabelNameForStaticModule(m.CcImplementationModuleName()),
+ JavaLibraryLabel: m.bp2buildJavaImplementationModuleName(),
+ }
+ bp2build.Bp2buildBaseSyspropLibrary(ctx, labels.SyspropLibraryLabel, bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Srcs)))
+ bp2build.Bp2buildSyspropCc(ctx, labels, m.properties.Cpp.Min_sdk_version)
+ bp2build.Bp2buildSyspropJava(ctx, labels, m.properties.Java.Min_sdk_version)
}