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

Commit 1c4048e0 authored by Romain Jobredeaux's avatar Romain Jobredeaux Committed by Gerrit Code Review
Browse files

Merge "Bp2build support for JNI deps of android_app." into main

parents 9483e487 947dfa76
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -854,6 +854,10 @@ var (

		"libstagefright_headers",

		// Apps with JNI libs
		"SimpleJNI",
		"libsimplejni",

		// aidl
		"aidl",
		"libaidl-common",
+13 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package bp2build

import (
	"android/soong/android"
	"android/soong/cc"
	"android/soong/java"

	"testing"
@@ -29,6 +30,7 @@ func runAndroidAppTestCase(t *testing.T, tc Bp2buildTestCase) {
func registerAndroidAppModuleTypes(ctx android.RegistrationContext) {
	ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	ctx.RegisterModuleType("java_library", java.LibraryFactory)
	ctx.RegisterModuleType("cc_library_shared", cc.LibrarySharedFactory)
}

func TestMinimalAndroidApp(t *testing.T) {
@@ -78,8 +80,9 @@ func TestAndroidAppAllSupportedFields(t *testing.T) {
			"manifest/AndroidManifest.xml": "",
			"assets_/asset.png":            "",
		},
		StubbedBuildDefinitions: []string{"static_lib_dep"},
		Blueprint: simpleModule("android_app", "static_lib_dep") + `
		StubbedBuildDefinitions: []string{"static_lib_dep", "jni_lib"},
		Blueprint: simpleModule("android_app", "static_lib_dep") +
			simpleModule("cc_library_shared", "jni_lib") + `
android_app {
	name: "TestApp",
	srcs: ["app.java"],
@@ -100,6 +103,7 @@ android_app {
		obfuscate: false,
		ignore_warnings: true,
	},
	jni_libs: ["jni_lib"],
}
`,
		ExpectedBazelTargets: []string{
@@ -113,7 +117,10 @@ android_app {
				"assets":         `["assets_/asset.png"]`,
				"assets_dir":     `"assets_"`,
				"custom_package": `"com.google"`,
				"deps":             `[":static_lib_dep"]`,
				"deps": `[
        ":static_lib_dep",
        ":jni_lib",
    ]`,
				"java_version":     `"7"`,
				"sdk_version":      `"current"`,
				"certificate_name": `"foocert"`,
+14 −0
Original line number Diff line number Diff line
@@ -1732,6 +1732,20 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
	deps := depLabels.Deps
	deps.Append(depLabels.StaticDeps)

	var jniDeps bazel.LabelListAttribute
	archVariantProps := a.GetArchVariantProperties(ctx, &appProperties{})
	for axis, configToProps := range archVariantProps {
		for config, _props := range configToProps {
			if archProps, ok := _props.(*appProperties); ok {
				archJniLibs := android.BazelLabelForModuleDeps(
					ctx,
					android.LastUniqueStrings(android.CopyOf(archProps.Jni_libs)))
				jniDeps.SetSelectValue(axis, config, archJniLibs)
			}
		}
	}
	deps.Append(jniDeps)

	if !bp2BuildInfo.hasKotlin {
		appAttrs.javaCommonAttributes = commonAttrs
		appAttrs.bazelAapt = aapt