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    fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
37    fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
38    force_static = True,
39    labels = [
40        "pfh:ReactNative_CommonInfrastructurePlaceholder",
41        "supermodule:xplat/default/public.react_native.infra",
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:headers_only_do_not_use",
54        "//xplat/folly:memory",
55        "//xplat/folly:molly",
56        react_native_xplat_target("butter:butter"),
57        react_native_xplat_target("react/debug:debug"),
58    ],
59)
60
61fb_xplat_cxx_test(
62    name = "tests",
63    srcs = glob(["tests/**/*.cpp"]),
64    headers = glob(["tests/**/*.h"]),
65    compiler_flags = [
66        "-fexceptions",
67        "-frtti",
68        "-std=c++17",
69        "-Wall",
70    ],
71    contacts = ["[email protected]"],
72    platforms = (ANDROID, APPLE, CXX),
73    deps = [
74        ":debug",
75        "//xplat/folly:molly",
76        "//xplat/third-party/gmock:gtest",
77    ],
78)
79