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
This commit is contained in:
Neil Dhar 2020-08-21 16:46:21 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 55911eafb8
Коммит be53aae324
1 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -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")