Loading android/bazel.go +8 −5 Original line number Diff line number Diff line Loading @@ -489,6 +489,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 Loading Loading @@ -558,6 +559,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 Loading bp2build/android_app_conversion_test.go +39 −0 Original line number Diff line number Diff line Loading @@ -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"]`, }), }}) } java/java.go +10 −2 Original line number Diff line number Diff line Loading @@ -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" Loading Loading
android/bazel.go +8 −5 Original line number Diff line number Diff line Loading @@ -489,6 +489,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 Loading Loading @@ -558,6 +559,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 Loading
bp2build/android_app_conversion_test.go +39 −0 Original line number Diff line number Diff line Loading @@ -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"]`, }), }}) }
java/java.go +10 −2 Original line number Diff line number Diff line Loading @@ -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" Loading