Skip to content

Commit a92e53e

Browse files
andrewdacenkofacebook-github-bot
authored andcommitted
HermesInstance::createJSRuntime integration
Summary: Changelog: [Internal] JSRuntime integration with executor on messagequeue. Inching closer to full integration with the rest of RN. Differential Revision: D76752667
1 parent 6bfc118 commit a92e53e

16 files changed

Lines changed: 423 additions & 52 deletions

File tree

packages/react-native/ReactAndroid/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ set(CMAKE_VERBOSE_MAKEFILE on)
1414
# This function will take care of forcefully including the jni_lib_merge.h header that takes
1515
# care of redefining the JNI_OnLoad function to JNI_OnLoad_Weak.
1616
function(target_merge_so target_name)
17+
if(NOT ANDROID)
18+
return()
19+
endif()
20+
1721
target_compile_options(${target_name}
1822
PRIVATE
1923
-DORIGINAL_SONAME=\"lib${target_name}.so\"

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ add_library(react_debug OBJECT ${react_debug_SRC})
1313

1414
target_include_directories(react_debug PUBLIC ${REACT_COMMON_DIR})
1515

16-
target_link_libraries(react_debug log folly_runtime)
16+
target_link_libraries(react_debug folly_runtime)
17+
18+
if(ANDROID)
19+
target_link_libraries(react_debug log)
20+
endif()
1721

1822
target_compile_reactnative_options(react_debug PRIVATE)
1923
target_compile_options(react_debug PRIVATE -Wpedantic)

private/react-native-fantom/build.gradle.kts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ val downloadsDir =
2525
File("$buildDir/downloads")
2626
}
2727
val thirdParty = File("$buildDir/third-party")
28-
val reactNativeRootDir = projectDir.parent
28+
val reactNativeRootDir = projectDir.parentFile.parentFile
29+
val reactAndroidBuildDir = File("$reactNativeRootDir/packages/react-native/ReactAndroid/build")
2930

3031
val createNativeDepsDirectories by
3132
tasks.registering {
@@ -54,12 +55,36 @@ val prepareGflags by
5455
outputDir.set(File(thirdParty, "gflags"))
5556
}
5657

57-
// Tasks used by Fantom to download the Native 3p dependencies used.
58-
val prepareNative3pDependencies by
58+
var codegenSrcDir = File("$reactAndroidBuildDir/generated/source/codegen/jni/react")
59+
var codegenOutDir = File("$buildDir/codegen/react")
60+
val prepareRNCodegen by
61+
tasks.registering(Copy::class) {
62+
dependsOn(":packages:react-native:ReactAndroid:generateCodegenArtifactsFromSchema")
63+
from(codegenSrcDir)
64+
from("tester/codegen/react")
65+
include(
66+
"**/FBReactNativeSpecJSI.h", "**/FBReactNativeSpecJSI-generated.cpp", "CMakeLists.txt")
67+
includeEmptyDirs = false
68+
into(codegenOutDir)
69+
}
70+
71+
val prepareHermesDependencies by
5972
tasks.registering {
6073
dependsOn(
61-
prepareGflags,
6274
":packages:react-native:ReactAndroid:hermes-engine:buildHermesLib",
6375
":packages:react-native:ReactAndroid:hermes-engine:prepareHeadersForPrefab",
6476
)
6577
}
78+
79+
val prepareNative3pDependencies by
80+
tasks.registering {
81+
dependsOn(
82+
prepareGflags,
83+
":packages:react-native:ReactAndroid:prepareNative3pDependencies",
84+
)
85+
}
86+
87+
val prepareAllDependencies by
88+
tasks.registering {
89+
dependsOn(prepareRNCodegen, prepareHermesDependencies, prepareNative3pDependencies)
90+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
set -e
88

99
pushd ../..
10-
./gradlew :packages:react-native:ReactAndroid:prepareNative3pDependencies
11-
./gradlew :private:react-native-fantom:prepareNative3pDependencies
10+
./gradlew :private:react-native-fantom:prepareAllDependencies
1211
popd

private/react-native-fantom/tester/CMakeLists.txt

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,111 @@ cmake_minimum_required(VERSION 3.13)
77
set(CMAKE_VERBOSE_MAKEFILE on)
88

99
project(fantom_tester)
10-
1110
find_library(LIB_HERMES libhermes
1211
HINTS ${REACT_ANDROID_DIR}/hermes-engine/build/hermes/API/hermes
1312
REQUIRED)
13+
# Ensure the library path is correct and the library exists
14+
if(NOT LIB_HERMES)
15+
message(FATAL_ERROR "libhermes not found at the specified path.")
16+
endif()
17+
# Check if the found library is a framework (macOS specific)
18+
get_filename_component(LIB_EXT ${LIB_HERMES} EXT)
19+
if(LIB_EXT STREQUAL ".framework")
20+
# For frameworks, we need to use a different approach
21+
add_library(hermes-engine::libhermes INTERFACE IMPORTED)
22+
set_target_properties(hermes-engine::libhermes PROPERTIES
23+
INTERFACE_LINK_LIBRARIES ${LIB_HERMES})
24+
else()
25+
# For regular libraries, use ALIAS as before
26+
add_library(hermes-engine::libhermes ALIAS ${LIB_HERMES})
27+
endif()
28+
1429
include_directories(${REACT_ANDROID_DIR}/hermes-engine/build/prefab-headers)
1530

1631
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
1732

18-
# Convert input paths to CMake format (with forward slashes)
19-
file(TO_CMAKE_PATH "${REACT_THIRD_PARTY_NDK_DIR}" REACT_THIRD_PARTY_NDK_DIR)
20-
file(TO_CMAKE_PATH "${REACT_COMMON_DIR}" REACT_COMMON_DIR)
21-
22-
function(add_react_third_party_ndk_subdir relative_path)
23-
add_subdirectory(${REACT_THIRD_PARTY_NDK_DIR}/${relative_path} ${relative_path})
24-
endfunction()
33+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
2534

26-
function(add_third_party_subdir relative_path)
27-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/${relative_path} ${relative_path})
28-
endfunction()
35+
include(Deps)
2936

30-
function(add_react_common_subdir relative_path)
31-
add_subdirectory(${REACT_COMMON_DIR}/${relative_path} ReactCommon/${relative_path})
32-
endfunction()
33-
34-
function(add_fantom_third_party_subdir relative_path)
35-
add_subdirectory(${FANTOM_THIRD_PARTY_DIR}/${relative_path} ${relative_path})
36-
endfunction()
37+
# Boost in NDK is not compatible with desktop build
38+
add_third_party_subdir(boost)
3739

3840
# Third-party downloaded targets
3941
add_react_third_party_ndk_subdir(glog)
40-
# Boost in NDK is not compatible with desktop build
41-
add_third_party_subdir(boost)
4242
add_react_third_party_ndk_subdir(double-conversion)
4343
add_react_third_party_ndk_subdir(fast_float)
4444
add_react_third_party_ndk_subdir(fmt)
4545
add_react_third_party_ndk_subdir(folly)
4646
add_fantom_third_party_subdir(gflags)
4747

48-
# Common targets
49-
add_react_common_subdir(yoga)
48+
add_fantom_codegen_subdir(react)
49+
50+
#add_react_common_subdir(hermes/executor)
51+
#add_react_common_subdir(hermes/inspector-modern)
52+
#add_react_common_subdir(react/runtime/hermes)
53+
add_react_common_subdir(callinvoker)
54+
add_react_common_subdir(cxxreact)
5055
add_react_common_subdir(jsi)
56+
add_react_common_subdir(jsiexecutor)
57+
add_react_common_subdir(jsinspector-modern)
58+
add_react_common_subdir(jsinspector-modern/cdp)
59+
add_react_common_subdir(jsinspector-modern/network)
60+
add_react_common_subdir(jsinspector-modern/tracing)
61+
add_react_common_subdir(jsitooling)
62+
add_react_common_subdir(logger)
63+
add_react_common_subdir(oscompat)
64+
add_react_common_subdir(react/bridging)
65+
add_react_common_subdir(react/debug)
5166
add_react_common_subdir(react/featureflags)
67+
add_react_common_subdir(react/performance/timeline)
68+
add_react_common_subdir(react/timing)
69+
add_react_common_subdir(reactperflogger)
70+
add_react_common_subdir(runtimeexecutor)
71+
add_react_common_subdir(yoga)
72+
73+
add_fantom_react_common_subdir(react/nativemodule/core)
74+
add_fantom_react_common_subdir(react/utils)
75+
add_fantom_react_common_subdir(react/runtime/hermes)
76+
add_fantom_react_common_subdir(hermes/inspector-modern)
77+
add_fantom_react_common_subdir(hermes/executor)
5278

5379
file(GLOB SOURCES "src/*.cpp" "src/*.h")
5480
add_executable(fantom_tester ${SOURCES})
5581

5682
target_link_libraries(fantom_tester
5783
PRIVATE
58-
glog
59-
gflags
60-
jsi
6184
${LIB_HERMES}
6285
boost
63-
double-conversion
64-
fast_float
86+
bridgelesshermes
87+
callinvoker
6588
folly_runtime
89+
gflags
90+
glog
91+
hermes_executor_common
92+
hermes_inspector_modern
93+
jsi
94+
jsinspector
95+
jsinspector_cdp
96+
jsinspector_network
97+
jsinspector_tracing
98+
jsireact
99+
jsitooling
100+
logger
101+
oscompat
102+
react_bridging
103+
react_codegen_rncore
104+
react_cxxreact
105+
react_debug
66106
react_featureflags
67-
yogacore)
107+
react_nativemodule_core
108+
react_performance_timeline
109+
react_timing
110+
react_utils
111+
reactperflogger
112+
runtimeexecutor
113+
yogacore
114+
)
68115

69116
target_compile_options(fantom_tester
70117
PRIVATE
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
10+
11+
file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS ${hermes_executor_DIR}/*.cpp)
12+
add_library(
13+
hermes_executor_common
14+
OBJECT
15+
${hermes_executor_SRC}
16+
)
17+
target_include_directories(hermes_executor_common PUBLIC ${hermes_executor_DIR}/.)
18+
target_link_libraries(hermes_executor_common
19+
hermes-engine::libhermes
20+
hermes_inspector_modern
21+
jsi
22+
jsireact
23+
)
24+
25+
target_compile_reactnative_options(hermes_executor_common PRIVATE)
26+
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
27+
target_compile_options(
28+
hermes_executor_common
29+
PRIVATE
30+
-DHERMES_ENABLE_DEBUGGER=1
31+
)
32+
else()
33+
target_compile_options(
34+
hermes_executor_common
35+
PRIVATE
36+
-DNDEBUG
37+
)
38+
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
10+
11+
file(GLOB hermes_inspector_modern_SRC CONFIGURE_DEPENDS ${hermes_inspector_modern_DIR}/chrome/*.cpp)
12+
13+
add_library(hermes_inspector_modern
14+
OBJECT
15+
${hermes_inspector_modern_SRC})
16+
17+
target_compile_reactnative_options(hermes_inspector_modern PRIVATE)
18+
19+
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
20+
target_compile_options(
21+
hermes_inspector_modern
22+
PRIVATE
23+
-DHERMES_ENABLE_DEBUGGER=1
24+
)
25+
endif()
26+
27+
target_include_directories(hermes_inspector_modern PUBLIC ${REACT_COMMON_DIR})
28+
target_link_libraries(hermes_inspector_modern
29+
hermes-engine::libhermes
30+
jsi
31+
jsinspector)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
10+
file(GLOB react_nativemodule_core_SRC CONFIGURE_DEPENDS
11+
${react_nativemodule_core_DIR}/ReactCommon/*.cpp)
12+
13+
add_library(react_nativemodule_core
14+
OBJECT
15+
${react_nativemodule_core_SRC})
16+
17+
target_include_directories(react_nativemodule_core
18+
PUBLIC
19+
${react_nativemodule_core_DIR}
20+
)
21+
22+
target_link_libraries(react_nativemodule_core
23+
folly_runtime
24+
glog
25+
jsi
26+
callinvoker
27+
react_bridging
28+
react_debug
29+
react_utils
30+
react_featureflags
31+
reactperflogger)
32+
target_compile_reactnative_options(react_nativemodule_core PRIVATE)
33+
target_compile_options(react_nativemodule_core PRIVATE -Wpedantic)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
10+
11+
file(GLOB_RECURSE bridgelesshermes_SRC CONFIGURE_DEPENDS ${react_runtime_hermes_DIR}/*.cpp)
12+
add_library(
13+
bridgelesshermes
14+
OBJECT
15+
${bridgelesshermes_SRC}
16+
)
17+
target_include_directories(bridgelesshermes PUBLIC ${react_runtime_hermes_DIR}/.)
18+
19+
target_link_libraries(bridgelesshermes
20+
hermes-engine::libhermes
21+
hermes_executor_common
22+
hermes_inspector_modern
23+
jsitooling
24+
jsi
25+
jsinspector
26+
)
27+
28+
target_compile_reactnative_options(bridgelesshermes PRIVATE)
29+
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
30+
target_compile_options(
31+
bridgelesshermes
32+
PRIVATE
33+
-DHERMES_ENABLE_DEBUGGER=1
34+
)
35+
endif()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
10+
11+
file(GLOB react_utils_SRC CONFIGURE_DEPENDS ${react_utils_DIR}/*.cpp)
12+
add_library(react_utils OBJECT ${react_utils_SRC})
13+
14+
target_include_directories(react_utils
15+
PUBLIC
16+
${REACT_COMMON_DIR}
17+
)
18+
19+
target_link_libraries(react_utils
20+
glog
21+
jsireact
22+
react_debug)
23+
target_compile_reactnative_options(react_utils PRIVATE)
24+
target_compile_options(react_utils PRIVATE -Wpedantic)

0 commit comments

Comments
 (0)