Skip to content

Commit

Permalink
Break Circular Dependency between React-Codegen and React-Fabric
Browse files Browse the repository at this point in the history
Summary:
One of the circular dependencies we have in OSS was between React-Codegen and React-Fabric.

React-Codegen generates component which has to depends on React-Fabric because they need to use the files contained in the `react/renderer/view` folder.

React-Fabric contains some components that depends on RNCore, which was generated inside the React-Codegen folder.

This change generates the RNCore components inside the `ReactCommon/react/renderer/components/rncore` folder, breaking the dependency as `rncore` folder is now contained by React-Fabric itself.

**Fun Fact:** That's how it always should have been. There was already a line in the `.gitignore` to exclude the content of `ReactCommon/react/renderer/components/rncore` folder. I guess that with some of the refactoring/previous projects on Codegen, this requirements has slipped.

## Changelog:
[iOS][Changed] -  generates RNCore components inside the ReactCommon folder

Differential Revision: https://internalfb.com/D43304641

fbshipit-source-id: e35422b6dd16989af633bc311e4fa2799901cd09
  • Loading branch information
Riccardo Cipolleschi authored and facebook-github-bot committed Feb 15, 2023
1 parent 94987d6 commit bc47f17
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 57 deletions.
2 changes: 2 additions & 0 deletions React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if ENV['USE_FRAMEWORKS']
header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/imagemanager/platform/ios\""
header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers\""
header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios\""
header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-ImageManager/React_ImageManager.framework/Headers\""
end

Pod::Spec.new do |s|
Expand Down Expand Up @@ -66,6 +67,7 @@ Pod::Spec.new do |s|
s.dependency "React-Core", version
s.dependency "React-Fabric", version
s.dependency "React-RCTImage", version
s.dependency "React-ImageManager"
s.dependency "RCT-Folly/Fabric", folly_version

s.test_spec 'Tests' do |test_spec|
Expand Down
16 changes: 9 additions & 7 deletions ReactCommon/React-Fabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Pod::Spec.new do |s|
header_search_path = [
"\"$(PODS_ROOT)/boost\"",
"\"$(PODS_TARGET_SRCROOT)/ReactCommon\"",
"\"$(PODS_ROOT)/RCT-Folly\""
"\"$(PODS_ROOT)/RCT-Folly\"",
]

if ENV['USE_FRAMEWORKS']
Expand Down Expand Up @@ -161,13 +161,19 @@ Pod::Spec.new do |s|
sss.header_dir = "react/renderer/components/modal"
end

ss.subspec "rncore" do |sss|
sss.dependency folly_dep_name, folly_version
sss.compiler_flags = folly_compiler_flags
sss.source_files = "react/renderer/components/rncore/**/*.{m,mm,cpp,h}"
sss.header_dir = "react/renderer/components/rncore"
end

ss.subspec "root" do |sss|
sss.dependency folly_dep_name, folly_version
sss.compiler_flags = folly_compiler_flags
sss.source_files = "react/renderer/components/root/**/*.{m,mm,cpp,h}"
sss.exclude_files = "react/renderer/components/root/tests"
sss.header_dir = "react/renderer/components/root"

end

ss.subspec "safeareaview" do |sss|
Expand Down Expand Up @@ -243,13 +249,9 @@ Pod::Spec.new do |s|
end

s.subspec "imagemanager" do |ss|
ss.dependency "React-RCTImage", version
ss.dependency folly_dep_name, folly_version
ss.compiler_flags = folly_compiler_flags
ss.source_files = "react/renderer/imagemanager/**/*.{m,mm,cpp,h}"
ss.exclude_files = "react/renderer/imagemanager/tests",
"react/renderer/imagemanager/platform/android",
"react/renderer/imagemanager/platform/cxx"
ss.source_files = "react/renderer/imagemanager/*.{m,mm,cpp,h}"
ss.header_dir = "react/renderer/imagemanager"
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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.

require "json"

package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "..", "..", "package.json")))
version = package['version']

source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
boost_compiler_flags = '-Wno-documentation'

Pod::Spec.new do |s|
source_files = "**/*.{m,mm,cpp,h}"
header_search_paths = [
"\"$(PODS_ROOT)/boost\"",
"\"$(PODS_TARGET_SRCROOT)/../../../\"",
"\"$(PODS_ROOT)/RCT-Folly\"",
]

s.name = "React-ImageManager"
s.version = version
s.summary = "Fabric for React Native."
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.source = source
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.source_files = source_files
s.header_dir = "react/renderer/imagemanager"

if ENV['USE_FRAMEWORKS']
s.module_name = "React_ImageManager"
s.header_mappings_dir = "./"
header_search_paths = header_search_paths + [
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers\"",
"\"$(PODS_ROOT)/DoubleConversion\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios\""
]
end

s.pod_target_xcconfig = {
"USE_HEADERMAP" => "NO",
"HEADER_SEARCH_PATHS" => header_search_paths.join(" "),
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
}

s.dependency "RCT-Folly/Fabric"
s.dependency "React-Fabric"
s.dependency "React-Core/Default"
s.dependency "React-RCTImage"
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include "ImageManager.h"
#import <react/renderer/imagemanager/ImageManager.h>

#import <React/RCTImageLoaderWithAttributionProtocol.h>
#import <React/RCTUtils.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include "ImageRequest.h"
#include <react/renderer/imagemanager/ImageRequest.h>

namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <UIKit/UIKit.h>

#import <RCTImageManagerProtocol.h>
#import "RCTImageManagerProtocol.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <UIKit/UIKit.h>

#import <RCTImageManagerProtocol.h>
#import "RCTImageManagerProtocol.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
Loading

0 comments on commit bc47f17

Please sign in to comment.