feat: add jsitooling package (#49348)

Summary:
> [!NOTE]
> This PR is part of JavaScriptCore Extraction to this repository: https://github.com/react-native-community/javascriptcore

This PR adds `jsitooling` package that third party JS engines can use (in that case javascriptcore). It's required because React-Runtime needs to depend on third-party engine on iOS, and the third-party engine needed to depend on React-Runtime to get access to the `JSRuntimeFactory` and Cocoapods doesn't support circular dependencies...

Now third-party engine can depenend on jsitooling package and provide JSRuntimeFactory

## Changelog:

[INTERNAL] [ADDED] - jsitooling package

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

Test Plan: CI Green

Reviewed By: cortinico

Differential Revision: D69535475

Pulled By: cipolleschi

fbshipit-source-id: f8d68b7957b7d69c13246ce3040a08256f2ebcd6
This commit is contained in:
Oskar Kwaśniewski
2025-02-13 08:49:42 -08:00
committed by Facebook GitHub Bot
parent 41dd822762
commit 31a8bb386d
14 changed files with 103 additions and 2 deletions
@@ -88,6 +88,7 @@ Pod::Spec.new do |s|
add_dependency(s, "React-debug")
add_dependency(s, "React-rendererdebug")
add_dependency(s, "React-featureflags")
add_dependency(s, "React-jsitooling", :framework_name => "JSITooling")
depend_on_js_engine(s)
end
@@ -62,6 +62,7 @@ add_react_common_subdir(runtimeexecutor)
add_react_common_subdir(reactperflogger)
add_react_common_subdir(logger)
add_react_common_subdir(jsiexecutor)
add_react_common_subdir(jsitooling)
add_react_common_subdir(cxxreact)
add_react_common_subdir(jsc)
add_react_common_subdir(jsi)
@@ -163,6 +164,7 @@ add_library(reactnative
$<TARGET_OBJECTS:jni_lib_merge_glue>
$<TARGET_OBJECTS:jserrorhandler>
$<TARGET_OBJECTS:jsinspector>
$<TARGET_OBJECTS:jsitooling>
$<TARGET_OBJECTS:jsinspector_tracing>
$<TARGET_OBJECTS:jsireact>
$<TARGET_OBJECTS:logger>
@@ -27,6 +27,7 @@ target_merge_so(hermesinstancejni)
target_link_libraries(hermesinstancejni
hermes-engine::libhermes
jsitooling
fbjni
bridgelesshermes
reactnative
@@ -29,6 +29,7 @@ target_link_libraries(
react_featureflagsjni
turbomodulejsijni
jsi
jsitooling
fbjni
bridgeless
)
@@ -0,0 +1,30 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
add_compile_options(
-fexceptions
-frtti
-std=c++20
-Wall
-Wpedantic
-DLOG_TAG=\"ReactNative\")
file(GLOB jsitooling_SRC CONFIGURE_DEPENDS react/runtime/*.cpp)
add_library(jsitooling OBJECT ${jsitooling_SRC})
target_include_directories(jsitooling
PUBLIC
${REACT_COMMON_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(jsitooling
react_cxxreact
folly_runtime
glog
jsi)
@@ -0,0 +1,62 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
require "json"
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end
folly_config = get_folly_config()
folly_compiler_flags = folly_config[:compiler_flags]
folly_version = folly_config[:version]
boost_config = get_boost_config()
boost_compiler_flags = boost_config[:compiler_flags]
header_search_paths = [
"\"$(PODS_ROOT)/boost\"",
"\"$(PODS_ROOT)/RCT-Folly\"",
"\"$(PODS_ROOT)/DoubleConversion\"",
"\"$(PODS_ROOT)/fast_float/include\"",
"\"$(PODS_ROOT)/fmt/include\""
]
Pod::Spec.new do |s|
s.name = "React-jsitooling"
s.version = version
s.summary = "-" # TODO
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "react/runtime/*.{cpp,h}"
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.header_dir = "react/runtime"
if ENV['USE_FRAMEWORKS']
s.module_name = "JSITooling"
s.header_mappings_dir = "./"
end
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => header_search_paths.join(" "),
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
s.dependency "React-cxxreact", version
s.dependency "React-jsi", version
s.dependency "RCT-Folly", folly_version
s.dependency "DoubleConversion"
s.dependency "fast_float", "6.1.4"
s.dependency "fmt", "11.0.2"
s.dependency "glog"
add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
end
@@ -28,6 +28,7 @@ target_link_libraries(
react_featureflagsjni
turbomodulejsijni
jsi
jsitooling
jsireact
react_utils
jsinspector
@@ -62,6 +62,6 @@ Pod::Spec.new do |s|
add_dependency(s, "React-Fabric")
depend_on_js_engine(s)
s.dependency "React-jsinspector"
add_dependency(s, "React-jsitooling", :framework_name => "JSITooling")
end
@@ -56,4 +56,5 @@ Pod::Spec.new do |s|
s.dependency "React-hermes"
s.dependency "hermes-engine"
add_dependency(s, "React-jsitooling", :framework_name => "JSITooling")
end
@@ -70,7 +70,7 @@ Pod::Spec.new do |s|
s.dependency "React-jserrorhandler"
s.dependency "React-jsinspector"
s.dependency "React-featureflags"
add_dependency(s, "React-jsitooling", :framework_name => "JSITooling")
add_dependency(s, "React-RCTFBReactNativeSpec")
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
@@ -633,6 +633,7 @@ class ReactNativePodsUtils
"React-jsi",
"React-jsiexecutor",
"React-jsinspector",
"React-jsitooling",
"React-logger",
"React-perflogger",
"React-rncore",
@@ -144,6 +144,7 @@ def use_react_native! (
pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor"
pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector-modern"
pod 'React-jsitooling', :path => "#{prefix}/ReactCommon/jsitooling"
pod 'React-jsinspectortracing', :path => "#{prefix}/ReactCommon/jsinspector-modern/tracing"
pod 'React-callinvoker', :path => "#{prefix}/ReactCommon/callinvoker"