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 = "text",
20    srcs = glob(
21        ["**/*.cpp"],
22        exclude = glob(["tests/**/*.cpp"]),
23    ),
24    headers = glob(
25        ["**/*.h"],
26        exclude = glob(["tests/**/*.h"]),
27    ),
28    header_namespace = "",
29    exported_headers = subdir_glob(
30        [
31            ("", "*.h"),
32            ("basetext", "*.h"),
33            ("paragraph", "*.h"),
34            ("text", "*.h"),
35            ("rawtext", "*.h"),
36        ],
37        prefix = "react/renderer/components/text",
38    ),
39    cxx_tests = [":tests"],
40    fbandroid_deps = [
41        react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"),
42    ],
43    fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
44    fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
45    force_static = True,
46    labels = [
47        "pfh:ReactNative_CommonInfrastructurePlaceholder",
48        "supermodule:xplat/default/public.react_native.infra",
49    ],
50    platforms = (ANDROID, APPLE, CXX),
51    preprocessor_flags = [
52        "-DLOG_TAG=\"ReactNative\"",
53        "-DWITH_FBSYSTRACE=1",
54    ],
55    visibility = ["PUBLIC"],
56    deps = [
57        "//third-party/glog:glog",
58        "//xplat/fbsystrace:fbsystrace",
59        "//xplat/folly:container_evicting_cache_map",
60        "//xplat/folly:headers_only_do_not_use",
61        "//xplat/folly:memory",
62        "//xplat/folly:molly",
63        YOGA_CXX_TARGET,
64        react_native_xplat_target("react/debug:debug"),
65        react_native_xplat_target("react/renderer/attributedstring:attributedstring"),
66        react_native_xplat_target("react/renderer/core:core"),
67        react_native_xplat_target("react/renderer/debug:debug"),
68        react_native_xplat_target("react/renderer/graphics:graphics"),
69        react_native_xplat_target("react/renderer/textlayoutmanager:textlayoutmanager"),
70        react_native_xplat_target("react/renderer/components/view:view"),
71        react_native_xplat_target("react/renderer/uimanager:uimanager"),
72        react_native_xplat_target("react/renderer/mounting:mounting"),
73        react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
74        react_native_xplat_target("react/utils:utils"),
75        react_native_xplat_target("react/renderer/telemetry:telemetry"),
76    ],
77)
78
79fb_xplat_cxx_test(
80    name = "tests",
81    srcs = glob(["tests/**/*.cpp"]),
82    headers = glob(["tests/**/*.h"]),
83    compiler_flags = [
84        "-fexceptions",
85        "-frtti",
86        "-std=c++17",
87        "-Wall",
88    ],
89    contacts = ["[email protected]"],
90    platforms = (
91        # `Apple` and `Android` flavors are disabled because the module depends on `textlayoutmanager` which requires real an Emulator/Simulator to run.
92        #  At the same time, the code of tests does not rely on the simulator capabilities and it would be wasteful to add `fbandroid_use_instrumentation_test = True`.
93        # (Beware of this option though.)
94        # ANDROID,
95        # APPLE,
96        CXX
97    ),
98    deps = [
99        ":text",
100        "//xplat/folly:molly",
101        "//xplat/third-party/gmock:gtest",
102        react_native_xplat_target("react/debug:debug"),
103    ],
104)
105