mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Move JSCRuntime into its own folder (#35482)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35482 This change moves the JSCRuntime.h/cpp into a `jsc` folder. This change is required for several reasons: 1. on iOS, the new `jsi`, `jsidynamic` and `jsc` setup is breaking the `use_frameworks!` with `:linkage => :static` option with the old architecture. So it is a regression. 2. JSCRuntime is required by some libraries and needs to be exposed as a prefab and the current setup makes it hard to achieve. allow-large-files ## Changelog: [General][Changed] - Move JSCRuntime into a separate pod/prefab Reviewed By: cortinico Differential Revision: D41533778 fbshipit-source-id: 642240c93a6c124280430d4f196049cb67cb130b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7329e4052d
commit
f3bf4d02ab
@@ -115,7 +115,7 @@ rn_apple_xplat_cxx_library(
|
||||
react_native_root_target("React/CoreModules:CoreModules"),
|
||||
react_native_xplat_target("cxxreact:bridge"),
|
||||
react_native_xplat_target("cxxreact:jsbigstring"),
|
||||
react_native_xplat_target("jsi:JSCRuntime"),
|
||||
react_native_xplat_target("jsc:JSCRuntime"),
|
||||
react_native_xplat_target("jsiexecutor:jsiexecutor"),
|
||||
react_native_xplat_target("reactperflogger:reactperflogger"),
|
||||
],
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "JSCExecutorFactory.h"
|
||||
|
||||
#import <jsi/JSCRuntime.h>
|
||||
#import <jsc/JSCRuntime.h>
|
||||
|
||||
#import <memory>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ rn_xplat_cxx_library(
|
||||
deps = [
|
||||
FBJNI_TARGET,
|
||||
react_native_target("jni/react/jni:jni"),
|
||||
react_native_xplat_target("jsi:JSCRuntime"),
|
||||
react_native_xplat_target("jsc:JSCRuntime"),
|
||||
react_native_xplat_target("jsiexecutor:jsiexecutor"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/JSCRuntime.h>
|
||||
#include <jsc/JSCRuntime.h>
|
||||
#include <jsireact/JSIExecutor.h>
|
||||
#include <react/jni/JReactMarker.h>
|
||||
#include <react/jni/JSLogging.h>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
Checks: '>
|
||||
clang-diagnostic-*,
|
||||
'
|
||||
InheritParentConfig: true
|
||||
...
|
||||
@@ -0,0 +1,34 @@
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "APPLE", "IOS", "MACOSX", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_dep", "rn_xplat_cxx_library")
|
||||
|
||||
APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "JSCRuntime",
|
||||
srcs = [
|
||||
"JSCRuntime.cpp",
|
||||
],
|
||||
header_namespace = "jsc",
|
||||
exported_headers = [
|
||||
"JSCRuntime.h",
|
||||
],
|
||||
apple_sdks = (IOS, MACOSX),
|
||||
compiler_flags_pedantic = True,
|
||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS + [
|
||||
"-Os",
|
||||
],
|
||||
fbobjc_frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework",
|
||||
],
|
||||
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
|
||||
labels = [
|
||||
"pfh:ReactNative_CommonInfrastructurePlaceholder",
|
||||
],
|
||||
platforms = APPLE,
|
||||
visibility = ["PUBLIC"],
|
||||
xplat_mangled_args = {
|
||||
"soname": "libjscjsi.$(ext)",
|
||||
},
|
||||
exported_deps = [
|
||||
react_native_xplat_dep("jsi:jsi"),
|
||||
],
|
||||
)
|
||||
@@ -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.
|
||||
|
||||
##################
|
||||
### jscruntime ###
|
||||
##################
|
||||
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
add_compile_options(
|
||||
-fexceptions
|
||||
-frtti
|
||||
-O3
|
||||
-Wno-unused-lambda-capture
|
||||
-DLOG_TAG=\"ReactNative\")
|
||||
|
||||
add_library(jscruntime STATIC
|
||||
JSCRuntime.h
|
||||
JSCRuntime.cpp)
|
||||
|
||||
target_include_directories(jscruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(jscruntime folly_runtime jsc glog)
|
||||
|
||||
# TODO: Remove this flag when ready.
|
||||
# Android has this enabled by default, but the flag is still needed for iOS.
|
||||
target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED)
|
||||
@@ -28,12 +28,8 @@ Pod::Spec.new do |s|
|
||||
s.source_files = "JSCRuntime.{cpp,h}"
|
||||
s.exclude_files = "**/test/*"
|
||||
s.framework = "JavaScriptCore"
|
||||
s.dependency "React-jsi", version
|
||||
s.default_subspec = "Default"
|
||||
|
||||
s.subspec "Default" do
|
||||
# no-op
|
||||
end
|
||||
s.dependency "React-jsi", version
|
||||
|
||||
s.subspec "Fabric" do |ss|
|
||||
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
|
||||
+1
-31
@@ -1,4 +1,4 @@
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "APPLE", "IOS", "MACOSX", "react_native_xplat_dep", "rn_xplat_cxx_library")
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_xplat_dep", "rn_xplat_cxx_library")
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "jsi",
|
||||
@@ -56,33 +56,3 @@ rn_xplat_cxx_library(
|
||||
react_native_xplat_dep("jsi:jsi"),
|
||||
],
|
||||
)
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "JSCRuntime",
|
||||
srcs = [
|
||||
"JSCRuntime.cpp",
|
||||
],
|
||||
header_namespace = "jsi",
|
||||
exported_headers = [
|
||||
"JSCRuntime.h",
|
||||
],
|
||||
apple_sdks = (IOS, MACOSX),
|
||||
compiler_flags_pedantic = True,
|
||||
fbobjc_compiler_flags = [
|
||||
"-Os",
|
||||
],
|
||||
fbobjc_frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework",
|
||||
],
|
||||
labels = [
|
||||
"pfh:ReactNative_CommonInfrastructurePlaceholder",
|
||||
],
|
||||
platforms = APPLE,
|
||||
visibility = ["PUBLIC"],
|
||||
xplat_mangled_args = {
|
||||
"soname": "libjscjsi.$(ext)",
|
||||
},
|
||||
exported_deps = [
|
||||
react_native_xplat_dep("jsi:jsi"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -415,7 +415,7 @@
|
||||
5CF0FD27207FC6EC00C13D65 /* Start Metro */,
|
||||
2FCDFB64B37634EC8EC3139B /* [CP] Embed Pods Frameworks */,
|
||||
A8DE6393E2BB72D8FBBF6C27 /* [CP] Copy Pods Resources */,
|
||||
9C4DBC25C644151BD596140F /* [RN] Copy Hermes Framework */,
|
||||
992FB5A50F2847F7EB2C285C /* [RN] Copy Hermes Framework */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -700,24 +700,7 @@
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
9A596313B3964A4DEB794409 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
9C4DBC25C644151BD596140F /* [RN] Copy Hermes Framework */ = {
|
||||
992FB5A50F2847F7EB2C285C /* [RN] Copy Hermes Framework */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
@@ -735,6 +718,23 @@
|
||||
shellPath = /bin/sh;
|
||||
shellScript = ". ../../sdks/hermes-engine/utils/copy-hermes-xcode.sh";
|
||||
};
|
||||
9A596313B3964A4DEB794409 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
A8DE6393E2BB72D8FBBF6C27 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
|
||||
@@ -44,7 +44,7 @@ class JSEngineTests < Test::Unit::TestCase
|
||||
# Assert
|
||||
assert_equal($podInvocationCount, 2)
|
||||
assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi")
|
||||
assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsi")
|
||||
assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsc")
|
||||
end
|
||||
|
||||
def test_setupJsc_installsPods_installsFabricSubspecWhenFabricEnabled
|
||||
@@ -57,8 +57,8 @@ class JSEngineTests < Test::Unit::TestCase
|
||||
# Assert
|
||||
assert_equal($podInvocationCount, 3)
|
||||
assert_equal($podInvocation["React-jsi"][:path], "../../ReactCommon/jsi")
|
||||
assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsi")
|
||||
assert_equal($podInvocation["React-jsc/Fabric"][:path], "../../ReactCommon/jsi")
|
||||
assert_equal($podInvocation["React-jsc"][:path], "../../ReactCommon/jsc")
|
||||
assert_equal($podInvocation["React-jsc/Fabric"][:path], "../../ReactCommon/jsc")
|
||||
end
|
||||
|
||||
# ================== #
|
||||
|
||||
@@ -11,9 +11,9 @@ require_relative './utils.rb'
|
||||
# @parameter fabric_enabled: whether Fabirc is enabled
|
||||
def setup_jsc!(react_native_path: "../node_modules/react-native", fabric_enabled: false)
|
||||
pod 'React-jsi', :path => "#{react_native_path}/ReactCommon/jsi"
|
||||
pod 'React-jsc', :path => "#{react_native_path}/ReactCommon/jsi"
|
||||
pod 'React-jsc', :path => "#{react_native_path}/ReactCommon/jsc"
|
||||
if fabric_enabled
|
||||
pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi"
|
||||
pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsc"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user