From be53aae324546ca038e2b58184ecc7066cfb598e Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Fri, 21 Aug 2020 16:46:21 -0700 Subject: [PATCH] Fix task ordering for including Hermes Summary: Fix a failure in running a single command to clean and rebuild with Hermes (e.g. `./gradlew clean :RNTester:android:app:installHermesDebug`). From my limited understanding of Gradle, the failure was caused by the fact that the `clean` task could end up running after `prepareHermes`, and therefore delete the shared library after it had been copied. This change updates the `prepareHermes` task to impose the proper order. In investigating this failure, I also updated inconsistent use of the `$thirdPartyNdkDir` variable. Changelog: [Internal][Fixed] Fix a failure in running a single command to clean and rebuild ReactAndroid with Hermes Reviewed By: mdvacca Differential Revision: D23098220 fbshipit-source-id: 822fa8ac9874d54a3fdd432ad8cbee78295228ee --- ReactAndroid/build.gradle | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 94b58475bdf..1189ead6e9a 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -101,7 +101,7 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy into("$thirdPartyNdkDir/folly") } -task prepareHermes() { +task prepareHermes(dependsOn: createNativeDepsDirectories, type: Copy) { def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine") if (!hermesPackagePath) { throw new GradleScriptException("Could not find the hermes-engine npm package", null) @@ -114,11 +114,9 @@ task prepareHermes() { def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" }) - copy { - from soFiles - from "src/main/jni/first-party/hermes/Android.mk" - into "$thirdPartyNdkDir/hermes" - } + from soFiles + from "src/main/jni/first-party/hermes/Android.mk" + into "$thirdPartyNdkDir/hermes" } task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) { @@ -314,7 +312,7 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) { "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", "NDK_OUT=" + temporaryDir, "NDK_LIBS_OUT=$buildDir/react-ndk/all", - "THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk", + "THIRD_PARTY_NDK_DIR=$thirdPartyNdkDir", "REACT_COMMON_DIR=$projectDir/../ReactCommon", "REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react", "BUILD_FABRIC=$enableFabric", @@ -328,7 +326,7 @@ def cleanReactNdkLib = tasks.register("cleanReactNdkLib", Exec) { errorOutput(new ByteArrayOutputStream()) commandLine(getNdkBuildFullPath(), "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", - "THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk", + "THIRD_PARTY_NDK_DIR=$thirdPartyNdkDir", "REACT_COMMON_DIR=$projectDir/../ReactCommon", "-C", file("src/main/jni/react/jni").absolutePath, "clean")