Merge "Created kotlinAttributes struct"
This commit is contained in:
@@ -1092,11 +1092,6 @@ func (a *AndroidLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext)
|
|||||||
} else if !depLabels.Deps.IsEmpty() {
|
} else if !depLabels.Deps.IsEmpty() {
|
||||||
ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
|
ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(a.properties.Common_srcs) != 0 {
|
|
||||||
commonAttrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, a.properties.Common_srcs))
|
|
||||||
}
|
|
||||||
|
|
||||||
name := a.Name()
|
name := a.Name()
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "android_library",
|
Rule_class: "android_library",
|
||||||
|
@@ -1528,13 +1528,12 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
|||||||
Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
|
Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bp2BuildInfo.hasKotlinSrcs && len(a.properties.Common_srcs) == 0 {
|
if !bp2BuildInfo.hasKotlin {
|
||||||
appAttrs.javaCommonAttributes = commonAttrs
|
appAttrs.javaCommonAttributes = commonAttrs
|
||||||
appAttrs.bazelAapt = aapt
|
appAttrs.bazelAapt = aapt
|
||||||
appAttrs.Deps = deps
|
appAttrs.Deps = deps
|
||||||
} else {
|
} else {
|
||||||
ktName := a.Name() + "_kt"
|
ktName := a.Name() + "_kt"
|
||||||
commonAttrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, a.properties.Common_srcs))
|
|
||||||
ctx.CreateBazelTargetModule(
|
ctx.CreateBazelTargetModule(
|
||||||
bazel.BazelTargetModuleProperties{
|
bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "android_library",
|
Rule_class: "android_library",
|
||||||
|
48
java/java.go
48
java/java.go
@@ -2607,10 +2607,10 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte
|
|||||||
|
|
||||||
type javaCommonAttributes struct {
|
type javaCommonAttributes struct {
|
||||||
*javaResourcesAttributes
|
*javaResourcesAttributes
|
||||||
Srcs bazel.LabelListAttribute
|
*kotlinAttributes
|
||||||
Plugins bazel.LabelListAttribute
|
Srcs bazel.LabelListAttribute
|
||||||
Javacopts bazel.StringListAttribute
|
Plugins bazel.LabelListAttribute
|
||||||
Common_srcs bazel.LabelListAttribute
|
Javacopts bazel.StringListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
type javaDependencyLabels struct {
|
type javaDependencyLabels struct {
|
||||||
@@ -2637,8 +2637,8 @@ type javaAidlLibraryAttributes struct {
|
|||||||
// depending on the module type.
|
// depending on the module type.
|
||||||
type bp2BuildJavaInfo struct {
|
type bp2BuildJavaInfo struct {
|
||||||
// separates dependencies into dynamic dependencies and static dependencies.
|
// separates dependencies into dynamic dependencies and static dependencies.
|
||||||
DepLabels *javaDependencyLabels
|
DepLabels *javaDependencyLabels
|
||||||
hasKotlinSrcs bool
|
hasKotlin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertLibraryAttrsBp2Build returns a javaCommonAttributes struct with
|
// convertLibraryAttrsBp2Build returns a javaCommonAttributes struct with
|
||||||
@@ -2785,9 +2785,17 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
depLabels.Deps = deps
|
depLabels.Deps = deps
|
||||||
depLabels.StaticDeps = bazel.MakeLabelListAttribute(staticDeps)
|
depLabels.StaticDeps = bazel.MakeLabelListAttribute(staticDeps)
|
||||||
|
|
||||||
|
hasKotlin := !kotlinSrcs.IsEmpty()
|
||||||
|
if len(m.properties.Common_srcs) != 0 {
|
||||||
|
hasKotlin = true
|
||||||
|
commonAttrs.kotlinAttributes = &kotlinAttributes{
|
||||||
|
bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bp2BuildInfo := &bp2BuildJavaInfo{
|
bp2BuildInfo := &bp2BuildJavaInfo{
|
||||||
DepLabels: depLabels,
|
DepLabels: depLabels,
|
||||||
hasKotlinSrcs: !kotlinSrcs.IsEmpty(),
|
hasKotlin: hasKotlin,
|
||||||
}
|
}
|
||||||
|
|
||||||
return commonAttrs, bp2BuildInfo
|
return commonAttrs, bp2BuildInfo
|
||||||
@@ -2800,6 +2808,10 @@ type javaLibraryAttributes struct {
|
|||||||
Neverlink bazel.BoolAttribute
|
Neverlink bazel.BoolAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type kotlinAttributes struct {
|
||||||
|
Common_srcs bazel.LabelListAttribute
|
||||||
|
}
|
||||||
|
|
||||||
func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
||||||
commonAttrs, bp2BuildInfo := m.convertLibraryAttrsBp2Build(ctx)
|
commonAttrs, bp2BuildInfo := m.convertLibraryAttrsBp2Build(ctx)
|
||||||
depLabels := bp2BuildInfo.DepLabels
|
depLabels := bp2BuildInfo.DepLabels
|
||||||
@@ -2828,14 +2840,12 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
|
|||||||
}
|
}
|
||||||
name := m.Name()
|
name := m.Name()
|
||||||
|
|
||||||
if !bp2BuildInfo.hasKotlinSrcs && len(m.properties.Common_srcs) == 0 {
|
if !bp2BuildInfo.hasKotlin {
|
||||||
props = bazel.BazelTargetModuleProperties{
|
props = bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "java_library",
|
Rule_class: "java_library",
|
||||||
Bzl_load_location: "//build/bazel/rules/java:library.bzl",
|
Bzl_load_location: "//build/bazel/rules/java:library.bzl",
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attrs.javaCommonAttributes.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
|
|
||||||
|
|
||||||
props = bazel.BazelTargetModuleProperties{
|
props = bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "kt_jvm_library",
|
Rule_class: "kt_jvm_library",
|
||||||
Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl",
|
Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl",
|
||||||
@@ -2926,7 +2936,7 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
|
|||||||
Jvm_flags: jvmFlags,
|
Jvm_flags: jvmFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bp2BuildInfo.hasKotlinSrcs && len(m.properties.Common_srcs) == 0 {
|
if !bp2BuildInfo.hasKotlin {
|
||||||
attrs.javaCommonAttributes = commonAttrs
|
attrs.javaCommonAttributes = commonAttrs
|
||||||
attrs.Deps = deps
|
attrs.Deps = deps
|
||||||
} else {
|
} else {
|
||||||
@@ -2935,18 +2945,10 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
|
|||||||
Rule_class: "kt_jvm_library",
|
Rule_class: "kt_jvm_library",
|
||||||
Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl",
|
Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl",
|
||||||
}
|
}
|
||||||
ktAttrs := &javaLibraryAttributes{
|
|
||||||
Deps: deps,
|
|
||||||
javaCommonAttributes: &javaCommonAttributes{
|
|
||||||
Srcs: commonAttrs.Srcs,
|
|
||||||
Plugins: commonAttrs.Plugins,
|
|
||||||
Javacopts: commonAttrs.Javacopts,
|
|
||||||
javaResourcesAttributes: commonAttrs.javaResourcesAttributes,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(m.properties.Common_srcs) != 0 {
|
ktAttrs := &javaLibraryAttributes{
|
||||||
ktAttrs.javaCommonAttributes.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
|
Deps: deps,
|
||||||
|
javaCommonAttributes: commonAttrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(ktProps, android.CommonAttributes{Name: ktName}, ktAttrs)
|
ctx.CreateBazelTargetModule(ktProps, android.CommonAttributes{Name: ktName}, ktAttrs)
|
||||||
|
Reference in New Issue
Block a user