Skip to content

Commit 1629b9f

Browse files
rshestfacebook-github-bot
authored andcommitted
Refactor BUCK file for WebPerformance (use TurboModule plugins) (facebook#36197)
Summary: Pull Request resolved: facebook#36197 [Changelog][Internal] This turns NativePerformance* module dependencies into "TurboModule plugins", which allows for more streamlined client integration (as it makes them register automatically once the dependency is there). Reviewed By: rubennorte Differential Revision: D43353204 fbshipit-source-id: 01d0089750a4873088dc4aefe34fd48693ee9791
1 parent bcf493f commit 1629b9f

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

BUCK

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ load(
1212
"//tools/build_defs/oss:rn_defs.bzl",
1313
"ANDROID",
1414
"APPLE",
15-
"CXX",
1615
"HERMES_BYTECODE_VERSION",
1716
"IOS",
1817
"RCT_IMAGE_DATA_DECODER_SOCKET",
1918
"RCT_IMAGE_URL_LOADER_SOCKET",
2019
"RCT_URL_REQUEST_HANDLER_SOCKET",
2120
"YOGA_CXX_TARGET",
2221
"get_react_native_ios_target_sdk_version",
22+
"react_cxx_module_plugin_provider",
2323
"react_fabric_component_plugin_provider",
2424
"react_module_plugin_providers",
2525
"react_native_root_target",
@@ -28,6 +28,7 @@ load(
2828
"rn_apple_library",
2929
"rn_apple_xplat_cxx_library",
3030
"rn_extra_build_flags",
31+
"rn_xplat_cxx_library",
3132
"subdir_glob",
3233
)
3334
load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
@@ -1455,7 +1456,7 @@ rn_apple_xplat_cxx_library(
14551456
],
14561457
)
14571458

1458-
rn_apple_xplat_cxx_library(
1459+
rn_xplat_cxx_library(
14591460
name = "RCTWebPerformance",
14601461
srcs = glob([
14611462
"Libraries/WebPerformance/**/*.cpp",
@@ -1465,15 +1466,23 @@ rn_apple_xplat_cxx_library(
14651466
[("Libraries/WebPerformance", "*.h")],
14661467
prefix = "RCTWebPerformance",
14671468
),
1468-
fbandroid_compiler_flags = [
1469-
"-fexceptions",
1470-
"-frtti",
1471-
],
1469+
compiler_flags_enable_exceptions = True,
1470+
compiler_flags_enable_rtti = True,
14721471
labels = [
14731472
"depslint_never_remove",
14741473
"pfh:ReactNative_CommonInfrastructurePlaceholder",
14751474
],
1476-
platforms = (ANDROID, APPLE, CXX),
1475+
platforms = (ANDROID, APPLE),
1476+
plugins = [
1477+
react_cxx_module_plugin_provider(
1478+
name = "NativePerformanceCxx",
1479+
function = "NativePerformanceModuleProvider",
1480+
),
1481+
react_cxx_module_plugin_provider(
1482+
name = "NativePerformanceObserverCxx",
1483+
function = "NativePerformanceObserverModuleProvider",
1484+
),
1485+
],
14771486
visibility = ["PUBLIC"],
14781487
deps = [
14791488
":FBReactNativeSpecJSI",

Libraries/WebPerformance/NativePerformance.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#include "NativePerformance.h"
9-
#include <glog/logging.h>
8+
#include <memory>
9+
1010
#include <jsi/instrumentation.h>
11+
#include "NativePerformance.h"
1112
#include "PerformanceEntryReporter.h"
1213

14+
#include "Plugins.h"
15+
16+
std::shared_ptr<facebook::react::TurboModule> NativePerformanceModuleProvider(
17+
std::shared_ptr<facebook::react::CallInvoker> jsInvoker) {
18+
return std::make_shared<facebook::react::NativePerformance>(
19+
std::move(jsInvoker));
20+
}
21+
1322
namespace facebook::react {
1423

1524
NativePerformance::NativePerformance(std::shared_ptr<CallInvoker> jsInvoker)

Libraries/WebPerformance/NativePerformanceObserver.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#include <memory>
9+
810
#include "NativePerformanceObserver.h"
911
#include "PerformanceEntryReporter.h"
1012

13+
#include "Plugins.h"
14+
15+
std::shared_ptr<facebook::react::TurboModule>
16+
NativePerformanceObserverModuleProvider(
17+
std::shared_ptr<facebook::react::CallInvoker> jsInvoker) {
18+
return std::make_shared<facebook::react::NativePerformanceObserver>(
19+
std::move(jsInvoker));
20+
}
21+
1122
namespace facebook::react {
1223

1324
NativePerformanceObserver::NativePerformanceObserver(

tools/build_defs/oss/rn_defs.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ def react_module_plugin_providers(*args, **kwargs):
424424
def react_fabric_component_plugin_provider(name, native_class_func):
425425
return None
426426

427+
# C++ TurboModule plugins support (stubbed)
428+
def react_cxx_module_plugin_provider(name, function):
429+
return None
430+
427431
HERMES_BYTECODE_VERSION = -1
428432

429433
RCT_IMAGE_DATA_DECODER_SOCKET = None

0 commit comments

Comments
 (0)