Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a45d37e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "convert java_import jars with arch variants"

parents 3aae38d4 48983166
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -571,9 +571,6 @@ var (
		"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
	}
+34 −1
Original line number Diff line number Diff line
@@ -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": [],
    })`,
			}),
		}})
}
+10 −2
Original line number Diff line number Diff line
@@ -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,