Merge "convert java_import jars with arch variants" am: 7a45d37e62 am: 0050ed2760 am: c70a811766

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1995732

Change-Id: I4a7caa5085dffcfad1b7413582ffcbfd0cd77220
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2022-04-04 17:02:11 +00:00 committed by Automerger Merge Worker
commit bb30ef3fd3
3 changed files with 47 additions and 9 deletions

View file

@ -570,12 +570,9 @@ var (
"art-script", // depends on unconverted modules: dalvikvm, dex2oat
"dex2oat-script", // depends on unconverted modules: dex2oat
"prebuilt_car-ui-androidx-core-common", // b/224773339, genrule dependency creates an .aar, not a .jar
"prebuilt_art-module-host-exports_okhttp-norepackage@current", // aosp/1999250, needs Jars (arch variant)
"prebuilt_conscrypt-unbundled", // aosp/1999250, needs Jars (arch variant)
"prebuilt_conscrypt-module-host-exports_conscrypt-unbundled@current", // aosp/1999250, needs Jars (arch variant)
"prebuilt_platform-robolectric-4.4-prebuilt", // aosp/1999250, needs .aar support in Jars
"prebuilt_platform-robolectric-4.5.1-prebuilt", // aosp/1999250, needs .aar support in Jars
"prebuilt_car-ui-androidx-core-common", // b/224773339, genrule dependency creates an .aar, not a .jar
"prebuilt_platform-robolectric-4.4-prebuilt", // aosp/1999250, needs .aar support in Jars
"prebuilt_platform-robolectric-4.5.1-prebuilt", // aosp/1999250, needs .aar support in Jars
}
// Per-module denylist of cc_library modules to only generate the static

View file

@ -29,7 +29,7 @@ func runJavaImportTestCase(t *testing.T, tc bp2buildTestCase) {
func registerJavaImportModuleTypes(ctx android.RegistrationContext) {
}
func TestMinimalJavaImport(t *testing.T) {
func TestJavaImportMinimal(t *testing.T) {
runJavaImportTestCase(t, bp2buildTestCase{
description: "Java import - simple example",
moduleTypeUnderTest: "java_import",
@ -50,3 +50,36 @@ java_import {
}),
}})
}
func TestJavaImportArchVariant(t *testing.T) {
runJavaImportTestCase(t, bp2buildTestCase{
description: "Java import - simple example",
moduleTypeUnderTest: "java_import",
moduleTypeUnderTestFactory: java.ImportFactory,
filesystem: map[string]string{
"import.jar": "",
},
blueprint: `
java_import {
name: "example_import",
target: {
android: {
jars: ["android.jar"],
},
linux_glibc: {
jars: ["linux.jar"],
},
},
bazel_module: { bp2build_available: true },
}
`,
expectedBazelTargets: []string{
makeBazelTarget("java_import", "example_import", attrNameToString{
"jars": `select({
"//build/bazel/platforms/os:android": ["android.jar"],
"//build/bazel/platforms/os:linux": ["linux.jar"],
"//conditions:default": [],
})`,
}),
}})
}

View file

@ -2218,8 +2218,16 @@ type bazelJavaImportAttributes struct {
// java_import bp2Build converter.
func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
//TODO(b/209577426): Support multiple arch variants
jars := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, i.properties.Jars, []string(nil)))
var jars bazel.LabelListAttribute
archVariantProps := i.GetArchVariantProperties(ctx, &ImportProperties{})
for axis, configToProps := range archVariantProps {
for config, _props := range configToProps {
if archProps, ok := _props.(*ImportProperties); ok {
archJars := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Jars, []string(nil))
jars.SetSelectValue(axis, config, archJars)
}
}
}
attrs := &bazelJavaImportAttributes{
Jars: jars,