diff --git a/BUCK b/BUCK index f900a2be0e0e42..fb88d3de50e4d8 100644 --- a/BUCK +++ b/BUCK @@ -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"), ], diff --git a/React/CxxBridge/JSCExecutorFactory.mm b/React/CxxBridge/JSCExecutorFactory.mm index 4d8a1ba1b2940e..78584cd4e6c121 100644 --- a/React/CxxBridge/JSCExecutorFactory.mm +++ b/React/CxxBridge/JSCExecutorFactory.mm @@ -7,7 +7,7 @@ #include "JSCExecutorFactory.h" -#import +#import #import diff --git a/ReactAndroid/src/main/jni/react/jscexecutor/BUCK b/ReactAndroid/src/main/jni/react/jscexecutor/BUCK index 7719f27dbc9601..8b3e82eb665f94 100644 --- a/ReactAndroid/src/main/jni/react/jscexecutor/BUCK +++ b/ReactAndroid/src/main/jni/react/jscexecutor/BUCK @@ -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"), ], ) diff --git a/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp b/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp index 60450b5c404b33..9d38412d1cb9cd 100644 --- a/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include diff --git a/ReactCommon/jsc/.clang-tidy b/ReactCommon/jsc/.clang-tidy new file mode 100644 index 00000000000000..9f33ef5a06d828 --- /dev/null +++ b/ReactCommon/jsc/.clang-tidy @@ -0,0 +1,6 @@ +--- +Checks: '> +clang-diagnostic-*, +' +InheritParentConfig: true +... diff --git a/ReactCommon/jsc/BUCK b/ReactCommon/jsc/BUCK new file mode 100644 index 00000000000000..3981ca830a7bbc --- /dev/null +++ b/ReactCommon/jsc/BUCK @@ -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"), + ], +) diff --git a/ReactCommon/jsc/CMakeLists.txt b/ReactCommon/jsc/CMakeLists.txt new file mode 100644 index 00000000000000..52188407ea55e4 --- /dev/null +++ b/ReactCommon/jsc/CMakeLists.txt @@ -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) diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsc/JSCRuntime.cpp similarity index 100% rename from ReactCommon/jsi/JSCRuntime.cpp rename to ReactCommon/jsc/JSCRuntime.cpp diff --git a/ReactCommon/jsi/JSCRuntime.h b/ReactCommon/jsc/JSCRuntime.h similarity index 100% rename from ReactCommon/jsi/JSCRuntime.h rename to ReactCommon/jsc/JSCRuntime.h diff --git a/ReactCommon/jsi/React-jsc.podspec b/ReactCommon/jsc/React-jsc.podspec similarity index 94% rename from ReactCommon/jsi/React-jsc.podspec rename to ReactCommon/jsc/React-jsc.podspec index a3e3c2cdf2ae98..ac0e7858cba1b2 100644 --- a/ReactCommon/jsi/React-jsc.podspec +++ b/ReactCommon/jsc/React-jsc.podspec @@ -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" } diff --git a/ReactCommon/jsi/BUCK b/ReactCommon/jsi/BUCK index 2d5e68fe3de0b6..72d8a39190def5 100644 --- a/ReactCommon/jsi/BUCK +++ b/ReactCommon/jsi/BUCK @@ -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"), - ], -) diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index d76853a1a9091f..92eb37818146d8 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -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,40 +700,40 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 9A596313B3964A4DEB794409 /* [CP] Copy Pods Resources */ = { + 992FB5A50F2847F7EB2C285C /* [RN] Copy Hermes Framework */ = { 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"; + inputPaths = ( + ); + name = "[RN] Copy Hermes Framework"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n"; - showEnvVarsInLog = 0; + shellScript = ". ../../sdks/hermes-engine/utils/copy-hermes-xcode.sh"; }; - 9C4DBC25C644151BD596140F /* [RN] Copy Hermes Framework */ = { + 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", ); - inputPaths = ( - ); - name = "[RN] Copy Hermes Framework"; + name = "[CP] Copy Pods Resources"; outputFileListPaths = ( - ); - outputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = ". ../../sdks/hermes-engine/utils/copy-hermes-xcode.sh"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n"; + showEnvVarsInLog = 0; }; A8DE6393E2BB72D8FBBF6C27 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; diff --git a/scripts/cocoapods/__tests__/jsengine-test.rb b/scripts/cocoapods/__tests__/jsengine-test.rb index 14c76d0c6d810c..ef18a72c6be0fb 100644 --- a/scripts/cocoapods/__tests__/jsengine-test.rb +++ b/scripts/cocoapods/__tests__/jsengine-test.rb @@ -44,7 +44,7 @@ def test_setupJsc_installsPods # 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 @@ def test_setupJsc_installsPods_installsFabricSubspecWhenFabricEnabled # 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 # ================== # diff --git a/scripts/cocoapods/jsengine.rb b/scripts/cocoapods/jsengine.rb index a3c1cff4f1f1ce..17941930fc5824 100644 --- a/scripts/cocoapods/jsengine.rb +++ b/scripts/cocoapods/jsengine.rb @@ -11,9 +11,9 @@ # @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