mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Honor the REACT_NATIVE_OVERRIDE_HERMES_DIR variable when searching for hermesc
Summary: When searching for the `hermesc` path, we should also honor the `REACT_NATIVE_OVERRIDE_HERMES_DIR` variable. Changelog: [Internal] [Changed] - Honor the REACT_NATIVE_OVERRIDE_HERMES_DIR variable when searching for `hermesc` Reviewed By: neildhar Differential Revision: D35903601 fbshipit-source-id: 31e1255a558eece8cd84669861328db72e9ed17b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6855f7405c
commit
6563c99c49
+17
-1
@@ -129,7 +129,8 @@ internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String
|
||||
}
|
||||
|
||||
// 2. If the project is building hermes-engine from source, use hermesc from there
|
||||
val builtHermesc = File(projectRoot, HERMESC_BUILT_FROM_SOURCE_PATH)
|
||||
val builtHermesc =
|
||||
getBuiltHermescFile(projectRoot, System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR"))
|
||||
if (builtHermesc.exists()) {
|
||||
return builtHermesc.absolutePath
|
||||
}
|
||||
@@ -151,6 +152,21 @@ internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String
|
||||
"node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc")
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location where Hermesc should be. If nothing is specified, built hermesc is assumed to
|
||||
* be inside [HERMESC_BUILT_FROM_SOURCE_PATH]. Otherwise user can specify an override with
|
||||
* [pathOverride], which is assumed to be an absolute path where Hermes source code is
|
||||
* provided/built.
|
||||
*
|
||||
* @param projectRoot The root of the Project.
|
||||
*/
|
||||
internal fun getBuiltHermescFile(projectRoot: File, pathOverride: String?) =
|
||||
if (!pathOverride.isNullOrBlank()) {
|
||||
File(pathOverride, "build/bin/hermesc")
|
||||
} else {
|
||||
File(projectRoot, HERMESC_BUILT_FROM_SOURCE_PATH)
|
||||
}
|
||||
|
||||
internal fun getHermesOSBin(): String {
|
||||
if (Os.isWindows()) return "win64-bin"
|
||||
if (Os.isMac()) return "osx-bin"
|
||||
|
||||
+14
@@ -231,4 +231,18 @@ class PathUtilsTest {
|
||||
|
||||
assertEquals(expected.toString(), detectOSAwareHermesCommand(tempFolder.root, ""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getBuiltHermescFile_withoutOverride() {
|
||||
assertEquals(
|
||||
File(tempFolder.root, "node_modules/react-native/sdks/hermes/build/bin/hermesc"),
|
||||
getBuiltHermescFile(tempFolder.root, ""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getBuiltHermescFile_withOverride() {
|
||||
assertEquals(
|
||||
File("/home/circleci/hermes/build/bin/hermesc"),
|
||||
getBuiltHermescFile(tempFolder.root, "/home/circleci/hermes"))
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -103,7 +103,10 @@ def getHermesCommand = {
|
||||
}
|
||||
|
||||
// 2. If the project is building hermes-engine from source, use hermesc from there
|
||||
def builtHermesc = new File(reactRoot, "node_modules/react-native/sdks/hermes/build/bin/hermesc")
|
||||
// Also note that user can override the hermes source location with
|
||||
// the `REACT_NATIVE_OVERRIDE_HERMES_DIR` env variable.
|
||||
def hermesOverrideDir = System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR")
|
||||
def builtHermesc = hermesOverrideDir ? new File(hermesOverrideDir, "build/bin/hermesc") : new File(reactRoot, "node_modules/react-native/sdks/hermes/build/bin/hermesc")
|
||||
if (builtHermesc.exists()) {
|
||||
return builtHermesc.getAbsolutePath()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user