diff options
| author | 2021-04-19 21:31:08 +0000 | |
|---|---|---|
| committer | 2021-04-19 21:31:08 +0000 | |
| commit | 91fc8cbc73c0d59d8a82dcdb1d8cb566f47bc112 (patch) | |
| tree | 136f8174c12295c9aa67eea771ea0957c9e0732a /java/java.go | |
| parent | 62b9c5bd99c8d92ad72e4449bbb25c299c59617a (diff) | |
| parent | f8d9c499d49469a2df88bb34ba84632c90468c27 (diff) | |
Merge "Reland: Add jni_libs property to java tests"
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index ee4f2eb0b..adb0c5644 100644 --- a/java/java.go +++ b/java/java.go @@ -27,6 +27,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/cc" "android/soong/dexpreopt" "android/soong/java/config" "android/soong/tradefed" @@ -708,6 +709,9 @@ type testProperties struct { // Test options. Test_options TestOptions + + // Names of modules containing JNI libraries that should be installed alongside the test. + Jni_libs []string } type hostTestProperties struct { @@ -769,6 +773,13 @@ func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { } } + if len(j.testProperties.Jni_libs) > 0 { + for _, target := range ctx.MultiTargets() { + sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) + ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...) + } + } + j.deps(ctx) } @@ -793,6 +804,29 @@ func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.data = append(j.data, android.OutputFileForModule(ctx, dep, "")) }) + ctx.VisitDirectDepsWithTag(jniLibTag, func(dep android.Module) { + sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo) + if sharedLibInfo.SharedLibrary != nil { + // Copy to an intermediate output directory to append "lib[64]" to the path, + // so that it's compatible with the default rpath values. + var relPath string + if sharedLibInfo.Target.Arch.ArchType.Multilib == "lib64" { + relPath = filepath.Join("lib64", sharedLibInfo.SharedLibrary.Base()) + } else { + relPath = filepath.Join("lib", sharedLibInfo.SharedLibrary.Base()) + } + relocatedLib := android.PathForModuleOut(ctx, "relocated").Join(ctx, relPath) + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cp, + Input: sharedLibInfo.SharedLibrary, + Output: relocatedLib, + }) + j.data = append(j.data, relocatedLib) + } else { + ctx.PropertyErrorf("jni_libs", "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep)) + } + }) + j.Library.GenerateAndroidBuildActions(ctx) } |