Merge "Pass java_library libs and static_libs to java_*_proto_library" into main
This commit is contained in:
@@ -948,6 +948,7 @@ var (
|
|||||||
"gson",
|
"gson",
|
||||||
"GsonBuildConfig.java",
|
"GsonBuildConfig.java",
|
||||||
"gson_version_generator",
|
"gson_version_generator",
|
||||||
|
"lab-resource-grpc",
|
||||||
}
|
}
|
||||||
|
|
||||||
Bp2buildModuleTypeAlwaysConvertList = []string{
|
Bp2buildModuleTypeAlwaysConvertList = []string{
|
||||||
@@ -970,8 +971,8 @@ var (
|
|||||||
"java_sdk_library_import",
|
"java_sdk_library_import",
|
||||||
"license",
|
"license",
|
||||||
"linker_config",
|
"linker_config",
|
||||||
"ndk_library",
|
|
||||||
"ndk_headers",
|
"ndk_headers",
|
||||||
|
"ndk_library",
|
||||||
"sysprop_library",
|
"sysprop_library",
|
||||||
"xsd_config",
|
"xsd_config",
|
||||||
// go/keep-sorted end
|
// go/keep-sorted end
|
||||||
|
@@ -141,17 +141,22 @@ func TestJavaProtoDefault(t *testing.T) {
|
|||||||
func TestJavaLibsAndOnlyProtoSrcs(t *testing.T) {
|
func TestJavaLibsAndOnlyProtoSrcs(t *testing.T) {
|
||||||
runJavaProtoTestCase(t, Bp2buildTestCase{
|
runJavaProtoTestCase(t, Bp2buildTestCase{
|
||||||
Description: "java_library that has only proto srcs",
|
Description: "java_library that has only proto srcs",
|
||||||
StubbedBuildDefinitions: []string{"java-lib"},
|
StubbedBuildDefinitions: []string{"java-lib-1", "java-lib-2"},
|
||||||
Blueprint: `java_library_static {
|
Blueprint: `java_library_static {
|
||||||
name: "java-protos",
|
name: "java-protos",
|
||||||
srcs: ["a.proto"],
|
srcs: ["a.proto"],
|
||||||
libs: ["java-lib"],
|
libs: ["java-lib-1"],
|
||||||
|
static_libs: ["java-lib-2"],
|
||||||
java_version: "7",
|
java_version: "7",
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
}
|
}
|
||||||
|
|
||||||
java_library_static {
|
java_library_static {
|
||||||
name: "java-lib",
|
name: "java-lib-1",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library_static {
|
||||||
|
name: "java-lib-2",
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
@@ -162,12 +167,19 @@ java_library_static {
|
|||||||
"java_lite_proto_library",
|
"java_lite_proto_library",
|
||||||
"java-protos_java_proto_lite",
|
"java-protos_java_proto_lite",
|
||||||
AttrNameToString{
|
AttrNameToString{
|
||||||
"deps": `[":java-protos_proto"]`,
|
"deps": `[":java-protos_proto"]`,
|
||||||
|
"additional_proto_deps": `[
|
||||||
|
":java-lib-1-neverlink",
|
||||||
|
":java-lib-2",
|
||||||
|
]`,
|
||||||
"java_version": `"7"`,
|
"java_version": `"7"`,
|
||||||
"sdk_version": `"current"`,
|
"sdk_version": `"current"`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||||
"exports": `[":java-protos_java_proto_lite"]`,
|
"exports": `[
|
||||||
|
":java-lib-2",
|
||||||
|
":java-protos_java_proto_lite",
|
||||||
|
]`,
|
||||||
"java_version": `"7"`,
|
"java_version": `"7"`,
|
||||||
"sdk_version": `"current"`,
|
"sdk_version": `"current"`,
|
||||||
}),
|
}),
|
||||||
|
25
java/java.go
25
java/java.go
@@ -3067,17 +3067,6 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protoDepLabel := bp2buildProto(ctx, &m.Module, srcPartitions[protoSrcPartition])
|
|
||||||
// Soong does not differentiate between a java_library and the Bazel equivalent of
|
|
||||||
// a java_proto_library + proto_library pair. Instead, in Soong proto sources are
|
|
||||||
// listed directly in the srcs of a java_library, and the classes produced
|
|
||||||
// by protoc are included directly in the resulting JAR. Thus upstream dependencies
|
|
||||||
// that depend on a java_library with proto sources can link directly to the protobuf API,
|
|
||||||
// and so this should be a static dependency.
|
|
||||||
if protoDepLabel != nil {
|
|
||||||
staticDeps.Append(bazel.MakeSingleLabelListAttribute(*protoDepLabel))
|
|
||||||
}
|
|
||||||
|
|
||||||
depLabels := &javaDependencyLabels{}
|
depLabels := &javaDependencyLabels{}
|
||||||
depLabels.Deps = deps
|
depLabels.Deps = deps
|
||||||
|
|
||||||
@@ -3093,6 +3082,20 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext
|
|||||||
}
|
}
|
||||||
depLabels.StaticDeps.Append(staticDeps)
|
depLabels.StaticDeps.Append(staticDeps)
|
||||||
|
|
||||||
|
var additionalProtoDeps bazel.LabelListAttribute
|
||||||
|
additionalProtoDeps.Append(depLabels.Deps)
|
||||||
|
additionalProtoDeps.Append(depLabels.StaticDeps)
|
||||||
|
protoDepLabel := bp2buildProto(ctx, &m.Module, srcPartitions[protoSrcPartition], additionalProtoDeps)
|
||||||
|
// Soong does not differentiate between a java_library and the Bazel equivalent of
|
||||||
|
// a java_proto_library + proto_library pair. Instead, in Soong proto sources are
|
||||||
|
// listed directly in the srcs of a java_library, and the classes produced
|
||||||
|
// by protoc are included directly in the resulting JAR. Thus upstream dependencies
|
||||||
|
// that depend on a java_library with proto sources can link directly to the protobuf API,
|
||||||
|
// and so this should be a static dependency.
|
||||||
|
if protoDepLabel != nil {
|
||||||
|
depLabels.StaticDeps.Append(bazel.MakeSingleLabelListAttribute(*protoDepLabel))
|
||||||
|
}
|
||||||
|
|
||||||
hasKotlin := !kotlinSrcs.IsEmpty()
|
hasKotlin := !kotlinSrcs.IsEmpty()
|
||||||
commonAttrs.kotlinAttributes = &kotlinAttributes{
|
commonAttrs.kotlinAttributes = &kotlinAttributes{
|
||||||
Kotlincflags: &m.properties.Kotlincflags,
|
Kotlincflags: &m.properties.Kotlincflags,
|
||||||
|
@@ -151,11 +151,17 @@ type protoAttributes struct {
|
|||||||
// a specific .proto file module explicitly.
|
// a specific .proto file module explicitly.
|
||||||
Transitive_deps bazel.LabelListAttribute
|
Transitive_deps bazel.LabelListAttribute
|
||||||
|
|
||||||
|
// This is the libs and the static_libs of the original java_library module.
|
||||||
|
// On the bazel side, after proto sources are generated in java_*_proto_library, a java_library
|
||||||
|
// will compile them. The libs and static_libs from the original java_library module need
|
||||||
|
// to be linked because they are necessary in compile-time classpath.
|
||||||
|
Additional_proto_deps bazel.LabelListAttribute
|
||||||
|
|
||||||
Sdk_version bazel.StringAttribute
|
Sdk_version bazel.StringAttribute
|
||||||
Java_version bazel.StringAttribute
|
Java_version bazel.StringAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute) *bazel.Label {
|
func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute, AdditionalProtoDeps bazel.LabelListAttribute) *bazel.Label {
|
||||||
protoInfo, ok := android.Bp2buildProtoProperties(ctx, &m.ModuleBase, protoSrcs)
|
protoInfo, ok := android.Bp2buildProtoProperties(ctx, &m.ModuleBase, protoSrcs)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
@@ -184,10 +190,11 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
|
|||||||
}
|
}
|
||||||
|
|
||||||
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),
|
||||||
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
Additional_proto_deps: AdditionalProtoDeps,
|
||||||
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
Java_version: bazel.StringAttribute{Value: m.properties.Java_version},
|
||||||
|
Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version},
|
||||||
}
|
}
|
||||||
|
|
||||||
name := m.Name() + suffix
|
name := m.Name() + suffix
|
||||||
|
Reference in New Issue
Block a user