Skip to content

Commit

Permalink
Remove RN_FABRIC_ENABLED flag (facebook#41561)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Nov 22, 2023
1 parent 0cbd2a3 commit 13d08f1
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 0 additions & 4 deletions packages/react-native/ReactCommon/jsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
13 changes: 0 additions & 13 deletions packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/jsc/React-jsc.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
62 changes: 0 additions & 62 deletions packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,68 +790,6 @@ def test_updateSearchPaths_whenNotUseFrameworks_addsSearchPaths
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 #
# ============================== #
Expand Down
9 changes: 0 additions & 9 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ def self.apply_xcode_15_patch(installer, xcodebuild_manager: Xcodebuild)

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)
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 2 additions & 10 deletions packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -933,18 +933,14 @@
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",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -1029,18 +1025,14 @@
);
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",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand Down

0 comments on commit 13d08f1

Please sign in to comment.