Merge "Bp2Build for libs property in java_library"
This commit is contained in:
15
java/java.go
15
java/java.go
@@ -2622,7 +2622,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
||||
if m.properties.Libs != nil {
|
||||
|
||||
// TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't
|
||||
if strings.HasPrefix(ctx.ModuleType(), "java_binary") {
|
||||
if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") {
|
||||
for _, d := range m.properties.Libs {
|
||||
neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
|
||||
neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
|
||||
@@ -2690,12 +2690,21 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
||||
Deps: deps,
|
||||
Exports: depLabels.StaticDeps,
|
||||
}
|
||||
name := m.Name()
|
||||
|
||||
if !bp2BuildInfo.hasKotlinSrcs && len(m.properties.Common_srcs) == 0 {
|
||||
props = bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "java_library",
|
||||
Bzl_load_location: "//build/bazel/rules/java:library.bzl",
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
|
||||
neverlinkProp := true
|
||||
neverLinkAttrs := &javaLibraryAttributes{
|
||||
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
|
||||
Neverlink: bazel.BoolAttribute{Value: &neverlinkProp},
|
||||
}
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs)
|
||||
} else {
|
||||
attrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
|
||||
|
||||
@@ -2703,10 +2712,10 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
||||
Rule_class: "kt_jvm_library",
|
||||
Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl",
|
||||
}
|
||||
// TODO (b/244210934): create neverlink-duplicate target once kt_jvm_library supports neverlink attribute
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
|
||||
}
|
||||
|
||||
name := m.Name()
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
|
||||
}
|
||||
|
||||
type javaBinaryHostAttributes struct {
|
||||
|
Reference in New Issue
Block a user