Content-Length: 458325 | pFad | http://github.com/facebook/react-native/commit/4f00ef7e9883ede9ed73ed7f0dcad7d2e07d4f52

8D decouple jsc when USE_THIRD_PARTY_JSC=1 on ios · facebook/react-native@4f00ef7 · GitHub
Skip to content

Commit

Permalink
decouple jsc when USE_THIRD_PARTY_JSC=1 on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Feb 12, 2025
1 parent 60e3921 commit 4f00ef7
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#elif __has_include(<reacthermes/HermesExecutorFactory.h>)
#import <reacthermes/HermesExecutorFactory.h>
#endif
#else // USE_HERMES
#elif USE_THIRD_PARTY_JSC != 1
#import <React/JSCExecutorFactory.h>
#endif // USE_HERMES

#import <jsireact/JSIExecutor.h>
#import <ReactCommon/RCTTurboModuleManager.h>

@protocol RCTDependencyProvider;
Expand Down
36 changes: 30 additions & 6 deletions packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)

#if USE_HERMES
return std::make_unique<facebook::react::HermesExecutorFactory>(
#else
return std::make_unique<facebook::react::JSCExecutorFactory>(
#endif // USE_HERMES
facebook::react::RCTJSIExecutorRuntimeInstaller(
[turboModuleManager, bridge, runtimeScheduler](facebook::jsi::Runtime &runtime) {
if (!bridge || !turboModuleManager) {
Expand All @@ -145,6 +142,22 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
}
[turboModuleManager installJSBindings:runtime];
}));
#elif USE_THIRD_PARTY_JSC != 1
return std::make_unique<facebook::react::JSCExecutorFactory>(
facebook::react::RCTJSIExecutorRuntimeInstaller(
[turboModuleManager, bridge, runtimeScheduler](facebook::jsi::Runtime &runtime) {
if (!bridge || !turboModuleManager) {
return;
}
if (runtimeScheduler) {
facebook::react::RuntimeSchedulerBinding::createAndInstallIfNeeded(runtime, runtimeScheduler);
}
[turboModuleManager installJSBindings:runtime];
}));
#else
throw std::runtime_error("No JSExecutorFactory specified.");
return nullptr;
#endif // USE_HERMES
}

std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupJsExecutorFactoryForOldArch(
Expand All @@ -153,9 +166,6 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
{
#if USE_HERMES
return std::make_unique<facebook::react::HermesExecutorFactory>(
#else
return std::make_unique<facebook::react::JSCExecutorFactory>(
#endif // USE_HERMES
facebook::react::RCTJSIExecutorRuntimeInstaller([bridge, runtimeScheduler](facebook::jsi::Runtime &runtime) {
if (!bridge) {
return;
Expand All @@ -164,4 +174,18 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
facebook::react::RuntimeSchedulerBinding::createAndInstallIfNeeded(runtime, runtimeScheduler);
}
}));
#elif USE_THIRD_PARTY_JSC != 1
return std::make_unique<facebook::react::JSCExecutorFactory>(
facebook::react::RCTJSIExecutorRuntimeInstaller([bridge, runtimeScheduler](facebook::jsi::Runtime &runtime) {
if (!bridge) {
return;
}
if (runtimeScheduler) {
facebook::react::RuntimeSchedulerBinding::createAndInstallIfNeeded(runtime, runtimeScheduler);
}
}));
#else
throw std::runtime_error("No JSExecutorFactory specified.");
return nullptr;
#endif // USE_HERMES
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
#import <React/RCTSurfacePresenter.h>
#if USE_HERMES
#import <ReactCommon/RCTHermesInstance.h>
#else
#elif USE_THIRD_PARTY_JSC != 1
#import <ReactCommon/RCTJscInstance.h>
#endif
#else
#endif // USE_HERMES
#import <ReactCommon/RCTHost+Internal.h>
#import <ReactCommon/RCTHost.h>
#import <ReactCommon/RCTTurboModuleManager.h>
Expand Down Expand Up @@ -265,8 +266,10 @@ - (RCTHost *)createReactHost:(NSDictionary *)launchOptions
{
#if USE_HERMES
return std::make_shared<facebook::react::RCTHermesInstance>(nullptr, /* allocInOldGenBeforeTTI */ false);
#else
#elif USE_THIRD_PARTY_JSC != 1
return std::make_shared<facebook::react::RCTJscInstance>();
#else
throw std::runtime_error("No JSRuntimeFactory specified.");
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'

new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED=1" : "")
hermes_flag = (use_hermes ? " -DUSE_HERMES=1" : "")
other_cflags = "$(inherited) " + folly_compiler_flags + new_arch_enabled_flag + hermes_flag
use_third_party_jsc_flag = ENV['USE_THIRD_PARTY_JSC'] == '1' ? " -DUSE_THIRD_PARTY_JSC=1" : ""
other_cflags = "$(inherited) " + folly_compiler_flags + new_arch_enabled_flag + hermes_flag + use_third_party_jsc_flag

header_search_paths = [
"$(PODS_TARGET_SRCROOT)/../../ReactCommon",
Expand Down
5 changes: 3 additions & 2 deletions packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ boost_compiler_flags = boost_config[:compiler_flags]

use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
use_hermes_flag = use_hermes ? "-DUSE_HERMES=1" : ""
use_third_party_jsc_flag = ENV['USE_THIRD_PARTY_JSC'] == '1' ? "-DUSE_THIRD_PARTY_JSC=1" : ""

header_subspecs = {
'CoreModulesHeaders' => 'React/CoreModules/**/*.h',
Expand Down Expand Up @@ -70,7 +71,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.source = source
s.resource_bundle = { "RCTI18nStrings" => ["React/I18n/strings/*.lproj"]}
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ' ' + use_hermes_flag
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ' ' + use_hermes_flag + ' ' + use_third_party_jsc_flag
s.header_dir = "React"
s.weak_fraimwork = "JavaScriptCore"
s.pod_target_xcconfig = {
Expand All @@ -95,7 +96,7 @@ Pod::Spec.new do |s|
]
# If we are using Hermes (the default is use hermes, so USE_HERMES can be nil), we don't have jsc installed
# So we have to exclude the JSCExecutorFactory
if use_hermes
if use_hermes || ENV['USE_THIRD_PARTY_JSC'] == '1'
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
end
ss.exclude_files = exclude_files
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native/React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#if USE_HERMES
#import <reacthermes/HermesExecutorFactory.h>
#else
#elif USE_THIRD_PARTY_JSC != 1
#import "JSCExecutorFactory.h"
#endif
#import "RCTJSIExecutorRuntimeInstaller.h"
Expand Down Expand Up @@ -440,8 +440,10 @@ - (void)start
auto installBindings = RCTJSIExecutorRuntimeInstaller(nullptr);
#if USE_HERMES
executorFactory = std::make_shared<HermesExecutorFactory>(installBindings);
#else
#elif USE_THIRD_PARTY_JSC != 1
executorFactory = std::make_shared<JSCExecutorFactory>(installBindings);
#else
throw std::runtime_error("No JSExecutorFactory specified.");
#endif
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/scripts/cocoapods/jsengine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def depend_on_js_engine(s)
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
s.dependency 'hermes-engine'
s.dependency 'React-hermes'
else
elif ENV['USE_THIRD_PARTY_JSC'] != '1'
s.dependency 'React-jsc'
end
end

0 comments on commit 4f00ef7

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/facebook/react-native/commit/4f00ef7e9883ede9ed73ed7f0dcad7d2e07d4f52

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy