Skip to content

Commit 20c10d6

Browse files
Kudogabrieldonadel
authored andcommitted
Enable hermes debugger on all build variants (#33)
1 parent cca888f commit 20c10d6

File tree

10 files changed

+47
-6
lines changed

10 files changed

+47
-6
lines changed

packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ android {
301301
cmake {
302302
arguments(
303303
"-DCMAKE_BUILD_TYPE=MinSizeRel",
304-
// For release builds, we don't want to enable the Hermes Debugger.
305-
"-DHERMES_ENABLE_DEBUGGER=False")
304+
// For Expo Go, we have to enable debugging even on release builds.
305+
"-DHERMES_ENABLE_DEBUGGER=True")
306306
}
307307
}
308308
}

packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ add_library(hermes_executor
1515
OBJECT
1616
${hermes_executor_SRC}
1717
)
18+
target_compile_options(
19+
hermes_executor
20+
PRIVATE
21+
-DHERMES_ENABLE_DEBUGGER=1
22+
-std=c++20
23+
-fexceptions
24+
)
1825
target_merge_so(hermes_executor)
1926
target_include_directories(hermes_executor PRIVATE .)
2027
target_link_libraries(

packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ add_library(hermesinstancejni
1515
OBJECT
1616
${hermes_instance_jni_SRC}
1717
)
18+
target_compile_options(
19+
hermesinstancejni
20+
PRIVATE
21+
-DHERMES_ENABLE_DEBUGGER=1
22+
-std=c++20
23+
-fexceptions
24+
)
25+
1826
target_include_directories(hermesinstancejni PRIVATE .)
1927
target_merge_so(hermesinstancejni)
2028

packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ add_library(rninstance
1818

1919
target_compile_reactnative_options(rninstance PRIVATE)
2020
if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
21-
target_compile_options(rninstance PRIVATE -DHERMES_ENABLE_DEBUGGER=1)
21+
target_compile_options(
22+
rninstance
23+
PRIVATE
24+
-DHERMES_ENABLE_DEBUGGER=1
25+
-std=c++20
26+
-fexceptions
27+
)
2228
endif ()
2329

2430
target_merge_so(rninstance)

packages/react-native/ReactCommon/hermes/executor/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ else()
3737
hermes_executor_common
3838
PRIVATE
3939
-DNDEBUG
40+
-DHERMES_ENABLE_DEBUGGER=1
4041
)
4142
endif()

packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
2323
PRIVATE
2424
-DHERMES_ENABLE_DEBUGGER=1
2525
)
26+
else()
27+
# Expo Go requires debugging on release builds
28+
target_compile_options(
29+
hermes_inspector_modern
30+
PRIVATE
31+
# Expo Go requires debugging on release builds
32+
-DHERMES_ENABLE_DEBUGGER=1
33+
)
2634
endif()
2735

2836
target_include_directories(hermes_inspector_modern PUBLIC ${REACT_COMMON_DIR})

packages/react-native/ReactCommon/react/runtime/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ add_library(bridgeless
1717
)
1818
target_compile_reactnative_options(bridgeless PRIVATE)
1919
if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED)
20-
target_compile_options(bridgeless PRIVATE -DHERMES_ENABLE_DEBUGGER=1)
20+
target_compile_options(
21+
bridgeless
22+
PRIVATE
23+
-DHERMES_ENABLE_DEBUGGER=1
24+
-std=c++20
25+
-fexceptions
26+
)
2127
endif ()
2228
target_include_directories(bridgeless PUBLIC .)
2329

packages/react-native/sdks/hermes-engine/hermes-engine.podspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ end
2222
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
2323
version = package['version']
2424

25+
# Force building Hermes from source because Expo Go requires customized Hermes build
26+
ENV['RCT_BUILD_HERMES_FROM_SOURCE'] = 'true'
27+
2528
source_type = hermes_source_type(version, react_native_path)
2629
source = podspec_source(source_type, version, react_native_path)
2730

packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ function configure_apple_framework {
7272
if [[ $BUILD_TYPE == "Debug" ]]; then
7373
enable_debugger="true"
7474
else
75-
enable_debugger="false"
75+
# Expo Go requires debugging on release build
76+
enable_debugger="true"
7677
fi
7778
if [[ $BUILD_TYPE == "Debug" ]]; then
7879
# JS developers aren't VM developers.

packages/react-native/sdks/hermes-engine/utils/build-hermes-xcode.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ function get_deployment_target {
3636
echo "${IPHONEOS_DEPLOYMENT_TARGET}"
3737
}
3838

39-
enable_debugger="false"
39+
# Expo Go requires debugging on release build
40+
enable_debugger="true"
4041
if [[ "$CONFIGURATION" = *Debug* ]]; then
4142
enable_debugger="true"
4243
fi

0 commit comments

Comments
 (0)