1load(
2    "//tools/build_defs/oss:rn_defs.bzl",
3    "ANDROID",
4    "APPLE",
5    "CXX",
6    "YOGA_CXX_TARGET",
7    "fb_xplat_cxx_test",
8    "get_apple_compiler_flags",
9    "get_apple_inspector_flags",
10    "get_preprocessor_flags_for_build_mode",
11    "react_native_xplat_target",
12    "rn_xplat_cxx_library",
13    "subdir_glob",
14)
15
16APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
17
18rn_xplat_cxx_library(
19    name = "root",
20    srcs = glob(
21        ["**/*.cpp"],
22        exclude = glob(["tests/**/*.cpp"]),
23    ),
24    headers = [],
25    header_namespace = "",
26    exported_headers = subdir_glob(
27        [
28            ("", "*.h"),
29        ],
30        prefix = "react/renderer/components/root",
31    ),
32    fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
33    fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
34    labels = [
35        "pfh:ReactNative_CommonInfrastructurePlaceholder",
36        "supermodule:xplat/default/public.react_native.infra",
37    ],
38    macosx_tests_override = [],
39    platforms = (ANDROID, APPLE, CXX),
40    preprocessor_flags = [
41        "-DLOG_TAG=\"ReactNative\"",
42        "-DWITH_FBSYSTRACE=1",
43    ],
44    tests = [":tests"],
45    visibility = ["PUBLIC"],
46    deps = [
47        "//third-party/glog:glog",
48        "//xplat/fbsystrace:fbsystrace",
49        "//xplat/folly:headers_only_do_not_use",
50        "//xplat/folly:memory",
51        "//xplat/folly:molly",
52        YOGA_CXX_TARGET,
53        react_native_xplat_target("react/renderer/debug:debug"),
54        react_native_xplat_target("react/renderer/core:core"),
55        react_native_xplat_target("react/renderer/graphics:graphics"),
56        react_native_xplat_target("react/renderer/components/view:view"),
57    ],
58)
59
60fb_xplat_cxx_test(
61    name = "tests",
62    srcs = glob(["tests/**/*.cpp"]),
63    headers = glob(["tests/**/*.h"]),
64    compiler_flags = [
65        "-fexceptions",
66        "-frtti",
67        "-std=c++17",
68        "-Wall",
69    ],
70    contacts = ["[email protected]"],
71    platforms = (ANDROID, APPLE, CXX),
72    deps = [
73        ":root",
74        "//xplat/folly:molly",
75        "//xplat/third-party/gmock:gtest",
76        react_native_xplat_target("react/renderer/element:element"),
77    ],
78)
79