Merge "bp2build supports arch variant srcs for java_library"
This commit is contained in:
@@ -490,6 +490,7 @@ var (
|
||||
"host-libprotobuf-java-nano", // b/217236083, java_library cannot have deps without srcs
|
||||
"error_prone_core", // b/217236083, java_library cannot have deps without srcs
|
||||
"bouncycastle-host", // b/217236083, java_library cannot have deps without srcs
|
||||
"mockito-robolectric-prebuilt", // b/217236083, java_library cannot have deps without srcs
|
||||
|
||||
"apex_manifest_proto_java", // b/215230097, we don't handle .proto files in java_library srcs attribute
|
||||
|
||||
@@ -559,6 +560,8 @@ var (
|
||||
"dex2oat-script", // depends on unconverted modules: dex2oat
|
||||
|
||||
"error_prone_checkerframework_dataflow_nullaway", // TODO(b/219908977): "Error in fail: deps not allowed without srcs; move to runtime_deps?"
|
||||
|
||||
"libprotobuf-java-nano", // b/220869005, depends on non-public_current SDK
|
||||
}
|
||||
|
||||
// Per-module denylist of cc_library modules to only generate the static
|
||||
|
@@ -94,3 +94,42 @@ android_app {
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
||||
func TestAndroidAppArchVariantSrcs(t *testing.T) {
|
||||
runAndroidAppTestCase(t, bp2buildTestCase{
|
||||
description: "Android app - arch variant srcs",
|
||||
moduleTypeUnderTest: "android_app",
|
||||
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
filesystem: map[string]string{
|
||||
"arm.java": "",
|
||||
"x86.java": "",
|
||||
"res/res.png": "",
|
||||
"AndroidManifest.xml": "",
|
||||
},
|
||||
blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm.java"],
|
||||
},
|
||||
x86: {
|
||||
srcs: ["x86.java"],
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", attrNameToString{
|
||||
"srcs": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["arm.java"],
|
||||
"//build/bazel/platforms/arch:x86": ["x86.java"],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `["res/res.png"]`,
|
||||
"deps": `["//prebuilts/sdk:public_current_android_sdk_java_import"]`,
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
12
java/java.go
12
java/java.go
@@ -2011,8 +2011,16 @@ type javaLibraryAttributes struct {
|
||||
}
|
||||
|
||||
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) *javaLibraryAttributes {
|
||||
//TODO(b/209577426): Support multiple arch variants
|
||||
srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs))
|
||||
var srcs bazel.LabelListAttribute
|
||||
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
||||
for axis, configToProps := range archVariantProps {
|
||||
for config, _props := range configToProps {
|
||||
if archProps, ok := _props.(*CommonProperties); ok {
|
||||
archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Srcs, archProps.Exclude_srcs)
|
||||
srcs.SetSelectValue(axis, config, archSrcs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
javaSrcPartition := "java"
|
||||
protoSrcPartition := "proto"
|
||||
|
Reference in New Issue
Block a user