arch variant support for libs property
Test: bp2build tests and manually inspected Build file for libprotobuf-java-lite Bug: 244210934 Change-Id: Id60d859eea2c23fa7a29784faeed5cb050d4193e
This commit is contained in:
@@ -715,3 +715,43 @@ func TestJavaLibraryKotlinCommonSrcs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaLibraryArchVariantLibs(t *testing.T) {
|
||||||
|
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "java_library with arch variant libs",
|
||||||
|
Blueprint: `java_library {
|
||||||
|
name: "java-lib-1",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
libs: ["java-lib-2"],
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
libs: ["java-lib-3"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library{
|
||||||
|
name: "java-lib-2",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library{
|
||||||
|
name: "java-lib-3",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||||
|
"srcs": `["a.java"]`,
|
||||||
|
"deps": `[":java-lib-2-neverlink"] + select({
|
||||||
|
"//build/bazel/platforms/os:android": [":java-lib-3-neverlink"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
})`,
|
||||||
|
}),
|
||||||
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||||
|
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{}),
|
||||||
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
|
||||||
|
MakeBazelTarget("java_library", "java-lib-3", AttrNameToString{}),
|
||||||
|
MakeNeverlinkDuplicateTarget("java_library", "java-lib-3"),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
20
java/java.go
20
java/java.go
@@ -2568,7 +2568,7 @@ type bp2BuildJavaInfo struct {
|
|||||||
// to be returned to the calling function.
|
// to be returned to the calling function.
|
||||||
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) (*javaCommonAttributes, *bp2BuildJavaInfo) {
|
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) (*javaCommonAttributes, *bp2BuildJavaInfo) {
|
||||||
var srcs bazel.LabelListAttribute
|
var srcs bazel.LabelListAttribute
|
||||||
var deps bazel.LabelList
|
var deps bazel.LabelListAttribute
|
||||||
var staticDeps bazel.LabelList
|
var staticDeps bazel.LabelList
|
||||||
|
|
||||||
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
||||||
@@ -2674,11 +2674,17 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
Javacopts: bazel.MakeStringListAttribute(javacopts),
|
Javacopts: bazel.MakeStringListAttribute(javacopts),
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.properties.Libs != nil {
|
for axis, configToProps := range archVariantProps {
|
||||||
for _, d := range m.properties.Libs {
|
for config, _props := range configToProps {
|
||||||
neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
|
if archProps, ok := _props.(*CommonProperties); ok {
|
||||||
neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
|
var libLabels []bazel.Label
|
||||||
deps.Add(&neverlinkLabel)
|
for _, d := range archProps.Libs {
|
||||||
|
neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
|
||||||
|
neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
|
||||||
|
libLabels = append(libLabels, neverlinkLabel)
|
||||||
|
}
|
||||||
|
deps.SetSelectValue(axis, config, bazel.MakeLabelList(libLabels))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2696,7 +2702,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||||||
staticDeps.Add(protoDepLabel)
|
staticDeps.Add(protoDepLabel)
|
||||||
|
|
||||||
depLabels := &javaDependencyLabels{}
|
depLabels := &javaDependencyLabels{}
|
||||||
depLabels.Deps = bazel.MakeLabelListAttribute(deps)
|
depLabels.Deps = deps
|
||||||
depLabels.StaticDeps = bazel.MakeLabelListAttribute(staticDeps)
|
depLabels.StaticDeps = bazel.MakeLabelListAttribute(staticDeps)
|
||||||
|
|
||||||
bp2BuildInfo := &bp2BuildJavaInfo{
|
bp2BuildInfo := &bp2BuildJavaInfo{
|
||||||
|
Reference in New Issue
Block a user