Merge "convert logtags in java srcs" am: b6e1614272
am: af8e9c73e6
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2042847 Change-Id: Ifb620a0dc2c6077f800ce9a8e587a1f8ee2484ad Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -219,3 +219,35 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledManually(t *testing.T)
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaLibraryLogTags(t *testing.T) {
|
||||||
|
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||||
|
description: "Java library - logtags creates separate dependency",
|
||||||
|
moduleTypeUnderTest: "java_library",
|
||||||
|
moduleTypeUnderTestFactory: java.LibraryFactory,
|
||||||
|
blueprint: `java_library {
|
||||||
|
name: "example_lib",
|
||||||
|
srcs: [
|
||||||
|
"a.java",
|
||||||
|
"b.java",
|
||||||
|
"a.logtag",
|
||||||
|
"b.logtag",
|
||||||
|
],
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}`,
|
||||||
|
expectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("event_log_tags", "example_lib_logtags", attrNameToString{
|
||||||
|
"srcs": `[
|
||||||
|
"a.logtag",
|
||||||
|
"b.logtag",
|
||||||
|
]`,
|
||||||
|
}),
|
||||||
|
makeBazelTarget("java_library", "example_lib", attrNameToString{
|
||||||
|
"srcs": `[
|
||||||
|
"a.java",
|
||||||
|
"b.java",
|
||||||
|
":example_lib_logtags",
|
||||||
|
]`,
|
||||||
|
}),
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
27
java/java.go
27
java/java.go
@@ -2041,6 +2041,10 @@ type javaDependencyLabels struct {
|
|||||||
// and also separates dependencies into dynamic dependencies and static dependencies.
|
// and also separates dependencies into dynamic dependencies and static dependencies.
|
||||||
// Each corresponding Bazel target type, can have a different method for handling
|
// Each corresponding Bazel target type, can have a different method for handling
|
||||||
// dynamic vs. static dependencies, and so these are returned to the calling function.
|
// dynamic vs. static dependencies, and so these are returned to the calling function.
|
||||||
|
type eventLogTagsAttributes struct {
|
||||||
|
Srcs bazel.LabelListAttribute
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) (*javaCommonAttributes, *javaDependencyLabels) {
|
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) (*javaCommonAttributes, *javaDependencyLabels) {
|
||||||
var srcs bazel.LabelListAttribute
|
var srcs bazel.LabelListAttribute
|
||||||
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
||||||
@@ -2055,11 +2059,32 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
|
|
||||||
javaSrcPartition := "java"
|
javaSrcPartition := "java"
|
||||||
protoSrcPartition := "proto"
|
protoSrcPartition := "proto"
|
||||||
|
logtagSrcPartition := "logtag"
|
||||||
srcPartitions := bazel.PartitionLabelListAttribute(ctx, &srcs, bazel.LabelPartitions{
|
srcPartitions := bazel.PartitionLabelListAttribute(ctx, &srcs, bazel.LabelPartitions{
|
||||||
javaSrcPartition: bazel.LabelPartition{Extensions: []string{".java"}, Keep_remainder: true},
|
javaSrcPartition: bazel.LabelPartition{Extensions: []string{".java"}, Keep_remainder: true},
|
||||||
|
logtagSrcPartition: bazel.LabelPartition{Extensions: []string{".logtags", ".logtag"}},
|
||||||
protoSrcPartition: android.ProtoSrcLabelPartition,
|
protoSrcPartition: android.ProtoSrcLabelPartition,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
javaSrcs := srcPartitions[javaSrcPartition]
|
||||||
|
|
||||||
|
var logtagsSrcs bazel.LabelList
|
||||||
|
if !srcPartitions[logtagSrcPartition].IsEmpty() {
|
||||||
|
logtagsLibName := m.Name() + "_logtags"
|
||||||
|
logtagsSrcs = bazel.MakeLabelList([]bazel.Label{{Label: ":" + logtagsLibName}})
|
||||||
|
ctx.CreateBazelTargetModule(
|
||||||
|
bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "event_log_tags",
|
||||||
|
Bzl_load_location: "//build/make/tools:event_log_tags.bzl",
|
||||||
|
},
|
||||||
|
android.CommonAttributes{Name: logtagsLibName},
|
||||||
|
&eventLogTagsAttributes{
|
||||||
|
Srcs: srcPartitions[logtagSrcPartition],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
javaSrcs.Append(bazel.MakeLabelListAttribute(logtagsSrcs))
|
||||||
|
|
||||||
var javacopts []string
|
var javacopts []string
|
||||||
if m.properties.Javacflags != nil {
|
if m.properties.Javacflags != nil {
|
||||||
javacopts = append(javacopts, m.properties.Javacflags...)
|
javacopts = append(javacopts, m.properties.Javacflags...)
|
||||||
@@ -2071,7 +2096,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
commonAttrs := &javaCommonAttributes{
|
commonAttrs := &javaCommonAttributes{
|
||||||
Srcs: srcPartitions[javaSrcPartition],
|
Srcs: javaSrcs,
|
||||||
Plugins: bazel.MakeLabelListAttribute(
|
Plugins: bazel.MakeLabelListAttribute(
|
||||||
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user