Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/tidy-moons-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@callstack/react-native-brownfield": patch
---

feat: allow extending the list of .so files kept out of the AAR

Adds a `reactBrownfield.ignoreEmbeddedLibs` option so a project can name additional native libraries that should not be embedded, next to the built-in `IGNORE_EMBEDDED_LIBS` list.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
Expand Down Expand Up @@ -50,6 +51,9 @@ abstract class ProcessAndCopyJniLibsTask : DefaultTask() {
@get:Input
abstract val useStrippedSoFiles: Property<Boolean>

@get:Input
abstract val extraIgnoredLibs: ListProperty<String>

@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty

Expand Down Expand Up @@ -125,7 +129,8 @@ abstract class ProcessAndCopyJniLibsTask : DefaultTask() {

private fun matchesAllowedLib(name: String): Boolean {
val isCodegenLib = name.startsWith("libreact_codegen_") && name.endsWith(".so")
val isIgnoredLib = IGNORE_EMBEDDED_LIBS.any { lib -> name == lib || name.contains(lib) }
val ignoredLibs = IGNORE_EMBEDDED_LIBS + extraIgnoredLibs.getOrElse(emptyList())
val isIgnoredLib = ignoredLibs.any { lib -> name == lib || name.contains(lib) }
return name == "libappmodules.so" || isCodegenLib || !isIgnoredLib
}

Expand Down Expand Up @@ -161,6 +166,7 @@ class JNILibsProcessor(val project: Project) {
val processJniTask =
project.tasks.register("processCustomJniLibsFor$capitalizedVariantName", ProcessAndCopyJniLibsTask::class.java) {
it.useStrippedSoFiles.set(projectExt.useStrippedSoFiles)
it.extraIgnoredLibs.set(projectExt.ignoreEmbeddedLibs)

val jniDirs =
aarLibraries.map { aarLib ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ open class Extension {
* listOf("type", "alpha")
*/
var missingDimensionStrategies = listOf<String>()

/**
* Additional .so file names to keep out of the AAR, on top of
* [com.callstack.react.brownfield.processors.IGNORE_EMBEDDED_LIBS].
*
* Use this for libraries that stay declared as dependencies of the published AAR: the
* host App resolves those from Maven, so embedding them as well leaves two copies of
* the same .so and the host's native library merge fails.
*
* Provide in this format:
* listOf("libdatadog-ndk.so")
*/
var ignoreEmbeddedLibs = listOf<String>()
}