From 62173a1569e03350beedffc3ffcf8037a6c56a9b Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 27 Nov 2018 18:29:39 -0800 Subject: [PATCH] Introducing `fabric/mounting` module Summary: ShadowView, ShadowViewMutation, and Differentiator were decoupled to separate module. That enables us to use ShadowView more widely without facing a circular dependency problem. Reviewed By: mdvacca Differential Revision: D13205229 fbshipit-source-id: 7373864bf153a7813c2f97edb263a41454ce0b88 --- React/Fabric/Mounting/RCTMountingManager.h | 4 +- React/Fabric/RCTScheduler.h | 2 +- ReactCommon/fabric/imagemanager/BUCK | 1 + ReactCommon/fabric/mounting/BUCK | 82 +++++++++++++++++++ .../Differentiator.cpp | 0 .../{uimanager => mounting}/Differentiator.h | 2 +- .../{uimanager => mounting}/ShadowView.cpp | 0 .../{uimanager => mounting}/ShadowView.h | 0 .../ShadowViewMutation.cpp | 0 .../ShadowViewMutation.h | 2 +- .../fabric/mounting/tests/MountingTest.cpp | 14 ++++ ReactCommon/fabric/uimanager/BUCK | 1 + ReactCommon/fabric/uimanager/Scheduler.cpp | 1 - .../fabric/uimanager/SchedulerDelegate.h | 2 +- ReactCommon/fabric/uimanager/ShadowTree.cpp | 4 +- ReactCommon/fabric/uimanager/ShadowTree.h | 2 +- .../fabric/uimanager/ShadowTreeDelegate.h | 2 +- 17 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 ReactCommon/fabric/mounting/BUCK rename ReactCommon/fabric/{uimanager => mounting}/Differentiator.cpp (100%) rename ReactCommon/fabric/{uimanager => mounting}/Differentiator.h (92%) rename ReactCommon/fabric/{uimanager => mounting}/ShadowView.cpp (100%) rename ReactCommon/fabric/{uimanager => mounting}/ShadowView.h (100%) rename ReactCommon/fabric/{uimanager => mounting}/ShadowViewMutation.cpp (100%) rename ReactCommon/fabric/{uimanager => mounting}/ShadowViewMutation.h (97%) create mode 100644 ReactCommon/fabric/mounting/tests/MountingTest.cpp diff --git a/React/Fabric/Mounting/RCTMountingManager.h b/React/Fabric/Mounting/RCTMountingManager.h index 68ed226d0da352..9d3a3e11d0a74f 100644 --- a/React/Fabric/Mounting/RCTMountingManager.h +++ b/React/Fabric/Mounting/RCTMountingManager.h @@ -8,8 +8,8 @@ #import #import -#import -#import +#import +#import #import #import diff --git a/React/Fabric/RCTScheduler.h b/React/Fabric/RCTScheduler.h index ff3baa318e79fc..a57c2cbf981989 100644 --- a/React/Fabric/RCTScheduler.h +++ b/React/Fabric/RCTScheduler.h @@ -11,7 +11,7 @@ #import #import #import -#import +#import NS_ASSUME_NONNULL_BEGIN diff --git a/ReactCommon/fabric/imagemanager/BUCK b/ReactCommon/fabric/imagemanager/BUCK index 0886629bb4d6d6..698d098d4a1ff4 100644 --- a/ReactCommon/fabric/imagemanager/BUCK +++ b/ReactCommon/fabric/imagemanager/BUCK @@ -98,6 +98,7 @@ rn_xplat_cxx_library( "xplat//third-party/glog:glog", "xplat//yoga:yoga", react_native_xplat_target("fabric/core:core"), + react_native_xplat_target("fabric/mounting:mounting"), react_native_xplat_target("fabric/debug:debug"), react_native_xplat_target("fabric/graphics:graphics"), ], diff --git a/ReactCommon/fabric/mounting/BUCK b/ReactCommon/fabric/mounting/BUCK new file mode 100644 index 00000000000000..082b1fb2e255c8 --- /dev/null +++ b/ReactCommon/fabric/mounting/BUCK @@ -0,0 +1,82 @@ +load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_debug_preprocessor_flags") +load( + "//tools/build_defs/oss:rn_defs.bzl", + "ANDROID", + "APPLE", + "fb_xplat_cxx_test", + "get_apple_compiler_flags", + "get_apple_inspector_flags", + "react_native_xplat_target", + "rn_xplat_cxx_library", + "subdir_glob", +) + +APPLE_COMPILER_FLAGS = get_apple_compiler_flags() + +rn_xplat_cxx_library( + name = "mounting", + srcs = glob( + ["**/*.cpp"], + exclude = glob(["tests/**/*.cpp"]), + ), + headers = glob( + ["**/*.h"], + exclude = glob(["tests/**/*.h"]), + ), + header_namespace = "", + exported_headers = subdir_glob( + [ + ("", "*.h"), + ], + prefix = "react/mounting", + ), + compiler_flags = [ + "-fexceptions", + "-frtti", + "-std=c++14", + "-Wall", + ], + fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, + fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + get_apple_inspector_flags(), + fbobjc_tests = [ + ":tests", + ], + force_static = True, + macosx_tests_override = [], + platforms = (ANDROID, APPLE), + preprocessor_flags = [ + "-DLOG_TAG=\"ReactNative\"", + "-DWITH_FBSYSTRACE=1", + ], + tests = [], + visibility = ["PUBLIC"], + deps = [ + "xplat//fbsystrace:fbsystrace", + "xplat//folly:headers_only", + "xplat//folly:memory", + "xplat//folly:molly", + "xplat//third-party/glog:glog", + react_native_xplat_target("fabric/core:core"), + react_native_xplat_target("fabric/debug:debug"), + react_native_xplat_target("fabric/events:events"), + ], +) + +fb_xplat_cxx_test( + name = "tests", + srcs = glob(["tests/**/*.cpp"]), + headers = glob(["tests/**/*.h"]), + compiler_flags = [ + "-fexceptions", + "-frtti", + "-std=c++14", + "-Wall", + ], + contacts = ["oncall+react_native@xmail.facebook.com"], + platforms = (ANDROID, APPLE), + deps = [ + "xplat//folly:molly", + "xplat//third-party/gmock:gtest", + ":mounting", + ], +) diff --git a/ReactCommon/fabric/uimanager/Differentiator.cpp b/ReactCommon/fabric/mounting/Differentiator.cpp similarity index 100% rename from ReactCommon/fabric/uimanager/Differentiator.cpp rename to ReactCommon/fabric/mounting/Differentiator.cpp diff --git a/ReactCommon/fabric/uimanager/Differentiator.h b/ReactCommon/fabric/mounting/Differentiator.h similarity index 92% rename from ReactCommon/fabric/uimanager/Differentiator.h rename to ReactCommon/fabric/mounting/Differentiator.h index e24c8a7018bc6c..d209809415b15d 100644 --- a/ReactCommon/fabric/uimanager/Differentiator.h +++ b/ReactCommon/fabric/mounting/Differentiator.h @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace facebook { namespace react { diff --git a/ReactCommon/fabric/uimanager/ShadowView.cpp b/ReactCommon/fabric/mounting/ShadowView.cpp similarity index 100% rename from ReactCommon/fabric/uimanager/ShadowView.cpp rename to ReactCommon/fabric/mounting/ShadowView.cpp diff --git a/ReactCommon/fabric/uimanager/ShadowView.h b/ReactCommon/fabric/mounting/ShadowView.h similarity index 100% rename from ReactCommon/fabric/uimanager/ShadowView.h rename to ReactCommon/fabric/mounting/ShadowView.h diff --git a/ReactCommon/fabric/uimanager/ShadowViewMutation.cpp b/ReactCommon/fabric/mounting/ShadowViewMutation.cpp similarity index 100% rename from ReactCommon/fabric/uimanager/ShadowViewMutation.cpp rename to ReactCommon/fabric/mounting/ShadowViewMutation.cpp diff --git a/ReactCommon/fabric/uimanager/ShadowViewMutation.h b/ReactCommon/fabric/mounting/ShadowViewMutation.h similarity index 97% rename from ReactCommon/fabric/uimanager/ShadowViewMutation.h rename to ReactCommon/fabric/mounting/ShadowViewMutation.h index b5d452bc8d4ef2..2de6e06aad63e1 100644 --- a/ReactCommon/fabric/uimanager/ShadowViewMutation.h +++ b/ReactCommon/fabric/mounting/ShadowViewMutation.h @@ -9,7 +9,7 @@ #include -#include +#include namespace facebook { namespace react { diff --git a/ReactCommon/fabric/mounting/tests/MountingTest.cpp b/ReactCommon/fabric/mounting/tests/MountingTest.cpp new file mode 100644 index 00000000000000..5bc4d38132d059 --- /dev/null +++ b/ReactCommon/fabric/mounting/tests/MountingTest.cpp @@ -0,0 +1,14 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include + +#include + +TEST(MountingTest, testSomething) { + // TODO +} diff --git a/ReactCommon/fabric/uimanager/BUCK b/ReactCommon/fabric/uimanager/BUCK index f0ce4821aea9b6..286c17ac7747a3 100644 --- a/ReactCommon/fabric/uimanager/BUCK +++ b/ReactCommon/fabric/uimanager/BUCK @@ -60,6 +60,7 @@ rn_xplat_cxx_library( "xplat//third-party/glog:glog", react_native_xplat_target("fabric/components/root:root"), react_native_xplat_target("fabric/components/view:view"), + react_native_xplat_target("fabric/mounting:mounting"), react_native_xplat_target("fabric/core:core"), react_native_xplat_target("fabric/debug:debug"), react_native_xplat_target("fabric/events:events"), diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index 478f52def840fc..7030a1ce894046 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -14,7 +14,6 @@ #include #include "ComponentDescriptorFactory.h" -#include "Differentiator.h" namespace facebook { namespace react { diff --git a/ReactCommon/fabric/uimanager/SchedulerDelegate.h b/ReactCommon/fabric/uimanager/SchedulerDelegate.h index 8215333295d781..946e4eb6bc9114 100644 --- a/ReactCommon/fabric/uimanager/SchedulerDelegate.h +++ b/ReactCommon/fabric/uimanager/SchedulerDelegate.h @@ -9,7 +9,7 @@ #include #include -#include +#include namespace facebook { namespace react { diff --git a/ReactCommon/fabric/uimanager/ShadowTree.cpp b/ReactCommon/fabric/uimanager/ShadowTree.cpp index 54e2759ab5d936..b1cb6e87f5d983 100644 --- a/ReactCommon/fabric/uimanager/ShadowTree.cpp +++ b/ReactCommon/fabric/uimanager/ShadowTree.cpp @@ -7,10 +7,10 @@ #include #include +#include +#include -#include "Differentiator.h" #include "ShadowTreeDelegate.h" -#include "ShadowViewMutation.h" namespace facebook { namespace react { diff --git a/ReactCommon/fabric/uimanager/ShadowTree.h b/ReactCommon/fabric/uimanager/ShadowTree.h index dca2a89e019c3a..0f8c6397ed34b5 100644 --- a/ReactCommon/fabric/uimanager/ShadowTree.h +++ b/ReactCommon/fabric/uimanager/ShadowTree.h @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include namespace facebook { namespace react { diff --git a/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h b/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h index e4d14018405ca2..c5a47ad6dccfe3 100644 --- a/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h +++ b/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace facebook { namespace react {