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    compiler_flags_pedantic = True,
40    cxx_tests = [":tests"],
41    fbandroid_deps = [
42        react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"),
43    ],
44    fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
45    fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
46    force_static = True,
47    labels = [
48        "pfh:ReactNative_CommonInfrastructurePlaceholder",
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        YOGA_CXX_TARGET,
60        react_native_xplat_target("react/debug:debug"),
61        react_native_xplat_target("react/renderer/attributedstring:attributedstring"),
62        react_native_xplat_target("react/renderer/core:core"),
63        react_native_xplat_target("react/renderer/debug:debug"),
64        react_native_xplat_target("react/renderer/graphics:graphics"),
65        react_native_xplat_target("react/renderer/textlayoutmanager:textlayoutmanager"),
66        react_native_xplat_target("react/renderer/components/view:view"),
67        react_native_xplat_target("react/renderer/uimanager:uimanager"),
68        react_native_xplat_target("react/renderer/mounting:mounting"),
69        react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
70        react_native_xplat_target("react/utils:utils"),
71        react_native_xplat_target("react/renderer/telemetry:telemetry"),
72    ],
73)
74
75fb_xplat_cxx_test(
76    name = "tests",
77    srcs = glob(["tests/**/*.cpp"]),
78    headers = glob(["tests/**/*.h"]),
79    compiler_flags = [
80        "-fexceptions",
81        "-frtti",
82        "-std=c++17",
83        "-Wall",
84    ],
85    contacts = ["[email protected]"],
86    platforms = (
87        # `Apple` and `Android` flavors are disabled because the module depends on `textlayoutmanager` which requires real an Emulator/Simulator to run.
88        #  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`.
89        # (Beware of this option though.)
90        # ANDROID,
91        # APPLE,
92        CXX
93    ),
94    deps = [
95        ":text",
96        "//xplat/third-party/gmock:gtest",
97        react_native_xplat_target("react/debug:debug"),
98    ],
99)
100