1load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob")
2load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "get_android_inspector_flags", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_target", "rn_xplat_cxx_library")
3
4rn_xplat_cxx_library(
5    name = "module",
6    header_namespace = "",
7    exported_headers = subdir_glob(
8        [
9            ("", "CxxModule.h"),
10            ("", "JsArgumentHelpers.h"),
11            ("", "JsArgumentHelpers-inl.h"),
12        ],
13        prefix = "cxxreact",
14    ),
15    compiler_flags_pedantic = True,
16    fbobjc_compiler_flags = get_apple_compiler_flags(),
17    force_static = True,
18    labels = [
19        "pfh:ReactNative_CommonInfrastructurePlaceholder",
20    ],
21    visibility = [
22        "PUBLIC",
23    ],
24    deps = [
25        "//xplat/folly:dynamic",
26    ],
27)
28
29rn_xplat_cxx_library(
30    name = "jsbigstring",
31    srcs = [
32        "JSBigString.cpp",
33    ],
34    header_namespace = "",
35    exported_headers = subdir_glob(
36        [("", "JSBigString.h")],
37        prefix = "cxxreact",
38    ),
39    compiler_flags_pedantic = True,
40    fbobjc_compiler_flags = get_apple_compiler_flags(),
41    force_static = True,
42    labels = [
43        "pfh:ReactNative_CommonInfrastructurePlaceholder",
44    ],
45    visibility = [
46        "PUBLIC",
47    ],
48    deps = [
49        "//third-party/glog:glog",
50        "//xplat/folly:exception",
51        "//xplat/folly:memory",
52        "//xplat/folly:portability_fcntl",
53        "//xplat/folly:portability_sys_mman",
54        "//xplat/folly:portability_sys_stat",
55        "//xplat/folly:portability_unistd",
56        "//xplat/folly:scope_guard",
57    ],
58)
59
60rn_xplat_cxx_library(
61    name = "samplemodule",
62    srcs = ["SampleCxxModule.cpp"],
63    header_namespace = "",
64    exported_headers = ["SampleCxxModule.h"],
65    compiler_flags = [
66        "-fno-omit-frame-pointer",
67    ],
68    compiler_flags_pedantic = True,
69    fbobjc_compiler_flags = get_apple_compiler_flags(),
70    labels = [
71        "pfh:ReactNative_CommonInfrastructurePlaceholder",
72    ],
73    soname = "libxplat_react_module_samplemodule.$(ext)",
74    visibility = [
75        "PUBLIC",
76    ],
77    deps = [
78        ":module",
79        "//third-party/glog:glog",
80        "//xplat/folly:memory",
81    ],
82)
83
84CXXREACT_PUBLIC_HEADERS = [
85    "CxxNativeModule.h",
86    "ErrorUtils.h",
87    "Instance.h",
88    "JSBundleType.h",
89    "JSExecutor.h",
90    "JSIndexedRAMBundle.h",
91    "JSModulesUnbundle.h",
92    "MessageQueueThread.h",
93    "MethodCall.h",
94    "ModuleRegistry.h",
95    "NativeModule.h",
96    "NativeToJsBridge.h",
97    "RAMBundleRegistry.h",
98    "ReactMarker.h",
99    "RecoverableError.h",
100    "SharedProxyCxxModule.h",
101    "SystraceSection.h",
102]
103
104rn_xplat_cxx_library(
105    name = "bridge",
106    srcs = glob(
107        ["*.cpp"],
108        exclude = [
109            "JSBigString.cpp",
110            "SampleCxxModule.cpp",
111        ],
112    ),
113    headers = glob(
114        ["*.h"],
115        exclude = CXXREACT_PUBLIC_HEADERS,
116    ),
117    header_namespace = "",
118    exported_headers = dict([
119        (
120            "cxxreact/%s" % header,
121            header,
122        )
123        for header in CXXREACT_PUBLIC_HEADERS
124    ]),
125    compiler_flags_pedantic = True,
126    exported_preprocessor_flags = [
127        "-DWITH_FBSYSTRACE=1",
128    ],
129    fbandroid_preprocessor_flags = get_android_inspector_flags(),
130    fbobjc_compiler_flags = get_apple_compiler_flags(),
131    fbobjc_force_static = True,
132    fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
133    labels = [
134        "pfh:ReactNative_CommonInfrastructurePlaceholder",
135    ],
136    macosx_tests_override = [],
137    platforms = (ANDROID, APPLE, CXX),
138    preprocessor_flags = [
139        "-DLOG_TAG=\"ReactNative\"",
140    ],
141    tests = [
142        react_native_xplat_target("cxxreact/tests:tests"),
143    ],
144    visibility = ["PUBLIC"],
145    deps = [
146        ":jsbigstring",
147        ":module",
148        "//third-party/glog:glog",
149        "//xplat/fbsystrace:fbsystrace",
150        "//xplat/folly:conv",
151        "//xplat/folly:dynamic",
152        "//xplat/folly:json",
153        "//xplat/folly:memory",
154        "//xplat/folly:move_wrapper",
155        "//xplat/folly:optional",
156        "//xplat/jsi:jsi",
157        react_native_xplat_target("callinvoker:callinvoker"),
158        react_native_xplat_target("jsinspector:jsinspector"),
159        react_native_xplat_target("runtimeexecutor:runtimeexecutor"),
160        react_native_xplat_target("reactperflogger:reactperflogger"),
161        react_native_xplat_target("logger:logger"),
162    ],
163)
164