Merge "Add support for java_library proto plugin in bp2build" into main am: b0f3ff43e5
am: 674022ced0
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2768495 Change-Id: I383f1241634231f84aac1dd17a4743b28a16c473 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
b55cc83aa5
3 changed files with 52 additions and 0 deletions
|
@ -993,6 +993,7 @@ var (
|
||||||
"tradefed-result-interfaces",
|
"tradefed-result-interfaces",
|
||||||
"tradefed-device-build-interfaces",
|
"tradefed-device-build-interfaces",
|
||||||
"tradefed-invocation-interfaces",
|
"tradefed-invocation-interfaces",
|
||||||
|
"tradefed-lib-core",
|
||||||
}
|
}
|
||||||
|
|
||||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||||
|
|
|
@ -193,3 +193,46 @@ java_library_static {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaProtoPlugin(t *testing.T) {
|
||||||
|
runJavaProtoTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "java_library proto plugin",
|
||||||
|
StubbedBuildDefinitions: []string{"protoc-gen-test-plugin"},
|
||||||
|
Blueprint: `java_library_static {
|
||||||
|
name: "java-protos",
|
||||||
|
srcs: ["a.proto"],
|
||||||
|
proto: {
|
||||||
|
plugin: "test-plugin",
|
||||||
|
},
|
||||||
|
sdk_version: "current",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library_static {
|
||||||
|
name: "protoc-gen-test-plugin",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("proto_library", "java-protos_proto", AttrNameToString{
|
||||||
|
"srcs": `["a.proto"]`,
|
||||||
|
}),
|
||||||
|
MakeBazelTarget(
|
||||||
|
"java_lite_proto_library",
|
||||||
|
"java-protos_java_proto_lite",
|
||||||
|
AttrNameToString{
|
||||||
|
"deps": `[":java-protos_proto"]`,
|
||||||
|
"plugin": `":protoc-gen-test-plugin"`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
|
}),
|
||||||
|
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||||
|
"exports": `[":java-protos_java_proto_lite"]`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
|
}),
|
||||||
|
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||||
|
"java_library",
|
||||||
|
"java-protos",
|
||||||
|
AttrNameToString{
|
||||||
|
"sdk_version": `"current"`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -159,6 +159,8 @@ type protoAttributes struct {
|
||||||
|
|
||||||
Sdk_version bazel.StringAttribute
|
Sdk_version bazel.StringAttribute
|
||||||
Java_version bazel.StringAttribute
|
Java_version bazel.StringAttribute
|
||||||
|
|
||||||
|
Plugin bazel.LabelAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute, AdditionalProtoDeps bazel.LabelListAttribute) *bazel.Label {
|
func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute, AdditionalProtoDeps bazel.LabelListAttribute) *bazel.Label {
|
||||||
|
@ -189,12 +191,18 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
|
||||||
ctx.PropertyErrorf("proto.type", "cannot handle conversion at this time: %q", typ)
|
ctx.PropertyErrorf("proto.type", "cannot handle conversion at this time: %q", typ)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin := bazel.LabelAttribute{}
|
||||||
|
if m.protoProperties.Proto.Plugin != nil {
|
||||||
|
plugin.SetValue(android.BazelLabelForModuleDepSingle(ctx, "protoc-gen-"+*m.protoProperties.Proto.Plugin))
|
||||||
|
}
|
||||||
|
|
||||||
protoAttrs := &protoAttributes{
|
protoAttrs := &protoAttributes{
|
||||||
Deps: bazel.MakeLabelListAttribute(protoInfo.Proto_libs),
|
Deps: bazel.MakeLabelListAttribute(protoInfo.Proto_libs),
|
||||||
Transitive_deps: bazel.MakeLabelListAttribute(protoInfo.Transitive_proto_libs),
|
Transitive_deps: bazel.MakeLabelListAttribute(protoInfo.Transitive_proto_libs),
|
||||||
Additional_proto_deps: AdditionalProtoDeps,
|
Additional_proto_deps: AdditionalProtoDeps,
|
||||||
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
||||||
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
||||||
|
Plugin: plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
name := m.Name() + suffix
|
name := m.Name() + suffix
|
||||||
|
|
Loading…
Reference in a new issue