Skip to content

Commit

Permalink
Move react/fabric/components -> react/cxxcomponents
Browse files Browse the repository at this point in the history
Summary:
This diff moves Component and ComponentManager classes -> react/cxxcomponents. The purpose is to be able to use these classes from any platform, not only Android

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D39531533

fbshipit-source-id: 4732aa7bf59d82dae11441212975f0e225c6d458
  • Loading branch information
mdvacca authored and facebook-github-bot committed Sep 16, 2022
1 parent c9966e4 commit 85e9b07
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 4 deletions.
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ add_react_android_subdir(src/main/jni/first-party/fbjni)
add_react_android_subdir(src/main/jni/first-party/fb)
add_react_android_subdir(src/main/jni/first-party/fbgloginit)
add_react_android_subdir(src/main/jni/first-party/yogajni)
add_react_android_subdir(src/main/jni/react/cxxcomponents)
add_react_android_subdir(src/main/jni/react/jni)
add_react_android_subdir(src/main/jni/react/reactperflogger)
add_react_android_subdir(src/main/jni/react/jscexecutor)
Expand Down
46 changes: 46 additions & 0 deletions ReactAndroid/src/main/jni/react/cxxcomponents/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
load(
"//tools/build_defs/oss:rn_defs.bzl",
"ANDROID",
"APPLE",
"CXX",
"react_native_xplat_target",
"rn_xplat_cxx_library",
"subdir_glob",
)

rn_xplat_cxx_library(
name = "components",
srcs = glob(
["**/*.cpp"],
),
headers = glob(
["**/*.h"],
),
header_namespace = "",
exported_headers = subdir_glob(
[
("", "**/*.h"),
],
prefix = "react/cxxcomponents",
),
force_static = True,
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
"supermodule:xplat/default/public.react_native.infra",
],
platforms = (APPLE, ANDROID, CXX),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
soname = "libcxxcomponents.$(ext)",
tests = [":tests"],
visibility = ["PUBLIC"],
deps = [
"//third-party/glog:glog",
"//xplat/fbsystrace:fbsystrace",
"//xplat/folly:memory",
"//xplat/folly:molly",
react_native_xplat_target("react/renderer/core:core"),
],
)
22 changes: 22 additions & 0 deletions ReactAndroid/src/main/jni/react/cxxcomponents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(
-fexceptions
-frtti
-std=c++17
-Wall
-Wpedantic
-Wno-gnu-zero-variadic-macro-arguments)

file(GLOB_RECURSE cxxcomponents_SRC CONFIGURE_DEPENDS *.cpp *.h)

add_library(cxxcomponents SHARED ${cxxcomponents_SRC})

target_include_directories(cxxcomponents PUBLIC .)
set_target_properties(cxxcomponents PROPERTIES LINKER_LANGUAGE CXX)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include <react/fabric/Component.h>
#include <react/cxxcomponents/Component.h>
#include <react/renderer/core/Props.h>

namespace facebook::react {
Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/react/fabric/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rn_xplat_cxx_library(
react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
react_native_xplat_target("react/renderer/components/scrollview:scrollview"),
react_native_xplat_target("runtimeexecutor:runtimeexecutor"),
"//xplat/js/react-native-github/ReactAndroid/src/main/jni/react/cxxcomponents:components",
react_native_target("jni/react/jni:jni"),
"//xplat/fbsystrace:fbsystrace",
"//xplat/jsi:JSIDynamic",
Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/react/fabric/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_include_directories(fabricjni PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(
fabricjni
butter
cxxcomponents
fb
fbjni
folly_runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#pragma once

#include <fbjni/fbjni.h>
#include <react/fabric/ComponentManager.h>
#include <react/cxxcomponents/ComponentManager.h>

namespace facebook {
namespace react {
Expand Down
4 changes: 2 additions & 2 deletions ReactAndroid/src/main/jni/react/fabric/CppComponentRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <mutex>
#include <unordered_set>

#include <react/fabric/Component.h>
#include <react/fabric/ComponentManager.h>
#include <react/cxxcomponents/Component.h>
#include <react/cxxcomponents/ComponentManager.h>
#include <react/fabric/ComponentRegistryResolver.h>

namespace facebook {
Expand Down

0 comments on commit 85e9b07

Please sign in to comment.