diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/droidstubs.go | 29 | ||||
| -rw-r--r-- | java/java.go | 25 | ||||
| -rw-r--r-- | java/proto.go | 17 |
3 files changed, 26 insertions, 45 deletions
diff --git a/java/droidstubs.go b/java/droidstubs.go index 1d5dd7624..67a55bd49 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -24,7 +24,6 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" - "android/soong/bazel" "android/soong/java/config" "android/soong/remoteexec" ) @@ -855,34 +854,6 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) { } } -var _ android.ApiProvider = (*Droidstubs)(nil) - -type bazelJavaApiContributionAttributes struct { - Api bazel.LabelAttribute - Api_surface *string -} - -func (d *Droidstubs) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) { - props := bazel.BazelTargetModuleProperties{ - Rule_class: "java_api_contribution", - Bzl_load_location: "//build/bazel/rules/apis:java_api_contribution.bzl", - } - apiFile := d.properties.Check_api.Current.Api_file - // Do not generate a target if check_api is not set - if apiFile == nil { - return - } - attrs := &bazelJavaApiContributionAttributes{ - Api: *bazel.MakeLabelAttribute( - android.BazelLabelForModuleSrcSingle(ctx, proptools.String(apiFile)).Label, - ), - Api_surface: proptools.StringPtr(bazelApiSurfaceName(d.Name())), - } - ctx.CreateBazelTargetModule(props, android.CommonAttributes{ - Name: android.ApiContributionTargetName(ctx.ModuleName()), - }, attrs) -} - func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) { api_file := d.properties.Check_api.Current.Api_file api_surface := d.properties.Api_surface diff --git a/java/java.go b/java/java.go index d5aeb7cb2..fbad4f390 100644 --- a/java/java.go +++ b/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.Deps = deps @@ -3093,6 +3082,20 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext } 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() commonAttrs.kotlinAttributes = &kotlinAttributes{ Kotlincflags: &m.properties.Kotlincflags, diff --git a/java/proto.go b/java/proto.go index 2ed7b27e9..48adadcc9 100644 --- a/java/proto.go +++ b/java/proto.go @@ -151,11 +151,17 @@ type protoAttributes struct { // a specific .proto file module explicitly. 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 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) if !ok { return nil @@ -184,10 +190,11 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze } protoAttrs := &protoAttributes{ - Deps: bazel.MakeLabelListAttribute(protoInfo.Proto_libs), - Transitive_deps: bazel.MakeLabelListAttribute(protoInfo.Transitive_proto_libs), - Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, - Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, + Deps: bazel.MakeLabelListAttribute(protoInfo.Proto_libs), + Transitive_deps: bazel.MakeLabelListAttribute(protoInfo.Transitive_proto_libs), + Additional_proto_deps: AdditionalProtoDeps, + Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, + Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, } name := m.Name() + suffix |