Skip to content

Commit a2b5e4c

Browse files
cortinicofacebook-github-bot
authored andcommitted
Fix enableVmCleanup not working for apps with product flavors. (#32422)
Summary: Pull Request resolved: #32422 While working on the NDK AGP Api I realized that the `enableVmCleanup` function, that is supposed to cleanup the extra `.so` files from the final artifacts, is broken for apps with variants. Specifically say for a `liteDebug` app it tries to search for `.so` files inside: ``` intermediates/stripped_native_libs/lite/debug/out/lib ``` while the `.so` files are located inside: ``` intermediates/stripped_native_libs/liteDebug/out/lib ``` I've fixed changing the token of the path from `targetPath` to `variant.name` Changelog: [Android] [Fixed] - Fix enableVmCleanup not working for apps with product flavors Reviewed By: ShikaSD Differential Revision: D31654704 fbshipit-source-id: 4af3478a3079ebcde4bd8e0c62bf4df7b6c75c0f
1 parent 79e72e0 commit a2b5e4c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,23 +165,23 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte
165165
packageTask.configure {
166166
if (config.enableVmCleanup.get()) {
167167
val libDir = "$buildDir/intermediates/transforms/"
168-
val targetVariant = ".*/transforms/[^/]*/$targetPath/.*".toRegex()
168+
val targetVariant = ".*/transforms/[^/]*/${variant.name}/.*".toRegex()
169169
it.doFirst { cleanupVMFiles(libDir, targetVariant, enableHermes, cleanup) }
170170
}
171171
}
172172

173173
stripDebugSymbolsTask?.configure {
174174
if (config.enableVmCleanup.get()) {
175-
val libDir = "$buildDir/intermediates/stripped_native_libs/${targetPath}/out/lib/"
176-
val targetVariant = ".*/stripped_native_libs/$targetPath/out/lib/.*".toRegex()
175+
val libDir = "$buildDir/intermediates/stripped_native_libs/${variant.name}/out/lib/"
176+
val targetVariant = ".*/stripped_native_libs/${variant.name}/out/lib/.*".toRegex()
177177
it.doLast { cleanupVMFiles(libDir, targetVariant, enableHermes, cleanup) }
178178
}
179179
}
180180

181181
mergeNativeLibsTask?.configure {
182182
if (config.enableVmCleanup.get()) {
183-
val libDir = "$buildDir/intermediates/merged_native_libs/${targetPath}/out/lib/"
184-
val targetVariant = ".*/merged_native_libs/$targetPath/out/lib/.*".toRegex()
183+
val libDir = "$buildDir/intermediates/merged_native_libs/${variant.name}/out/lib/"
184+
val targetVariant = ".*/merged_native_libs/${variant.name}/out/lib/.*".toRegex()
185185
it.doLast { cleanupVMFiles(libDir, targetVariant, enableHermes, cleanup) }
186186
}
187187
}

react.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ afterEvaluate {
369369
}
370370
}
371371
}.visit { details ->
372-
def targetVariant1 = ".*/transforms/[^/]*/${targetPath}/.*"
373-
def targetVariant2 = ".*/merged_native_libs/${targetPath}/out/lib/.*"
374-
def targetVariant3 = ".*/stripped_native_libs/${targetPath}/out/lib/.*"
372+
def targetVariant1 = ".*/transforms/[^/]*/${variant.name}/.*"
373+
def targetVariant2 = ".*/merged_native_libs/${variant.name}/out/lib/.*"
374+
def targetVariant3 = ".*/stripped_native_libs/${variant.name}/out/lib/.*"
375375
def path = details.file.getAbsolutePath().replace(File.separatorChar, '/' as char)
376376
if ((path.matches(targetVariant1) || path.matches(targetVariant2) || path.matches(targetVariant3)) && details.file.isFile()) {
377377
details.file.delete()
@@ -386,13 +386,13 @@ afterEvaluate {
386386

387387
def sTask = tasks.findByName("strip${targetName}DebugSymbols")
388388
if (sTask != null) {
389-
def strippedLibDir = "$buildDir/intermediates/stripped_native_libs/${targetPath}/out/lib/"
389+
def strippedLibDir = "$buildDir/intermediates/stripped_native_libs/${variant.name}/out/lib/"
390390
sTask.doLast { vmSelectionAction(strippedLibDir) }
391391
}
392392

393393
def mTask = tasks.findByName("merge${targetName}NativeLibs")
394394
if (mTask != null) {
395-
def mergedLibDir = "$buildDir/intermediates/merged_native_libs/${targetPath}/out/lib/"
395+
def mergedLibDir = "$buildDir/intermediates/merged_native_libs/${variant.name}/out/lib/"
396396
mTask.doLast { vmSelectionAction(mergedLibDir) }
397397
}
398398
}

0 commit comments

Comments
 (0)