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