diff options
| author | 2024-10-07 17:37:48 +0000 | |
|---|---|---|
| committer | 2024-10-07 17:37:48 +0000 | |
| commit | f331fd79effcb1b6fa4b02b3aef42e9c78310cc6 (patch) | |
| tree | d889e2e257a9c6bf18762c2c64ac7244db21e252 /java/java.go | |
| parent | 10903c73f6f508dbbe5da867958c69f17ac3a262 (diff) | |
| parent | e42c5d96f90f64ba9b2d85b2e8e099c1f8ea3f8e (diff) | |
Merge "Add JNI libs support to device variants of java_binary" into main
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/java/java.go b/java/java.go index 661422b54..018850fef 100644 --- a/java/java.go +++ b/java/java.go @@ -1795,8 +1795,7 @@ type binaryProperties struct { // Name of the class containing main to be inserted into the manifest as Main-Class. Main_class *string - // Names of modules containing JNI libraries that should be installed alongside the host - // variant of the binary. + // Names of modules containing JNI libraries that should be installed alongside the binary. Jni_libs []string `android:"arch_variant"` } @@ -1809,6 +1808,8 @@ type Binary struct { wrapperFile android.Path binaryFile android.InstallPath + + androidMkNamesOfJniLibs []string } func (j *Binary) HostToolPath() android.OptionalPath { @@ -1880,6 +1881,21 @@ func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.ModuleName()+ext, j.wrapperFile) setOutputFiles(ctx, j.Library.Module) + + // Set the jniLibs of this binary. + // These will be added to `LOCAL_REQUIRED_MODULES`, and the kati packaging system will + // install these alongside the java binary. + ctx.VisitDirectDepsWithTag(jniInstallTag, func(jni android.Module) { + // Use the BaseModuleName of the dependency (without any prebuilt_ prefix) + bmn, _ := jni.(interface{ BaseModuleName() string }) + j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, bmn.BaseModuleName()+":"+jni.Target().Arch.ArchType.Bitness()) + }) + // Check that native libraries are not listed in `required`. Prompt users to use `jni_libs` instead. + ctx.VisitDirectDepsWithTag(android.RequiredDepTag, func(dep android.Module) { + if _, hasSharedLibraryInfo := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider); hasSharedLibraryInfo { + ctx.ModuleErrorf("cc_library %s is no longer supported in `required` of java_binary modules. Please use jni_libs instead.", dep.Name()) + } + }) } } @@ -1888,11 +1904,9 @@ func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) { j.deps(ctx) } // These dependencies ensure the installation rules will install the jar file when the - // wrapper is installed, and the jni libraries on host when the wrapper is installed. - if ctx.Arch().ArchType != android.Common && ctx.Os().Class == android.Host { - ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...) - } + // wrapper is installed, and the jni libraries when the wrapper is installed. if ctx.Arch().ArchType != android.Common { + ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...) ctx.AddVariationDependencies( []blueprint.Variation{{Mutator: "arch", Variation: android.CommonArch.String()}}, binaryInstallTag, ctx.ModuleName()) |