Merge "Bp2build support for JNI deps of android_app." into main am: 1c4048e08d

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

Change-Id: Ie3d0fefd42a14038e97cbecb5e93f677dca3cbda
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Romain Jobredeaux 2023-09-21 15:04:52 +00:00 committed by Automerger Merge Worker
commit 4bc34aa84e
3 changed files with 31 additions and 6 deletions

View file

@ -854,6 +854,10 @@ var (
"libstagefright_headers",
// Apps with JNI libs
"SimpleJNI",
"libsimplejni",
// aidl
"aidl",
"libaidl-common",

View file

@ -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{
@ -110,10 +114,13 @@ android_app {
"resa/res.png",
"resb/res.png",
]`,
"assets": `["assets_/asset.png"]`,
"assets_dir": `"assets_"`,
"custom_package": `"com.google"`,
"deps": `[":static_lib_dep"]`,
"assets": `["assets_/asset.png"]`,
"assets_dir": `"assets_"`,
"custom_package": `"com.google"`,
"deps": `[
":static_lib_dep",
":jni_lib",
]`,
"java_version": `"7"`,
"sdk_version": `"current"`,
"certificate_name": `"foocert"`,

View file

@ -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