Explicitly enable debugger when building Hermes for Fantom (#55202)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55202

Changelog: [Internal]

After changing Hermes V1 to be the default engine, Fantom tests started failing. This was due to a combination of changes, one of them being the change of default value for `HERMES_ENABLE_DEBUGGER`. In case of legacy Hermes it was enabled by default, while for Hermes V1 it's disabled by default.

Fantom didn't explicitly set this flag, but the debug build of RN (which Fantom performs) requires it to be enabled. This diff explicitly sets this flag to true for Fantom builds.

Reviewed By: cipolleschi, cortinico

Differential Revision: D90849881

fbshipit-source-id: 17f8393872eacef26f927f50aaf364644d9b94d7
This commit is contained in:
Jakub Piasecki authored and meta-codesync[bot] committed 2026-01-16 06:42:34 -08:00
1 parent 58f9141aec
commit 1c63877fec
2 files changed
+103 -27

No files matched your search

@@ -149,28 +149,55 @@ val installCMake by
)
}
fun configureBuildForHermesCommandLineArgs(
hermesBuildDir: File,
jsiDir: File,
enableDebugger: Boolean,
): List<String> {
var cmakeCommandLine =
windowsAwareCommandLine(
cmakeBinaryPath,
// Suppress all warnings as this is the Hermes build and we can't fix them.
"--log-level=ERROR",
"-Wno-dev",
"-S",
".",
"-B",
hermesBuildDir.toString(),
"-DJSI_DIR=" + jsiDir.absolutePath,
"-DCMAKE_BUILD_TYPE=Release",
)
if (enableDebugger) {
cmakeCommandLine = cmakeCommandLine + "-DHERMES_ENABLE_DEBUGGER=True"
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
cmakeCommandLine = cmakeCommandLine + "-GNMake Makefiles"
}
if (hermesV1Enabled) {
cmakeCommandLine = cmakeCommandLine + "-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32"
}
return cmakeCommandLine
}
fun buildHermesCCommandLineArgs() =
listOf(
cmakeBinaryPath,
"--build",
hermesBuildDir.toString(),
"--target",
"hermesc",
"-j",
ndkBuildJobs,
)
val configureBuildForHermes by
tasks.registering(CustomExecTask::class) {
dependsOn(installCMake)
workingDir(hermesDir)
inputs.dir(hermesDir)
outputs.files(hermesBuildOutputFileTree)
var cmakeCommandLine =
windowsAwareCommandLine(
cmakeBinaryPath,
// Suppress all warnings as this is the Hermes build and we can't fix them.
"--log-level=ERROR",
"-Wno-dev",
"-S",
".",
"-B",
hermesBuildDir.toString(),
"-DJSI_DIR=" + jsiDir.absolutePath,
"-DCMAKE_BUILD_TYPE=Release",
)
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
cmakeCommandLine = cmakeCommandLine + "-GNMake Makefiles"
}
val cmakeCommandLine = configureBuildForHermesCommandLineArgs(hermesBuildDir, jsiDir, false)
commandLine(cmakeCommandLine)
standardOutputFile.set(project.file("$buildDir/configure-hermesc.log"))
}
@@ -181,15 +208,8 @@ val buildHermesC by
workingDir(hermesDir)
inputs.files(hermesBuildOutputFileTree)
outputs.file(hermesCOutputBinary)
commandLine(
cmakeBinaryPath,
"--build",
hermesBuildDir.toString(),
"--target",
"hermesc",
"-j",
ndkBuildJobs,
)
val cmakeCommandLine = buildHermesCCommandLineArgs()
commandLine(cmakeCommandLine)
standardOutputFile.set(project.file("$buildDir/build-hermesc.log"))
errorOutputFile.set(project.file("$buildDir/build-hermesc.error.log"))
}
@@ -222,6 +242,60 @@ val buildHermesLib by
errorOutputFile.set(project.file("$buildDir/build-hermes-lib.error.log"))
}
// The repeated tasks below named "*WithDebugger" are required by Fantom.
// Hermes V1 by default builds with the debugger disabled, while Fantom needs
// it to be enabled as it does a debug build of React Native.
val configureBuildForHermesWithDebugger by
tasks.registering(CustomExecTask::class) {
dependsOn(installCMake)
workingDir(hermesDir)
inputs.dir(hermesDir)
outputs.files(hermesBuildOutputFileTree)
val cmakeCommandLine = configureBuildForHermesCommandLineArgs(hermesBuildDir, jsiDir, true)
commandLine(cmakeCommandLine)
standardOutputFile.set(project.file("$buildDir/configure-hermesc.log"))
}
val buildHermesCWithDebugger by
tasks.registering(CustomExecTask::class) {
dependsOn(configureBuildForHermesWithDebugger)
workingDir(hermesDir)
inputs.files(hermesBuildOutputFileTree)
outputs.file(hermesCOutputBinary)
val cmakeCommandLine = buildHermesCCommandLineArgs()
commandLine(cmakeCommandLine)
standardOutputFile.set(project.file("$buildDir/build-hermesc.log"))
errorOutputFile.set(project.file("$buildDir/build-hermesc.error.log"))
}
val prepareHeadersForPrefabWithDebugger by
tasks.registering(Copy::class) {
dependsOn(buildHermesCWithDebugger)
from("$hermesDir/API")
from("$hermesDir/public")
include("**/*.h")
exclude("jsi/**")
into(prefabHeadersDir)
}
val buildHermesLibWithDebugger by
tasks.registering(CustomExecTask::class) {
dependsOn(buildHermesCWithDebugger)
workingDir(hermesDir)
inputs.files(hermesBuildOutputFileTree)
commandLine(
cmakeBinaryPath,
"--build",
hermesBuildDir.toString(),
"--target",
"hermesvm",
"-j",
ndkBuildJobs,
)
standardOutputFile.set(project.file("$buildDir/build-hermes-lib.log"))
errorOutputFile.set(project.file("$buildDir/build-hermes-lib.error.log"))
}
fun windowsAwareCommandLine(vararg commands: String): List<String> {
val result =
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
@@ -370,6 +444,8 @@ afterEvaluate {
// download/unzip Hermes from Github then.
tasks.getByName("configureBuildForHermes").dependsOn(unzipHermes)
tasks.getByName("prepareHeadersForPrefab").dependsOn(unzipHermes)
tasks.getByName("configureBuildForHermesWithDebugger").dependsOn(unzipHermes)
tasks.getByName("prepareHeadersForPrefabWithDebugger").dependsOn(unzipHermes)
}
tasks.getByName("preBuild").dependsOn(buildHermesC)
tasks.getByName("preBuild").dependsOn(prepareHeadersForPrefab)
+2 -2
View File
@@ -159,8 +159,8 @@ val prepareHermesDependencies by
tasks.registering {
dependsOn(
enableHermesBuild,
":packages:react-native:ReactAndroid:hermes-engine:buildHermesLib",
":packages:react-native:ReactAndroid:hermes-engine:prepareHeadersForPrefab",
":packages:react-native:ReactAndroid:hermes-engine:buildHermesLibWithDebugger",
":packages:react-native:ReactAndroid:hermes-engine:prepareHeadersForPrefabWithDebugger",
)
}