Skip to content

Commit

Permalink
Fix Release build of RNTester
Browse files Browse the repository at this point in the history
Summary:
Currently the release build of RNTester is broken
as it's loading the debug native libraries. I had to create
separate tasks for the two variants as we can't benefit
of automatic variant matching between project (as of now till
we use prefabs or find another approach).

Changelog:
[Internal] [Fixed] - Fix Release build of RNTester

Reviewed By: ShikaSD

Differential Revision: D32203637

fbshipit-source-id: 5c260a365626e9b3c66e76166086711236a38264
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 8, 2021
1 parent ec84a56 commit d70555f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
14 changes: 13 additions & 1 deletion ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,26 @@ def ndkBuildJobs() {
return project.findProperty("jobs") ?: Runtime.runtime.availableProcessors()
}

tasks.register("packageReactNdkLibsForBuck", Copy) {
tasks.register("packageReactNdkLibsForBuck") {
dependsOn("packageReactNdkDebugLibsForBuck")
}

tasks.register("packageReactNdkDebugLibsForBuck", Copy) {
dependsOn("mergeDebugNativeLibs")
from("$buildDir/intermediates/merged_native_libs/debug/out/lib/")
exclude("**/libjsc.so")
exclude("**/libhermes.so")
into("src/main/jni/prebuilt/lib")
}

tasks.register("packageReactNdkReleaseLibsForBuck", Copy) {
dependsOn("mergeReleaseNativeLibs")
from("$buildDir/intermediates/merged_native_libs/release/out/lib/")
exclude("**/libjsc.so")
exclude("**/libhermes.so")
into("src/main/jni/prebuilt/lib")
}

final def extractNativeDependencies = tasks.register('extractNativeDependencies', ExtractJniAndHeadersTask) {
it.extractHeadersConfiguration.setFrom(configurations.extractHeaders)
it.extractJniConfiguration.setFrom(configurations.extractJNI)
Expand Down
16 changes: 13 additions & 3 deletions packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,16 @@ if (enableCodegen) {
}
}

def packageReactNdkLibs = tasks.register("packageReactNdkLibs", Copy) {
def packageReactDebugNdkLibs = tasks.register("packageReactDebugNdkLibs", Copy) {
// TODO: handle extracting .so from prebuilt :ReactAndroid.
dependsOn(":ReactAndroid:packageReactNdkLibsForBuck")
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
dependsOn("generateCodegenSchemaFromJavaScript")
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
into("$buildDir/react-ndk/exported")
}
def packageReactReleaseNdkLibs = tasks.register("packageReactReleaseNdkLibs", Copy) {
// TODO: handle extracting .so from prebuilt :ReactAndroid.
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
dependsOn("generateCodegenSchemaFromJavaScript")
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
into("$buildDir/react-ndk/exported")
Expand All @@ -308,7 +315,10 @@ if (enableCodegen) {
}

afterEvaluate {
preBuild.dependsOn(packageReactNdkLibs)
preHermesReleaseBuild.dependsOn(packageReactReleaseNdkLibs)
preJscReleaseBuild.dependsOn(packageReactReleaseNdkLibs)
preHermesDebugBuild.dependsOn(packageReactDebugNdkLibs)
preJscDebugBuild.dependsOn(packageReactDebugNdkLibs)
clean.dependsOn(cleanProjectNdkBuild)
}
}

0 comments on commit d70555f

Please sign in to comment.