Remove RN_FABRIC_ENABLED flag (#41561)

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

The RN_FABRIC_ENABLED has been deprecated and superseded by the RCT_NEW_ARCH_ENABLED for a while now.

This change removes it, from the codebase as now we always have the Fabric pod available to the codebase.

## Changelog
[Internal] - Remove RN_FABRIC_ENABLED flag

Reviewed By: dmytrorykun

Differential Revision: D51468332

fbshipit-source-id: 6b2fc554e6bf5ac748b9e45d7c14f9ba9b57820c
This commit is contained in:
Riccardo Cipolleschi
2023-11-22 03:50:29 -08:00
committed by Facebook GitHub Bot
parent 0cbd2a345d
commit 13d08f146b
9 changed files with 5 additions and 103 deletions
@@ -24,9 +24,8 @@ use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED" : "")
is_fabric_enabled = is_new_arch_enabled || ENV["RCT_FABRIC_ENABLED"]
fabric_flag = (is_fabric_enabled ? " -DRN_FABRIC_ENABLED" : "")
hermes_flag = (use_hermes ? " -DUSE_HERMES" : "")
other_cflags = "$(inherited)" + folly_flags + new_arch_enabled_flag + fabric_flag + hermes_flag
other_cflags = "$(inherited)" + folly_flags + new_arch_enabled_flag + hermes_flag
header_search_paths = [
"$(PODS_TARGET_SRCROOT)/../../ReactCommon",
@@ -58,7 +58,7 @@ Pod::Spec.new do |s|
s.framework = ["JavaScriptCore", "MobileCoreServices"]
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => header_search_paths,
"OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" + " " + folly_flags,
"OTHER_CFLAGS" => "$(inherited) " + folly_flags,
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
}.merge!(ENV['USE_FRAMEWORKS'] != nil ? {
"PUBLIC_HEADERS_FOLDER_PATH" => "#{module_name}.framework/Headers/#{header_dir}"
@@ -30,10 +30,6 @@ target_link_libraries(jscruntime
jsi
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)
if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_options(jscruntime PRIVATE -DNDEBUG)
endif()
@@ -240,10 +240,7 @@ class JSCRuntime : public jsi::Runtime {
static JSStringRef stringRef(const jsi::String& str);
static JSStringRef stringRef(const jsi::PropNameID& sym);
static JSObjectRef objectRef(const jsi::Object& obj);
#ifdef RN_FABRIC_ENABLED
static JSObjectRef objectRef(const jsi::WeakObject& obj);
#endif
// Factory methods for creating String/Object
jsi::Symbol createSymbol(JSValueRef symbolRef) const;
@@ -1065,23 +1062,15 @@ jsi::Array JSCRuntime::getPropertyNames(const jsi::Object& obj) {
}
jsi::WeakObject JSCRuntime::createWeakObject(const jsi::Object& obj) {
#ifdef RN_FABRIC_ENABLED
// TODO: revisit this implementation
JSObjectRef objRef = objectRef(obj);
return make<jsi::WeakObject>(makeObjectValue(objRef));
#else
throw std::logic_error("Not implemented");
#endif
}
jsi::Value JSCRuntime::lockWeakObject(const jsi::WeakObject& obj) {
#ifdef RN_FABRIC_ENABLED
// TODO: revisit this implementation
JSObjectRef objRef = objectRef(obj);
return jsi::Value(createObject(objRef));
#else
throw std::logic_error("Not implemented");
#endif
}
jsi::Array JSCRuntime::createArray(size_t length) {
@@ -1527,12 +1516,10 @@ JSObjectRef JSCRuntime::objectRef(const jsi::Object& obj) {
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}
#ifdef RN_FABRIC_ENABLED
JSObjectRef JSCRuntime::objectRef(const jsi::WeakObject& obj) {
// TODO: revisit this implementation
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}
#endif
void JSCRuntime::checkException(JSValueRef exc) {
if (JSC_UNLIKELY(exc)) {
@@ -32,6 +32,6 @@ Pod::Spec.new do |s|
s.dependency "React-jsi", version
s.subspec "Fabric" do |ss|
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited)" }
end
end
@@ -790,68 +790,6 @@ class UtilsTests < Test::Unit::TestCase
end
end
# ============================= #
# Test - Apply Flags For Fabric #
# ============================= #
def test_applyFlagsForFabric_whenFabricEnabled_addsTheFlag
# Arrange
first_target = prepare_target("FirstTarget")
second_target = prepare_target("SecondTarget")
third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle")
user_project_mock = UserProjectMock.new("a/path", [
prepare_config("Debug"),
prepare_config("Release"),
],
:native_targets => [
first_target,
second_target
]
)
pods_projects_mock = PodsProjectMock.new([third_target], {"hermes-engine" => {}})
installer = InstallerMock.new(pods_projects_mock, [
AggregatedProjectMock.new(user_project_mock)
])
# Act
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: true)
# Assert
user_project_mock.build_configurations.each do |config|
received_cflags = config.build_settings["OTHER_CFLAGS"]
expected_cflags = "$(inherited) -DRN_FABRIC_ENABLED"
assert_equal(received_cflags, expected_cflags)
end
end
def test_applyFlagsForFabric_whenFabricDisabled_doNothing
# Arrange
first_target = prepare_target("FirstTarget")
second_target = prepare_target("SecondTarget")
third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle")
user_project_mock = UserProjectMock.new("/a/path", [
prepare_config("Debug"),
prepare_config("Release"),
],
:native_targets => [
first_target,
second_target
]
)
pods_projects_mock = PodsProjectMock.new([third_target], {"hermes-engine" => {}})
installer = InstallerMock.new(pods_projects_mock, [
AggregatedProjectMock.new(user_project_mock)
])
# Act
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: false)
# Assert
user_project_mock.build_configurations.each do |config|
assert_equal(config.build_settings["OTHER_CFLAGS"], "$(inherited)")
end
end
# ============================== #
# Test - Apply ATS configuration #
# ============================== #
@@ -147,15 +147,6 @@ class ReactNativePodsUtils
end
def self.apply_flags_for_fabric(installer, fabric_enabled: false)
fabric_flag = "-DRN_FABRIC_ENABLED"
if fabric_enabled
self.add_compiler_flag_to_project(installer, fabric_flag)
else
self.remove_compiler_flag_from_project(installer, fabric_flag)
end
end
private
def self.add_build_settings_to_pod(installer, settings_name, settings_value, target_pod_name, configuration)
@@ -281,7 +281,6 @@ def react_native_post_install(
ReactNativePodsUtils.update_search_paths(installer)
ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled)
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: fabric_enabled)
ReactNativePodsUtils.apply_xcode_15_patch(installer)
ReactNativePodsUtils.apply_ats_config(installer)
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
@@ -933,10 +933,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"$(inherited)",
"-DRN_FABRIC_ENABLED",
);
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
@@ -944,7 +941,6 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = (
"-ObjC",
@@ -1029,10 +1025,7 @@
);
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = (
"$(inherited)",
"-DRN_FABRIC_ENABLED",
);
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
@@ -1040,7 +1033,6 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = (
"-ObjC",