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